ux stuff
This commit is contained in:
34
common/elements/v1/element.go
Normal file
34
common/elements/v1/element.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package elements
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.vezzani.net/ben/games/common/control/v1"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type ClickEvent struct {
|
||||
X, Y int
|
||||
Button control.MouseButton
|
||||
}
|
||||
|
||||
const (
|
||||
ParentKey = "parent_element"
|
||||
)
|
||||
|
||||
type Clickable interface {
|
||||
HandleClick(ctx context.Context, click *ClickEvent) error
|
||||
}
|
||||
|
||||
type Element interface {
|
||||
Draw(ctx context.Context, image *ebiten.Image) error
|
||||
Size() (w, h int32)
|
||||
}
|
||||
|
||||
func GetParent(ctx context.Context) Element {
|
||||
if e, ok := ctx.Value(ParentKey).(Element); ok {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user