forked from zeozeozeo/microui-go
-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.go
147 lines (121 loc) · 2.47 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
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
package debugui
import (
"image"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/exp/textinput"
)
type controlID uint64
type poolItem struct {
id controlID
lastUpdate int
}
type baseCommand struct {
typ int
}
type jumpCommand struct {
dstIdx int
}
type clipCommand struct {
rect image.Rectangle
}
type rectCommand struct {
rect image.Rectangle
color color.Color
}
type textCommand struct {
pos image.Point
color color.Color
str string
}
type iconCommand struct {
rect image.Rectangle
icon icon
color color.Color
}
type drawCommand struct {
f func(screen *ebiten.Image)
}
type layout struct {
body image.Rectangle
position image.Point
height int
max image.Point
widths []int
itemIndex int
nextRow int
indent int
}
type command struct {
typ 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
draw drawCommand // type 6
}
type container struct {
layout Layout
headIdx int
tailIdx int
zIndex int
open bool
}
type Layout struct {
Rect image.Rectangle
Body image.Rectangle
ContentSize image.Point
Scroll image.Point
}
type style struct {
size image.Point
padding int
spacing int
indent int
titleHeight int
scrollbarSize int
thumbSize int
colors [ColorMax + 1]color.RGBA
}
type Context struct {
// core state
style *style
hover controlID
focus controlID
lastID controlID
lastRect image.Rectangle
lastZIndex int
keepFocus bool
tick int
hoverRoot *container
nextHoverRoot *container
scrollTarget *container
numberEditBuf string
numberEdit controlID
// stacks
commandList []*command
rootList []*container
containerStack []*container
clipStack []image.Rectangle
idStack []controlID
layoutStack []layout
// retained state pools
containerPool [containerPoolSize]poolItem
containers [containerPoolSize]container
treeNodePool [treeNodePoolSize]poolItem
// input state
mousePos image.Point
lastMousePos image.Point
mouseDelta image.Point
scrollDelta image.Point
mouseDown int
mousePressed int
keyDown int
keyPressed int
textFields map[controlID]*textinput.Field
}