Fixed right/center alignment of labels.
This commit is contained in:
parent
432281f08d
commit
757758d8e9
10
ui/label.go
10
ui/label.go
@ -36,5 +36,13 @@ func (l *Label) Render(ctx Context) {
|
||||
var c = l.FontColor(ctx)
|
||||
var f = l.FontName(ctx)
|
||||
var pad = ctx.Style().Dimensions.TextPadding
|
||||
ctx.Renderer().TextAlign(l.bounds.Min.Add(geom.PtF32(pad, pad)), f, c, l.Text, l.TextAlignment)
|
||||
var bounds = l.bounds.Inset(pad)
|
||||
switch l.TextAlignment {
|
||||
case AlignLeft:
|
||||
ctx.Renderer().TextAlign(bounds.Min, f, c, l.Text, l.TextAlignment)
|
||||
case AlignRight:
|
||||
ctx.Renderer().TextAlign(geom.PtF32(bounds.Max.X, bounds.Min.Y), f, c, l.Text, l.TextAlignment)
|
||||
case AlignCenter:
|
||||
ctx.Renderer().TextAlign(geom.PtF32(.5*(bounds.Min.X+bounds.Max.X), bounds.Min.Y), f, c, l.Text, l.TextAlignment)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user