forked from inkyblackness/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layout.go
179 lines (148 loc) · 5 KB
/
Layout.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package imgui
// #include "wrapper/Layout.h"
import "C"
// PushID pushes the given identifier into the ID stack. IDs are hash of the entire stack!
func PushID(id string) {
idArg, idFin := wrapString(id)
defer idFin()
C.iggPushID(idArg)
}
// PushIDInt pushes the given identifier into the ID stack. IDs are hash of the entire stack!
func PushIDInt(id int) {
C.iggPushIDInt(C.int(id))
}
// PopID removes the last pushed identifier from the ID stack.
func PopID() {
C.iggPopID()
}
// Separator is generally horizontal. Inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
func Separator() {
C.iggSeparator()
}
// SameLineV is between widgets or groups to layout them horizontally.
func SameLineV(posX float32, spacingW float32) {
C.iggSameLine(C.float(posX), C.float(spacingW))
}
// SameLine calls SameLineV(0, -1).
func SameLine() {
SameLineV(0, -1)
}
// Spacing adds vertical spacing.
func Spacing() {
C.iggSpacing()
}
// Dummy adds a dummy item of given size.
func Dummy(size Vec2) {
sizeArg, _ := size.wrapped()
C.iggDummy(sizeArg)
}
// Indent moves content position toward the right by style.IndentSpacing.
func Indent() {
C.iggIndent(0)
}
// Unindent moves content position back to the left by style.IndentSpacing.
func Unindent() {
C.iggUnindent(0)
}
// IndentV moves content position toward the right, by style.IndentSpacing or indentW if not zero.
func IndentV(indentW float32) {
C.iggIndent(C.float(indentW))
}
// UnindentV moves content position back to the left, by style.IndentSpacing or indentW if not zero.
func UnindentV(indentW float32) {
C.iggUnindent(C.float(indentW))
}
// BeginGroup locks horizontal starting position + capture group bounding box into one "item";
// So you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.
func BeginGroup() {
C.iggBeginGroup()
}
// EndGroup must be called for each call to BeginGroup().
func EndGroup() {
C.iggEndGroup()
}
/*
// Disabled API is beta as v1.84; they can change in such a way that require a
// major version. So, it's better to leave them out until out of beta.
// BeginDisabled starts a disabled group.
func BeginDisabled() {
BeginDisabledV(true)
}
// BeginDisabledV starts a disabled group only if parameter is true.
func BeginDisabledV(disabled bool) {
C.iggBeginDisabled(castBool(disabled))
}
// EndDisabled must be called for each call to BeginDisabled().
func EndDisabled() {
C.iggEndDisabled()
}
*/
// CursorPos returns the cursor position in window coordinates (relative to window position).
func CursorPos() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggCursorPos(valueArg)
valueFin()
return value
}
// CursorPosX returns the x-coordinate of the cursor position in window coordinates.
func CursorPosX() float32 {
return float32(C.iggCursorPosX())
}
// CursorPosY returns the y-coordinate of the cursor position in window coordinates.
func CursorPosY() float32 {
return float32(C.iggCursorPosY())
}
// CursorStartPos returns the initial cursor position in window coordinates.
func CursorStartPos() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggCursorStartPos(valueArg)
valueFin()
return value
}
// CursorScreenPos returns cursor position in absolute coordinates (useful to work with DrawList API).
// Generally top-left == MainViewport().Pos() == (0,0) in single viewport mode,
// and bottom-right == MainViewport().Pos()+Size == io.DisplaySize in single-viewport mode.
func CursorScreenPos() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggCursorScreenPos(valueArg)
valueFin()
return value
}
// SetCursorPos sets the cursor relative to the current window.
func SetCursorPos(localPos Vec2) {
localPosArg, _ := localPos.wrapped()
C.iggSetCursorPos(localPosArg)
}
// SetCursorScreenPos sets cursor position in absolute coordinates.
func SetCursorScreenPos(absPos Vec2) {
absPosArg, _ := absPos.wrapped()
C.iggSetCursorScreenPos(absPosArg)
}
// AlignTextToFramePadding vertically aligns upcoming text baseline to
// FramePadding.y so that it will align properly to regularly framed
// items. Call if you have text on a line before a framed item.
func AlignTextToFramePadding() {
C.iggAlignTextToFramePadding()
}
// TextLineHeight returns ~ FontSize.
func TextLineHeight() float32 {
return float32(C.iggGetTextLineHeight())
}
// TextLineHeightWithSpacing returns ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text).
func TextLineHeightWithSpacing() float32 {
return float32(C.iggGetTextLineHeightWithSpacing())
}
// FrameHeight returns the height of the current frame. This is equal to the
// font size plus the padding at the top and bottom.
func FrameHeight() float32 {
return float32(C.iggGetFrameHeight())
}
// FrameHeightWithSpacing returns the height of the current frame with the item
// spacing added. This is equal to the font size plus the padding at the top
// and bottom, plus the value of style.ItemSpacing.y.
func FrameHeightWithSpacing() float32 {
return float32(C.iggGetFrameHeightWithSpacing())
}