Skip to content

Commit bc560f4

Browse files
committed
gui: custom theme for GUI controls
1 parent 6293d14 commit bc560f4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

gui.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ func (g *Gui) draw(gtx layout.Context, bgCol color.NRGBA) {
316316
g.ctx = gtx
317317
op.InvalidateOp{}.Add(gtx.Ops)
318318

319+
defaultColor := color.NRGBA{R: 0x2d, G: 0x23, B: 0x2e, A: 0xff}
319320
th := material.NewTheme(gofont.Collection())
321+
th.TextSize = unit.Sp(12)
322+
th.Palette.ContrastBg = defaultColor
323+
th.FingerSize = 10
324+
320325
c := g.setColor(g.cfg.color.background)
321326
paint.Fill(g.ctx.Ops, c)
322327

@@ -387,17 +392,17 @@ func (g *Gui) draw(gtx layout.Context, bgCol color.NRGBA) {
387392
if g.cp.Debug {
388393
layout.Stack{}.Layout(g.ctx,
389394
layout.Stacked(func(gtx C) D {
390-
hudHeight := 55
395+
hudHeight := 40
391396
r := image.Rectangle{
392397
Max: image.Point{
393398
X: gtx.Constraints.Max.X,
394399
Y: hudHeight,
395400
},
396401
}
397-
op.Offset(image.Pt(0, gtx.Constraints.Max.Y-hudHeight)).Add(gtx.Ops)
402+
defer op.Offset(image.Pt(0, gtx.Constraints.Max.Y-hudHeight)).Push(gtx.Ops).Pop()
398403
return layout.Stack{}.Layout(gtx,
399404
layout.Expanded(func(gtx C) D {
400-
paint.FillShape(gtx.Ops, color.NRGBA{R: 255, G: 255, B: 255, A: 127}, clip.Rect(r).Op())
405+
paint.FillShape(gtx.Ops, color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xcc}, clip.Rect(r).Op())
401406
return layout.Dimensions{Size: r.Max}
402407
}),
403408
layout.Stacked(func(gtx C) D {
@@ -407,14 +412,16 @@ func (g *Gui) draw(gtx layout.Context, bgCol color.NRGBA) {
407412
Y: gtx.Dp(unit.Dp(0.5)),
408413
},
409414
}
410-
paint.FillShape(gtx.Ops, utils.HSL(0.45, 0.16, 0.35), clip.Rect(border).Op())
415+
paint.FillShape(gtx.Ops, color.NRGBA{R: 0x3B, G: 0x41, B: 0x3C, A: 0xaa}, clip.Rect(border).Op())
411416
return layout.Dimensions{Size: r.Max}
412417
}),
413418
layout.Stacked(func(gtx C) D {
414419
return g.view.huds.Layout(gtx, len(g.huds),
415420
func(gtx layout.Context, index int) D {
416421
if hud, ok := g.huds[index]; ok {
417-
return material.CheckBox(th, &hud.visible, fmt.Sprintf("%v", hud.title)).Layout(gtx)
422+
checkbox := material.CheckBox(th, &hud.visible, fmt.Sprintf("%v", hud.title))
423+
checkbox.Size = 20
424+
return checkbox.Layout(gtx)
418425
}
419426
return D{}
420427
})

0 commit comments

Comments
 (0)