wip I guess

This commit is contained in:
2025-09-05 21:21:18 -04:00
parent 4e6d720a91
commit 9a4993570e
10 changed files with 143 additions and 112 deletions

View File

@@ -3,52 +3,54 @@ package main
import (
"git.vezzani.net/ben/games/common/elements/v1"
"git.vezzani.net/ben/games/common/elements/v1/blocks"
"git.vezzani.net/ben/games/common/elements/v1/buttons"
"git.vezzani.net/ben/games/common/elements/v1/mouse"
"git.vezzani.net/ben/games/common/elements/v1/stacks"
"git.vezzani.net/ben/games/common/sprites/v1"
"github.com/hajimehoshi/ebiten/v2"
"golang.org/x/image/colornames"
)
var root = stacks.New(
stacks.Horizontal(),
//stacks.Core(blocks.BackgroundColor(color.White)),
stacks.Core(elements.Name("parent")),
stacks.Core(elements.Children(
stacks.New(
stacks.Core(elements.Name("left")),
stacks.Core(elements.Children(
buttons.New(
buttons.BlockOpt(blocks.Size(100, 100)),
buttons.Label("hello"),
buttons.BlockOpt(blocks.BackgroundColor(colornames.Green)),
buttons.OnClick(func(ms mouse.State) {
println("green")
}),
),
blocks.New(
blocks.Size(100, 100),
blocks.BackgroundColor(colornames.Yellow),
),
)),
),
stacks.New(
stacks.Core(elements.Name("right")),
stacks.Core(elements.Children(
blocks.New(
blocks.Size(100, 100),
blocks.BackgroundColor(colornames.Blue),
),
blocks.New(
blocks.Size(100, 100),
blocks.BackgroundColor(colornames.Red),
),
)),
),
)),
)
//var root = stacks.New(
// stacks.Horizontal(),
// //stacks.Element(blocks.BackgroundColor(color.White)),
// stacks.Element(elements.Name("parent")),
// stacks.Element(elements.Children(
// stacks.New(
// stacks.Element(elements.Name("left")),
// stacks.Element(elements.Children(
// buttons.New(
// buttons.BlockOpt(blocks.Size(100, 100)),
// buttons.Label("hello"),
// buttons.BlockOpt(blocks.BackgroundColor(colornames.Green)),
// buttons.OnClick(func(ms mouse.State) {
// println("green")
// }),
// ),
// blocks.New(
// blocks.Size(100, 100),
// blocks.BackgroundColor(colornames.Yellow),
// ),
// )),
// ),
// stacks.New(
// stacks.Element(elements.Name("right")),
// stacks.Element(elements.Children(
// blocks.New(
// blocks.Size(100, 100),
// blocks.BackgroundColor(colornames.Blue),
// ),
// blocks.New(
// blocks.Size(100, 100),
// blocks.BackgroundColor(colornames.Red),
// ),
// )),
// ),
// )),
//)
var root = blocks.New().
Size(100, 100).
BackgroundColor(colornames.Red)
func newEditor() *editor {
return &editor{}
@@ -57,6 +59,7 @@ func newEditor() *editor {
type editor struct {
bounds elements.Bounds
handleMouse func() bool
root elements.Element
}
func (e *editor) Update() error {
@@ -66,7 +69,7 @@ func (e *editor) Update() error {
}
func (e *editor) Draw(screen *ebiten.Image) {
root.Draw(screen)
e.root.Draw(screen)
}
func (e *editor) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
@@ -76,7 +79,8 @@ func (e *editor) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHei
Width: outsideWidth,
Height: outsideHeight,
}
e.handleMouse = mouse.Handler(root)
e.root = root()
e.handleMouse = mouse.Handler(e.root)
}
return outsideWidth, outsideHeight