package ui import ( "opslag.de/schobers/geom" "opslag.de/schobers/zntg/allg5" ) type Label struct { ControlBase Text string HorizontalAlignment allg5.HorizontalAlignment } func (l *Label) DesiredSize(ctx Context) geom.PointF32 { var fonts = ctx.Fonts() var fnt = fonts.Get("default") var _, _, w, h = fnt.TextDimensions(l.Text) return geom.PtF32(w, h) } func (l *Label) Render(ctx Context) { var fonts = ctx.Fonts() var min = l.Bounds.Min var fnt = fonts.Get("default") fnt.Draw(min.X, min.Y+fnt.Height()-fnt.Ascent(), ctx.Palette().Darkest(), l.HorizontalAlignment, l.Text) l.ControlBase.Render(ctx) }