package ui import ( "opslag.de/schobers/geom" ) type Label struct { ControlBase Text string } func BuildLabel(text string, fn func(*Label)) *Label { var l = &Label{Text: text} if fn != nil { fn(l) } return l } func (l *Label) DesiredSize(ctx Context) geom.PointF32 { var fontName = l.FontName(ctx) var font = ctx.Renderer().Font(fontName) var width = font.WidthOf(l.Text) var height = font.Height() var pad = ctx.Style().Dimensions.TextPadding return geom.PtF32(width+pad*2, height+pad*2) } func (l *Label) Render(ctx Context) { l.RenderBackground(ctx) var c = l.FontColor(ctx) var f = l.FontName(ctx) var pad = ctx.Style().Dimensions.TextPadding ctx.Renderer().Text(l.bounds.Min.Add(geom.PtF32(pad, pad)), f, c, l.Text) }