aboutsummaryrefslogtreecommitdiff
path: root/go/ui/button.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-03 14:05:14 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:46 +0100
commit642b2e14532f906fe133bf2d05bb132ebb53d9ef (patch)
treeda45eeb332bc786c998f8b64a69585ff36c031e5 /go/ui/button.go
parent6034149d014e999b17247af75b98913e4e4c68af (diff)
downloadmuhqs-game-642b2e14532f906fe133bf2d05bb132ebb53d9ef.tar.gz
muhqs-game-642b2e14532f906fe133bf2d05bb132ebb53d9ef.zip
add text input and properly center text
Diffstat (limited to 'go/ui/button.go')
-rw-r--r--go/ui/button.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/go/ui/button.go b/go/ui/button.go
index 6454ccac..0fd26936 100644
--- a/go/ui/button.go
+++ b/go/ui/button.go
@@ -35,15 +35,8 @@ func (b *SimpleButton) render() *ebiten.Image {
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 - bounds.Dx()) / 2
- if x < 0 {
- x = 0
- }
-
- y := b.Height - bounds.Dy()/2
- if y < 0 {
- y = 0
- }
+ x := b.Width/2 - centerTextXOffset(bounds)
+ y := b.Height/2 - centerTextYOffset(bounds)
text.Draw(img, b.label, font.Font24, x, y, b.FG)
return img
}