ux stuff
This commit is contained in:
65
common/elements/v1/button.go
Normal file
65
common/elements/v1/button.go
Normal 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 {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user