package alui

import "opslag.de/schobers/geom"

type Column struct {
	Proxy

	panel *StackPanel
}

func NewColumn() *Column {
	c := &Column{}
	c.Init()
	return c
}

func (c *Column) AddChild(child ...Control) {
	c.panel.Children = append(c.panel.Children, child...)
}

func (c *Column) Init() {
	c.panel = &StackPanel{Orientation: OrientationVertical}
	c.Proxy.Target = c.panel
}

func (c *Column) Layout(ctx *Context, bounds geom.RectangleF32) {}

func (c *Column) Render(ctx *Context, bounds geom.RectangleF32) {
	columnHeight := c.Proxy.DesiredSize(ctx).Y
	width, center := bounds.Dx(), bounds.Center()
	columnBounds := geom.RectF32(.25*width, center.Y-.5*columnHeight, .75*width, center.Y+.5*columnHeight)
	c.Proxy.Layout(ctx, columnBounds)
	c.Proxy.Render(ctx, columnBounds)
}
