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

View File

@@ -0,0 +1,23 @@
package elements
import (
"context"
"github.com/hajimehoshi/ebiten/v2"
)
func NewBlock(inline bool) *Block {
}
type Block struct {
inline bool
}
func (b *Block) Draw(ctx context.Context, image *ebiten.Image) error {
}
func (b *Block) OnClick(ctx context.Context, click *ClickEvent) {
}

View File

@@ -0,0 +1,32 @@
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)
}

View 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
}

View File

@@ -0,0 +1 @@
package elements

View File

@@ -0,0 +1 @@
package elements