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-08-20 15:46:38 +0200
commit8802f30ff720fcb64d9207c4cb673dc6805390c2 (patch)
tree9be529221105fc8681e3afb0e673e229ef9504d4 /go/ui/button.go
parente8f44219976edf8cf57cbd9e964f66fe9d145a9c (diff)
downloadmuhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.tar.gz
muhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.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
}