This commit is contained in:
2025-08-18 14:57:01 -04:00
parent 627ca88732
commit ee69afdb02
9 changed files with 155 additions and 2 deletions

View File

@@ -0,0 +1,65 @@
package elements
import (
"context"
"image/color"
"github.com/ebitengine/gomobile/event/mouse"
"github.com/hajimehoshi/ebiten/v2"
"golang.org/x/image/font"
)
import "git.vezzani.net/ben/games/common/ux/v1"
type XAlign int
type YAlign int
const (
AlignCente XAlign = iota
AlignLeft
AlignRight
)
const (
AlignCenter YAlign = iota
AlignTop
AlignBottom
)
type Button struct {
Label string
OnClick func() error
OnRightClick func() error
Style struct {
XAlign XAlign
YAlign YAlign
Offset int
Font *font.Face
BackgroundColor color.Color
}
down bool
}
func (b *Button) HandleMouseMove(ctx context.Context, s MouseState) error {
}
func (b *Button) HandleMouseDown(_ context.Context, _ MouseState) error {
return nil
}
func (b *Button) HandleMouseUp(ctx context.Context, s MouseState) error {
if
}
func (b *Button) getFont() font.Face {
if b.Style.Font == nil {
return ux.FontFace
}
return *b.Style.Font
}
func (b *Button) Draw(ctx context.Context, image *ebiten.Image) error {
}