diff options
Diffstat (limited to 'go/ui/button.go')
| -rw-r--r-- | go/ui/button.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/go/ui/button.go b/go/ui/button.go index 9afa8c05..6e8fd8b7 100644 --- a/go/ui/button.go +++ b/go/ui/button.go @@ -83,3 +83,18 @@ func (b *SimpleButton) UpdateLabel(label string) { b.ForceRedraw() } } + +type ImageButton struct { + WidgetBase + img *ebiten.Image +} + +func NewImageButton(x, y int, img *ebiten.Image, onClick func(b *ImageButton)) *ImageButton { + bounds := img.Bounds() + sb := &ImageButton{NewWidgetBase(x, y, bounds.Dx(), bounds.Dy()), img} + sb.EventHandlersMap["click"] = func(int, int) { onClick(sb) } + sb.renderImpl = func() *ebiten.Image { + return sb.img + } + return sb +} |
