33 lines
553 B
Go
33 lines
553 B
Go
package elements
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"golang.org/x/image/font"
|
|
)
|
|
import "git.vezzani.net/ben/games/common/ux/v1"
|
|
|
|
type Button struct {
|
|
Label string
|
|
LabelPosition
|
|
Font *font.Face
|
|
OnClick func(click *ClickEvent) error
|
|
}
|
|
|
|
func (b *Button) getFont() font.Face {
|
|
if b.Font == nil {
|
|
return ux.FontFace
|
|
}
|
|
|
|
return *b.Font
|
|
}
|
|
|
|
func (b *Button) Draw(ctx context.Context, image *ebiten.Image) error {
|
|
|
|
}
|
|
|
|
func (b *Button) HandleClick(ctx context.Context, clickEvent *ClickEvent) error {
|
|
return b.OnClick(click)
|
|
}
|