Skip to content

Commit 96f66cf

Browse files
committed
debugui: unexport color consts
1 parent 404b475 commit 96f66cf

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

container.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,21 @@ func (c *Context) window(title string, bounds image.Rectangle, opt option, f fun
119119
// draw frame
120120
collapsed := cnt.collapsed
121121
if (^opt&optionNoFrame) != 0 && !collapsed {
122-
c.drawFrame(bounds, ColorWindowBG)
122+
c.drawFrame(bounds, colorWindowBG)
123123
}
124124

125125
// do title bar
126126
if (^opt & optionNoTitle) != 0 {
127127
tr := bounds
128128
tr.Max.Y = tr.Min.Y + c.style().titleHeight
129-
c.drawFrame(tr, ColorTitleBG)
129+
c.drawFrame(tr, colorTitleBG)
130130

131131
// do title text
132132
if (^opt & optionNoTitle) != 0 {
133133
id := c.idFromString("title", id)
134134
r := image.Rect(tr.Min.X+tr.Dy()-c.style().padding, tr.Min.Y, tr.Max.X, tr.Max.Y)
135135
c.updateControl(id, r, opt)
136-
c.drawControlText(title, r, ColorTitleText, opt)
136+
c.drawControlText(title, r, colorTitleText, opt)
137137
if id == c.focus && ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
138138
cnt.layout.Bounds = cnt.layout.Bounds.Add(c.mouseDelta())
139139
}
@@ -148,7 +148,7 @@ func (c *Context) window(title string, bounds image.Rectangle, opt option, f fun
148148
if collapsed {
149149
icon = iconCollapsed
150150
}
151-
c.drawIcon(icon, r, c.style().colors[ColorTitleText])
151+
c.drawIcon(icon, r, c.style().colors[colorTitleText])
152152
c.updateControl(id, r, opt)
153153
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) && id == c.focus {
154154
cnt.collapsed = !cnt.collapsed

control.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (c *Context) Text(text string) {
161161
endIdx = p
162162
p++
163163
}
164-
c.drawControlText(text[startIdx:endIdx], bounds, ColorText, 0)
164+
c.drawControlText(text[startIdx:endIdx], bounds, colorText, 0)
165165
p = endIdx + 1
166166
return false, nil
167167
}); err != nil {
@@ -186,9 +186,9 @@ func (c *Context) button(label string, opt option, callerPC uintptr) (controlID,
186186
res = true
187187
}
188188
// draw
189-
c.drawControlFrame(id, bounds, ColorButton, opt)
189+
c.drawControlFrame(id, bounds, colorButton, opt)
190190
if len(label) > 0 {
191-
c.drawControlText(label, bounds, ColorText, opt)
191+
c.drawControlText(label, bounds, colorText, opt)
192192
}
193193
return res, nil
194194
})
@@ -211,13 +211,13 @@ func (c *Context) Checkbox(state *bool, label string) bool {
211211
res = true
212212
*state = !*state
213213
}
214-
c.drawControlFrame(id, box, ColorBase, 0)
214+
c.drawControlFrame(id, box, colorBase, 0)
215215
if *state {
216-
c.drawIcon(iconCheck, box, c.style().colors[ColorText])
216+
c.drawIcon(iconCheck, box, c.style().colors[colorText])
217217
}
218218
if label != "" {
219219
bounds = image.Rect(bounds.Min.X+lineHeight(), bounds.Min.Y, bounds.Max.X, bounds.Max.Y)
220-
c.drawControlText(label, bounds, ColorText, 0)
220+
c.drawControlText(label, bounds, colorText, 0)
221221
}
222222
return res, nil
223223
})
@@ -262,15 +262,15 @@ func (c *Context) slider(value *float64, low, high, step float64, digits int, op
262262
}
263263

264264
// draw base
265-
c.drawControlFrame(id, bounds, ColorBase, opt)
265+
c.drawControlFrame(id, bounds, colorBase, opt)
266266
// draw thumb
267267
w := c.style().thumbSize
268268
x := int((v - low) * float64(bounds.Dx()-w) / (high - low))
269269
thumb := image.Rect(bounds.Min.X+x, bounds.Min.Y, bounds.Min.X+x+w, bounds.Max.Y)
270-
c.drawControlFrame(id, thumb, ColorButton, opt)
270+
c.drawControlFrame(id, thumb, colorButton, opt)
271271
// draw text
272272
text := formatNumber(v, digits)
273-
c.drawControlText(text, bounds, ColorText, opt)
273+
c.drawControlText(text, bounds, colorText, opt)
274274

