-
Notifications
You must be signed in to change notification settings - Fork 6
/
types.go
167 lines (138 loc) · 2.62 KB
/
types.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
package microui
import "image/color"
type mu_Id uintptr
type Vec2 struct {
X, Y int
}
type Rect struct {
X, Y, W, H int
}
type Color struct {
R, G, B, A uint8
}
func (c *Color) ToRGBA() color.RGBA {
return color.RGBA{c.R, c.G, c.B, c.A}
}
type MuPoolItem struct {
ID mu_Id
LastUpdate int
}
type BaseCommand struct {
Type int
}
type JumpCommand struct {
Base BaseCommand
DstIdx int
}
type ClipCommand struct {
Base BaseCommand
Rect Rect
}
type RectCommand struct {
Base BaseCommand
Rect Rect
Color Color
}
type Font interface{} // Font is interface{}, microui does not manage fonts
type TextCommand struct {
Base BaseCommand
Font Font
Pos Vec2
Color Color
Str string
}
type IconCommand struct {
Base BaseCommand
Rect Rect
Id int
Color Color
}
type Layout struct {
Body Rect
Next Rect
Position Vec2
Size Vec2
Max Vec2
Widths [MU_MAX_WIDTHS]int
Items int
ItemIndex int
NextRow int
NextType int
Indent int
}
type Command struct {
Type int
Idx int
Base BaseCommand // type 0 (TODO)
Jump JumpCommand // type 1
Clip ClipCommand // type 2
Rect RectCommand // type 3
Text TextCommand // type 4
Icon IconCommand // type 5
}
type Container struct {
HeadIdx int
TailIdx int
Rect Rect
Body Rect
ContentSize Vec2
Scroll Vec2
Zindex int
Open bool
}
func (c *Container) Clear() {
*c = Container{}
}
type Style struct {
Font Font
Size Vec2
Padding int
Spacing int
Indent int
TitleHeight int
ScrollbarSize int
ThumbSize int
Colors [MU_COLOR_MAX]Color
}
type Context struct {
// callbacks
TextWidth func(font Font, str string) int
TextHeight func(font Font) int
DrawFrame func(ctx *Context, rect Rect, colorid int)
// core state
_style Style
Style *Style
Hover mu_Id
Focus mu_Id
LastID mu_Id
LastRect Rect
LastZindex int
UpdatedFocus bool
Frame int
HoverRoot *Container
NextHoverRoot *Container
ScrollTarget *Container
NumberEditBuf string
NumberEdit mu_Id
// stacks
CommandList []*Command
RootList []*Container
ContainerStack []*Container
ClipStack []Rect
IdStack []mu_Id
LayoutStack []Layout
// retained state pools
ContainerPool [MU_CONTAINERPOOL_SIZE]MuPoolItem
Containers [MU_CONTAINERPOOL_SIZE]Container
TreeNodePool [MU_TREENODEPOOL_SIZE]MuPoolItem
// input state
MousePos Vec2
lastMousePos Vec2
MouseDelta Vec2
ScrollDelta Vec2
MouseDown int
MousePressed int
KeyDown int
KeyPressed int
TextInput []rune
}