okay new ux idea
This commit is contained in:
31
common/elements/v1/stack.go
Normal file
31
common/elements/v1/stack.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package elements
|
||||
|
||||
import "github.com/hajimehoshi/ebiten/v2"
|
||||
|
||||
type StackOption func(*stack)
|
||||
|
||||
func Stack(ops ...StackOption) ElementFunc {
|
||||
return func(parentDimensions Dimensions) Element {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
type stack struct {
|
||||
block
|
||||
horizontal bool
|
||||
children []Element
|
||||
}
|
||||
|
||||
func (s *stack) Draw(image *ebiten.Image, anchorX, anchorY float64) (w, h float64) {
|
||||
var offsetX, offsetY float64
|
||||
originalX, originalY := anchorX, anchorY
|
||||
for i := range s.children {
|
||||
offsetX, offsetY = s.children[i].Draw(image, anchorX, anchorY)
|
||||
if s.horizontal {
|
||||
anchorX += offsetX
|
||||
} else {
|
||||
anchorY += offsetY
|
||||
}
|
||||
}
|
||||
return anchorX - originalX, anchorY - originalY
|
||||
}
|
||||
Reference in New Issue
Block a user