39 lines
691 B
Go
39 lines
691 B
Go
package base
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
"git.vezzani.net/ben/games/common/elements/v1"
|
|
"git.vezzani.net/ben/games/common/elements/v1/mouse"
|
|
)
|
|
|
|
type Element struct {
|
|
mouse.NopHandler
|
|
|
|
anchor elements.Point
|
|
children []elements.Element
|
|
|
|
backgroundColor color.Color
|
|
name string // For debugging
|
|
}
|
|
|
|
func (e *Element) Anchor() elements.Point {
|
|
return e.anchor
|
|
}
|
|
|
|
func (e *Element) SetAnchor(a elements.Point) {
|
|
d := e.Anchor().Delta(a)
|
|
for _, ch := range e.Children() {
|
|
ch.SetAnchor(ch.Anchor().Add(d))
|
|
}
|
|
e.anchor = a
|
|
}
|
|
|
|
func (e *Element) Children() []elements.Element {
|
|
return e.children
|
|
}
|
|
|
|
func (e *Element) BackgroundColor() color.Color {
|
|
return e.backgroundColor
|
|
}
|