package tins2020 import ( "github.com/veandco/go-sdl2/sdl" ) type Container struct { ControlBase Children []Control } func NewContainer() *Container { return &Container{} } func (c *Container) AddChild(child Control) { c.Children = append(c.Children, child) } func (c *Container) Arrange(ctx *Context, bounds Rectangle) { c.ControlBase.Arrange(ctx, bounds) for _, child := range c.Children { child.Arrange(ctx, bounds) } } func (c *Container) Handle(ctx *Context, event sdl.Event) bool { if c.ControlBase.Handle(ctx, event) { return true } for _, child := range c.Children { if child.Handle(ctx, event) { return true } } return false } func (c *Container) Init(ctx *Context) error { c.ControlBase.Init(ctx) for _, child := range c.Children { err := child.Init(ctx) if err != nil { return err } } return nil } func (c *Container) Render(ctx *Context) { c.ControlBase.Render(ctx) for _, child := range c.Children { child.Render(ctx) } }