42 lines
826 B
Go
42 lines
826 B
Go
|
package ui
|
||
|
|
||
|
import (
|
||
|
"opslag.de/schobers/geom"
|
||
|
)
|
||
|
|
||
|
type ContainerBase struct {
|
||
|
ControlBase
|
||
|
Children []Control
|
||
|
}
|
||
|
|
||
|
func BuildContainerBase(controls ...Control) ContainerBase {
|
||
|
return ContainerBase{
|
||
|
Children: controls,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (c *ContainerBase) AddChild(child ...Control) {
|
||
|
c.Children = append(c.Children, child...)
|
||
|
}
|
||
|
|
||
|
func (c *ContainerBase) Arrange(ctx Context, bounds geom.RectangleF32, offset geom.PointF32) {
|
||
|
for _, child := range c.Children {
|
||
|
child.Arrange(ctx, bounds, offset)
|
||
|
}
|
||
|
c.ControlBase.Arrange(ctx, bounds, offset)
|
||
|
}
|
||
|
|
||
|
func (c *ContainerBase) Handle(ctx Context, e Event) {
|
||
|
for _, child := range c.Children {
|
||
|
child.Handle(ctx, e)
|
||
|
}
|
||
|
c.ControlBase.Handle(ctx, e)
|
||
|
}
|
||
|
|
||
|
func (c *ContainerBase) Render(ctx Context) {
|
||
|
c.RenderBackground(ctx)
|
||
|
for _, child := range c.Children {
|
||
|
child.Render(ctx)
|
||
|
}
|
||
|
}
|