aboutsummaryrefslogtreecommitdiff
path: root/go/ui/button.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/ui/button.go')
-rw-r--r--go/ui/button.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/go/ui/button.go b/go/ui/button.go
index eac3c2e4..50f78a3d 100644
--- a/go/ui/button.go
+++ b/go/ui/button.go
@@ -19,8 +19,8 @@ type SimpleButton struct {
WidgetBase
label string
OnClick func(b *SimpleButton)
- BG color.Color
- FG color.Color
+ Bg color.Color
+ Fg color.Color
}
func NewSimpleButton(x, y, w, h int, label string, onClick func(b *SimpleButton)) *SimpleButton {
@@ -32,15 +32,20 @@ func NewSimpleButton(x, y, w, h int, label string, onClick func(b *SimpleButton)
func (b *SimpleButton) render() *ebiten.Image {
img := ebiten.NewImage(b.Width, b.Height)
- ebitenutil.DrawRect(img, float64(0), float64(0), float64(b.Width), float64(b.Height), b.BG)
+ ebitenutil.DrawRect(img, float64(0), float64(0), float64(b.Width), float64(b.Height), b.Bg)
bounds := text.BoundString(font.Font24, b.label)
x := b.Width/2 - centerTextXOffset(bounds)
y := b.Height/2 - centerTextYOffset(bounds)
- text.Draw(img, b.label, font.Font24, x, y, b.FG)
+ text.Draw(img, b.label, font.Font24, x, y, b.Fg)
return img
}
func (b *SimpleButton) Click(x, y int) {
b.OnClick(b)
}
+
+func (b *SimpleButton) UpdateLabel(label string) {
+ b.label = label
+ b.ForceRedraw()
+}