forked from HACKERALERT/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Style.go
161 lines (147 loc) · 4.84 KB
/
Style.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
package imgui
// #include "StyleWrapper.h"
import "C"
// StyleVarID identifies a style variable in the UI style.
type StyleVarID int
const (
StyleVarAlpha StyleVarID = iota
StyleVarDisabledAlpha
StyleVarWindowPadding
StyleVarWindowRounding
StyleVarWindowBorderSize
StyleVarWindowMinSize
StyleVarWindowTitleAlign
StyleVarChildRounding
StyleVarChildBorderSize
StyleVarPopupRounding
StyleVarPopupBorderSize
StyleVarFramePadding
StyleVarFrameRounding
StyleVarFrameBorderSize
StyleVarItemSpacing
StyleVarItemInnerSpacing
StyleVarIndentSpacing
StyleVarCellPadding
StyleVarScrollbarSize
StyleVarScrollbarRounding
StyleVarGrabMinSize
StyleVarGrabRounding
StyleVarTabRounding
StyleVarButtonTextAlign
StyleVarSelectableTextAlign
)
// StyleColorID identifies a color in the UI style.
type StyleColorID int
// StyleColor identifier
const (
StyleColorText StyleColorID = iota
StyleColorTextDisabled
StyleColorWindowBg // Background of normal windows
StyleColorChildBg // Background of child windows
StyleColorPopupBg // Background of popups, menus, tooltips windows
StyleColorBorder
StyleColorBorderShadow
StyleColorFrameBg // Background of checkbox, radio button, plot, slider, text input
StyleColorFrameBgHovered
StyleColorFrameBgActive
StyleColorTitleBg
StyleColorTitleBgActive
StyleColorTitleBgCollapsed
StyleColorMenuBarBg
StyleColorScrollbarBg
StyleColorScrollbarGrab
StyleColorScrollbarGrabHovered
StyleColorScrollbarGrabActive
StyleColorCheckMark
StyleColorSliderGrab
StyleColorSliderGrabActive
StyleColorButton
StyleColorButtonHovered
StyleColorButtonActive
StyleColorHeader // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem
StyleColorHeaderHovered
StyleColorHeaderActive
StyleColorSeparator
StyleColorSeparatorHovered
StyleColorSeparatorActive
StyleColorResizeGrip
StyleColorResizeGripHovered
StyleColorResizeGripActive
StyleColorTab
StyleColorTabHovered
StyleColorTabActive
StyleColorTabUnfocused
StyleColorTabUnfocusedActive
StyleColorPlotLines
StyleColorPlotLinesHovered
StyleColorPlotHistogram
StyleColorPlotHistogramHovered
StyleColorTableHeaderBg // Table header background
StyleColorTableBorderStrong // Table outer and header borders (prefer using Alpha=1.0 here)
StyleColorTableBorderLight // Table inner borders (prefer using Alpha=1.0 here)
StyleColorTableRowBg // Table row background (even rows)
StyleColorTableRowBgAlt // Table row background (odd rows)
StyleColorTextSelectedBg
StyleColorDragDropTarget
StyleColorNavHighlight // Gamepad/keyboard: current highlighted item
StyleColorNavWindowingHighlight // Highlight window when using CTRL+TAB
StyleColorNavWindowingDimBg // Darken/colorize entire screen behind the CTRL+TAB window list, when active
StyleColorModalWindowDimBg // Darken/colorize entire screen behind a modal window, when one is active
)
// Style describes the overall graphical representation of the user interface.
type Style uintptr
func (style Style) handle() C.IggGuiStyle {
return C.IggGuiStyle(style)
}
// ItemSpacing is the horizontal and vertical spacing between widgets/lines.
func (style Style) ItemSpacing() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggStyleGetItemSpacing(style.handle(), valueArg)
valueFin()
return value
}
// ItemInnerSpacing is the horizontal and vertical spacing between elements of
// a composed widget (e.g. a slider and its label).
func (style Style) ItemInnerSpacing() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggStyleGetItemInnerSpacing(style.handle(), valueArg)
valueFin()
return value
}
func (style Style) WindowPadding() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggStyleGetWindowPadding(style.handle(), valueArg)
valueFin()
return value
}
func (style Style) FramePadding() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggStyleGetFramePadding(style.handle(), valueArg)
valueFin()
return value
}
// SetColor sets a color value of the UI style.
func (style Style) SetColor(id StyleColorID, value Vec4) {
valueArg, _ := value.wrapped()
C.iggStyleSetColor(style.handle(), C.int(id), valueArg)
}
func (style Style) GetColor(id StyleColorID) Vec4 {
var col Vec4
colArg, colFin := col.wrapped()
C.iggStyleGetColor(style.handle(), C.int(id), colArg)
colFin()
return col
}
// ScaleAllSizes applies a scaling factor to all sizes.
// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function.
// Scaling the fonts is done separately and is up to you.
//
// Important: This operation is lossy because all sizes are rounded to integer.
// If you need to change your scale multiples, call this over a freshly initialized style rather than scaling multiple times.
func (style Style) ScaleAllSizes(scale float32) {
C.iggStyleScaleAllSizes(style.handle(), C.float(scale))
}