2018-08-03 06:46:10 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"opslag.de/schobers/geom"
|
2018-09-23 07:42:23 +00:00
|
|
|
"opslag.de/schobers/zntg/allg5"
|
2018-08-03 06:46:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ Control = &StatusBar{}
|
|
|
|
|
|
|
|
const statusBarHeight = 24
|
|
|
|
|
|
|
|
type StatusBar struct {
|
|
|
|
ControlBase
|
|
|
|
Text string
|
|
|
|
RightText string
|
|
|
|
}
|
|
|
|
|
2018-09-23 07:42:23 +00:00
|
|
|
func (b *StatusBar) DesiredSize(Context) geom.PointF32 {
|
|
|
|
return geom.PtF32(geom.NaN32(), statusBarHeight)
|
2018-08-03 06:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (b *StatusBar) Render(ctx Context) {
|
|
|
|
var fonts = ctx.Fonts()
|
|
|
|
|
2018-09-23 07:42:23 +00:00
|
|
|
var min = b.Bounds.Min
|
|
|
|
var max = b.Bounds.Max
|
2018-09-22 14:23:26 +00:00
|
|
|
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")
|
2018-08-07 05:03:52 +00:00
|
|
|
var y = min.Y + float32(.5*b.Bounds.Dy()) - .67*fnt.Ascent()
|
2018-09-22 14:23:26 +00:00
|
|
|
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)
|
|
|
|
}
|