forked from AllenDang/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
imnodes.go
157 lines (119 loc) · 4.06 KB
/
imnodes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package imgui
// #cgo CXXFLAGS: -std=c++11
// #include "imnodesWrapper.h"
import "C"
func ImNodesCreateContext() {
C.iggImNodesCreateContext()
}
func ImNodesDestroyContext() {
C.iggImNodesDestroyContext()
}
func ImNodesBeginNodeEditor() {
C.iggImNodesBeginNodeEditor()
}
func ImNodesEndNodeEditor() {
C.iggImNodesEndNodeEditor()
}
func ImNodesBeginNode(id int) {
C.iggImNodesBeginNode(C.int(id))
}
func ImNodesEndNode() {
C.iggImNodesEndNode()
}
func ImNodesBeginNodeTitleBar() {
C.iggImNodesBeginNodeTitleBar()
}
func ImNodesEndNodeTitleBar() {
C.iggImNodesEndNodeTitleBar()
}
func ImNodesBeginInputAttribute(id int) {
C.iggImNodesBeginInputAttribute(C.int(id))
}
func ImNodesEndInputAttribute() {
C.iggImNodesEndInputAttribute()
}
func ImNodesBeginOutputAttribute(id int) {
C.iggImNodesBeginOutputAttribute(C.int(id))
}
func ImNodesEndOutputAttribute() {
C.iggImNodesEndOutputAttribute()
}
func ImNodesLink(id, startAttributeId, endAttributeId int) {
C.iggImNodesLink(C.int(id), C.int(startAttributeId), C.int(endAttributeId))
}
func ImNodesIsLinkCreated() (startedNodeId, startedAttributeId, endedNodeId, endedAttributeId int32, createdFromSnap, isLinkCreated bool) {
sNodeIdArg, sNodeIdDeleter := wrapInt32(&startedNodeId)
defer sNodeIdDeleter()
sAttrIdArg, sAttrIdDeleter := wrapInt32(&startedAttributeId)
defer sAttrIdDeleter()
eNodeIdArg, eNodeIdDeleter := wrapInt32(&endedNodeId)
defer eNodeIdDeleter()
eAttrIdArg, eAttrIdDeleter := wrapInt32(&endedAttributeId)
defer eAttrIdDeleter()
bArg, bArgDeleter := wrapBool(&createdFromSnap)
defer bArgDeleter()
isLinkCreated = C.iggImNodesIsLinkCreated(sNodeIdArg, sAttrIdArg, eNodeIdArg, eAttrIdArg, bArg) != 0
return
}
func ImNodesIsLinkDestroyed() (linkId int32, isDestroyed bool) {
linkIdArg, linkIdDeleter := wrapInt32(&linkId)
defer linkIdDeleter()
isDestroyed = C.iggImNodesIsLinkDestroyed(linkIdArg) != 0
return
}
type ImNodesAttributeFlags int
const (
AttributeFlags_None ImNodesAttributeFlags = 0
// Allow detaching a link by left-clicking and dragging the link at a pin it is connected to.
// NOTE: the user has to actually delete the link for this to work. A deleted link can be
// detected by calling IsLinkDestroyed() after EndNodeEditor().
AttributeFlags_EnableLinkDetachWithDragClick ImNodesAttributeFlags = 1 << 0
// Visual snapping of an in progress link will trigger IsLink Created/Destroyed events. Allows
// for previewing the creation of a link while dragging it across attributes. See here for demo:
// https://github.com/Nelarius/imnodes/issues/41#issuecomment-647132113 NOTE: the user has to
// actually delete the link for this to work. A deleted link can be detected by calling
// IsLinkDestroyed() after EndNodeEditor().
AttributeFlags_EnableLinkCreationOnSnap ImNodesAttributeFlags = 1 << 1
)
func ImNodesPushAttributeFlag(flag ImNodesAttributeFlags) {
C.iggImNodesPushAttributeFlag(C.int(flag))
}
func ImNodesPopAttributeFlag() {
C.iggImNodesPopAttributeFlag()
}
func ImNodesEnableDetachWithCtrlClick() {
C.iggImNodesEnableDetachWithCtrlClick()
}
func ImNodesSetNodeScreenSpacePos(nodeId int, pos Vec2) {
posArg, _ := pos.wrapped()
C.iggImNodesSetNodeScreenSpacePos(C.int(nodeId), posArg)
}
func ImNodesSetNodeEditorSpacePos(nodeId int, pos Vec2) {
posArg, _ := pos.wrapped()
C.iggImNodesSetNodeEditorSpacePos(C.int(nodeId), posArg)
}
func ImNodesSetNodeGridSpacePos(nodeId int, pos Vec2) {
posArg, _ := pos.wrapped()
C.iggImNodesSetNodeGridSpacePos(C.int(nodeId), posArg)
}
func ImNodesGetNodeScreenSpacePos(nodeId int) *Vec2 {
var pos Vec2
valueArg, valueDeleter := pos.wrapped()
defer valueDeleter()
C.iggImNodesGetNodeScreenSpacePos(C.int(nodeId), valueArg)
return &pos
}
func ImNodesGetNodeEditorSpacePos(nodeId int) *Vec2 {
var pos Vec2
valueArg, valueDeleter := pos.wrapped()
defer valueDeleter()
C.iggImNodesGetNodeEditorSpacePos(C.int(nodeId), valueArg)
return &pos
}
func ImNodesGetNodeGridSpacePos(nodeId int) *Vec2 {
var pos Vec2
valueArg, valueDeleter := pos.wrapped()
defer valueDeleter()
C.iggImNodesGetNodeGridSpacePos(C.int(nodeId), valueArg)
return &pos
}