275275
return res, nil
276276
})
@@ -299,10 +299,10 @@ func (c *Context) header(label string, isTreeNode bool, opt option, callerPC uin
299299
}
300300
if isTreeNode {
301301
if c.hover == id {
302-
c.drawFrame(bounds, ColorButtonHover)
302+
c.drawFrame(bounds, colorButtonHover)
303303
}
304304
} else {
305-
c.drawControlFrame(id, bounds, ColorButton, 0)
305+
c.drawControlFrame(id, bounds, colorButton, 0)
306306
}
307307
var icon icon
308308
if expanded {
@@ -313,10 +313,10 @@ func (c *Context) header(label string, isTreeNode bool, opt option, callerPC uin
313313
c.drawIcon(
314314
icon,
315315
image.Rect(bounds.Min.X, bounds.Min.Y, bounds.Min.X+bounds.Dy(), bounds.Max.Y),
316-
c.style().colors[ColorText],
316+
c.style().colors[colorText],
317317
)
318318
bounds.Min.X += bounds.Dy() - c.style().padding
319-
c.drawControlText(label, bounds, ColorText, 0)
319+
c.drawControlText(label, bounds, colorText, 0)
320320

321321
return expanded, nil
322322
})
@@ -373,11 +373,11 @@ func (c *Context) scrollbarVertical(cnt *container, b image.Rectangle, cs image.
373373
cnt.layout.ScrollOffset.Y = clamp(cnt.layout.ScrollOffset.Y, 0, maxscroll)
374374

375375
// draw base and thumb
376-
c.drawFrame(base, ColorScrollBase)
376+
c.drawFrame(base, colorScrollBase)
377377
thumb := base
378378
thumb.Max.Y = thumb.Min.Y + max(c.style().thumbSize, base.Dy()*b.Dy()/cs.Y)
379379
thumb = thumb.Add(image.Pt(0, cnt.layout.ScrollOffset.Y*(base.Dy()-thumb.Dy())/maxscroll))
380-
c.drawFrame(thumb, ColorScrollThumb)
380+
c.drawFrame(thumb, colorScrollThumb)
381381

382382
// set this as the scroll_target (will get scrolled on mousewheel)
383383
// if the mouse is over it
@@ -408,11 +408,11 @@ func (c *Context) scrollbarHorizontal(cnt *container, b image.Rectangle, cs imag
408408
cnt.layout.ScrollOffset.X = clamp(cnt.layout.ScrollOffset.X, 0, maxscroll)
409409

410410
// draw base and thumb
411-
c.drawFrame(base, ColorScrollBase)
411+
c.drawFrame(base, colorScrollBase)
412412
thumb := base
413413
thumb.Max.X = thumb.Min.X + max(c.style().thumbSize, base.Dx()*b.Dx()/cs.X)
414414
thumb = thumb.Add(image.Pt(cnt.layout.ScrollOffset.X*(base.Dx()-thumb.Dx())/maxscroll, 0))
415-
c.drawFrame(thumb, ColorScrollThumb)
415+
c.drawFrame(thumb, colorScrollThumb)
416416

417417
// set this as the scroll_target (will get scrolled on mousewheel)
418418
// if the mouse is over it

draw.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ func (c *Context) DrawControl(f func(screen *ebiten.Image)) {
206206

207207
func (c *Context) drawFrame(rect image.Rectangle, colorid int) {
208208
c.drawRect(rect, c.style().colors[colorid])
209-
if colorid == ColorScrollBase || colorid == ColorScrollThumb || colorid == ColorTitleBG {
209+
if colorid == colorScrollBase || colorid == colorScrollThumb || colorid == colorTitleBG {
210210
return
211211
}
212212
// draw border
213-
if c.style().colors[ColorBorder].A != 0 {
214-
c.drawBox(rect.Inset(-1), c.style().colors[ColorBorder])
213+
if c.style().colors[colorBorder].A != 0 {
214+
c.drawBox(rect.Inset(-1), c.style().colors[colorBorder])
215215
}
216216
}
217217

panel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (c *Context) panel(name string, opt option, f func(layout ContainerLayout))
2222
}
2323
cnt.layout.Bounds = l
2424
if (^opt & optionNoFrame) != 0 {
25-
c.drawFrame(cnt.layout.Bounds, ColorPanelBG)
25+
c.drawFrame(cnt.layout.Bounds, colorPanelBG)
2626
}
2727

2828
c.pushContainer(cnt)

style.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ type style struct {
1515
titleHeight int
1616
scrollbarSize int
1717
thumbSize int
18-
colors [ColorMax + 1]color.RGBA
18+
colors [colorCount]color.RGBA
1919
}
2020

2121
const (
22-
ColorText = iota
23-
ColorBorder
24-
ColorWindowBG
25-
ColorTitleBG
26-
ColorTitleText
27-
ColorPanelBG
28-
ColorButton
29-
ColorButtonHover
30-
ColorButtonFocus
31-
ColorBase
32-
ColorBaseHover
33-
ColorBaseFocus
34-
ColorScrollBase
35-
ColorScrollThumb
36-
ColorMax = ColorScrollThumb
22+
colorText = iota
23+
colorBorder
24+
colorWindowBG
25+
colorTitleBG
26+
colorTitleText
27+
colorPanelBG
28+
colorButton
29+
colorButtonHover
30+
colorButtonFocus
31+
colorBase
32+
colorBaseHover
33+
colorBaseFocus
34+
colorScrollBase
35+
colorScrollThumb
36+
colorCount
3737
)
3838

3939
var defaultStyle style = style{
@@ -45,19 +45,19 @@ var defaultStyle style = style{
4545
scrollbarSize: 12,
4646
thumbSize: 8,
4747
colors: [...]color.RGBA{
48-
ColorText: {230, 230, 230, 255},
49-
ColorBorder: {25, 25, 25, 255},
50-
ColorWindowBG: {45, 45, 45, 230},
51-
ColorTitleBG: {23, 23, 23, 230},
52-
ColorTitleText: {240, 240, 240, 255},
53-
ColorPanelBG: {0, 0, 0, 0},
54-
ColorButton: {75, 75, 75, 255},
55-
ColorButtonHover: {95, 95, 95, 255},
56-
ColorButtonFocus: {115, 115, 115, 255},
57-
ColorBase: {30, 30, 30, 255},
58-
ColorBaseHover: {35, 35, 35, 255},
59-
ColorBaseFocus: {40, 40, 40, 255},
60-
ColorScrollBase: {43, 43, 43, 255},
61-
ColorScrollThumb: {30, 30, 30, 255},
48+
colorText: {230, 230, 230, 255},
49+
colorBorder: {25, 25, 25, 255},
50+
colorWindowBG: {45, 45, 45, 230},
51+
colorTitleBG: {23, 23, 23, 230},
52+
colorTitleText: {240, 240, 240, 255},
53+
colorPanelBG: {0, 0, 0, 0},
54+
colorButton: {75, 75, 75, 255},
55+
colorButtonHover: {95, 95, 95, 255},
56+
colorButtonFocus: {115, 115, 115, 255},
57+
colorBase: {30, 30, 30, 255},
58+
colorBaseHover: {35, 35, 35, 255},
59+
colorBaseFocus: {40, 40, 40, 255},
60+
colorScrollBase: {43, 43, 43, 255},
61+
colorScrollThumb: {30, 30, 30, 255},
6262
},
6363
}

textfield.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ func (c *Context) textFieldRaw(buf *string, id controlID, opt option) (bool, err
7272
}
7373

7474
// draw
75-
c.drawControlFrame(id, bounds, ColorBase, opt)
75+
c.drawControlFrame(id, bounds, colorBase, opt)
7676
if c.focus == id {
77-
color := c.style().colors[ColorText]
77+
color := c.style().colors[colorText]
7878
textw := textWidth(*buf)
7979
texth := lineHeight()
8080
ofx := bounds.Dx() - c.style().padding - textw - 1
@@ -85,7 +85,7 @@ func (c *Context) textFieldRaw(buf *string, id controlID, opt option) (bool, err
8585
c.drawRect(image.Rect(textx+textw, texty, textx+textw+1, texty+texth), color)
8686
c.popClipRect()
8787
} else {
88-
c.drawControlText(*buf, bounds, ColorText, opt)
88+
c.drawControlText(*buf, bounds, colorText, opt)
8989
}
9090
return res, nil
9191
})
@@ -153,10 +153,10 @@ func (c *Context) numberField(value *float64, step float64, digits int, opt opti
153153
}
154154

155155
// draw base
156-
c.drawControlFrame(id, bounds, ColorBase, opt)
156+
c.drawControlFrame(id, bounds, colorBase, opt)
157157
// draw text
158158
text := formatNumber(*value, digits)
159-
c.drawControlText(text, bounds, ColorText, opt)
159+
c.drawControlText(text, bounds, colorText, opt)
160160

161161
return res, nil
162162
})

0 commit comments

Comments
 (0)