krampus19/alui/column.go
Sander Schobers 11ab3fca0f Added settings in-game.
Added video settings.
Added and improved reusable controls.
Separated drawing of sprites.
Fixed bug that text was right aligned instead of left aligned.
2019-12-28 16:03:57 +01:00

35 lines
782 B
Go

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)
}