zntg/ui/statusbar.go

38 lines
836 B
Go
Raw Normal View History

2018-08-03 06:46:10 +00:00
package ui
import (
"math"
"opslag.de/schobers/zntg/allg5"
2018-08-03 06:46:10 +00:00
"opslag.de/schobers/geom"
)
var _ Control = &StatusBar{}
const statusBarHeight = 24
type StatusBar struct {
ControlBase
Text string
RightText string
}
func (b *StatusBar) DesiredSize(Context) geom.PointF {
return geom.PtF(math.NaN(), statusBarHeight)
}
func (b *StatusBar) Render(ctx Context) {
var fonts = ctx.Fonts()
var min = b.Bounds.Min.To32()
var max = b.Bounds.Max.To32()
allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, ctx.Palette().Primary())
2018-08-03 06:46:10 +00:00
var fnt = fonts.Get("default")
var y = min.Y + float32(.5*b.Bounds.Dy()) - .67*fnt.Ascent()
fnt.Draw(min.X+leftMargin, y, ctx.Palette().Lightest(), allg5.AlignLeft, b.Text)
fnt.Draw(max.X-leftMargin, y, ctx.Palette().Lightest(), allg5.AlignRight, b.RightText)
2018-08-03 06:46:10 +00:00
b.ControlBase.Render(ctx)
}