From 50b9a042435b324be281b78ceb87dd63fd24acba Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 17 Feb 2023 14:36:06 +0100 Subject: use prompt for target selection of all actions --- go/ui/button.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'go/ui/button.go') 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() +} -- cgit v1.2.3