wip I guess
This commit is contained in:
38
common/elements/v1/base/base.go
Normal file
38
common/elements/v1/base/base.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user