37 lines
810 B
Go
37 lines
810 B
Go
|
package ui
|
||
|
|
||
|
import (
|
||
|
"math"
|
||
|
|
||
|
"opslag.de/schobers/galleg/allegro5"
|
||
|
"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()
|
||
|
allegro5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, ctx.Palette().Primary())
|
||
|
|
||
|
var fnt = fonts.Get("default")
|
||
|
fnt.Draw(min.X+leftMargin, min.Y+topMargin, ctx.Palette().White(), allegro5.AlignLeft, b.Text)
|
||
|
fnt.Draw(max.X-leftMargin, min.Y+topMargin, ctx.Palette().White(), allegro5.AlignRight, b.RightText)
|
||
|
|
||
|
b.ControlBase.Render(ctx)
|
||
|
}
|