zntg/ui/statusbar.go

36 lines
819 B
Go

package ui
import (
"opslag.de/schobers/geom"
"opslag.de/schobers/zntg/allg5"
)
var _ Control = &StatusBar{}
const statusBarHeight = 24
type StatusBar struct {
ControlBase
Text string
RightText string
}
func (b *StatusBar) DesiredSize(Context) geom.PointF32 {
return geom.PtF32(geom.NaN32(), statusBarHeight)
}
func (b *StatusBar) Render(ctx Context) {
var fonts = ctx.Fonts()
var min = b.Bounds.Min
var max = b.Bounds.Max
allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, ctx.Palette().Primary())
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)
b.ControlBase.Render(ctx)
}