feat(tracker): adding, setting, unsetting and deleting units

This commit is contained in:
vsariola
2021-02-04 21:50:41 +02:00
parent 29b289d2fb
commit 6307dd51de
8 changed files with 316 additions and 86 deletions

View File

@ -17,12 +17,13 @@ type LabelStyle struct {
Text string
Color color.NRGBA
ShadeColor color.NRGBA
Alignment layout.Direction
Font text.Font
FontSize unit.Value
}
func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
return layout.Stack{Alignment: l.Alignment}.Layout(gtx,
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
defer op.Save(gtx.Ops).Load()
paint.ColorOp{Color: l.ShadeColor}.Add(gtx.Ops)
@ -46,6 +47,6 @@ func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
)
}
func Label(text string, color color.NRGBA) layout.Widget {
return LabelStyle{Text: text, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize}.Layout
func Label(str string, color color.NRGBA) layout.Widget {
return LabelStyle{Text: str, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize, Alignment: layout.W}.Layout
}