krampus19/alui/center.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

24 lines
505 B
Go

package alui
import (
"opslag.de/schobers/geom"
)
type center struct {
Proxy
}
func Center(control Control) Control {
return &center{Proxy: Proxy{Target: control}}
}
func (c *center) Layout(ctx *Context, bounds geom.RectangleF32) {
size := c.DesiredSize(ctx)
center := bounds.Center()
size.X = geom.Min32(size.X, bounds.Dx())
size.Y = geom.Min32(size.Y, bounds.Dy())
size = size.Mul(.5)
c.Proxy.Layout(ctx, geom.RectF32(center.X-size.X, center.Y-size.Y, center.X+size.X, center.Y+size.Y))
}