package alui import ( "opslag.de/schobers/allg5" "opslag.de/schobers/geom" ) var _ Control = &Button{} type Button struct { ControlBase Text string } func (b *Button) DesiredSize(ctx *Context) geom.PointF32 { font := ctx.Fonts.Get(b.Font) _, _, w, h := font.TextDimensions(b.Text) return geom.PtF32(w+8, h+8) } func (b *Button) Render(ctx *Context, bounds geom.RectangleF32) { font := ctx.Fonts.Get(b.Font) fore := ctx.Palette.Primary if b.Over { fore = ctx.Palette.Dark ctx.Cursor = allg5.MouseCursorLink } font.Draw(bounds.Min.X+4, bounds.Min.Y+4, fore, allg5.AlignLeft, b.Text) }