diff --git a/tracker/instruments.go b/tracker/instruments.go index 79fd292..79d9e4f 100644 --- a/tracker/instruments.go +++ b/tracker/instruments.go @@ -108,9 +108,14 @@ func (t *Tracker) layoutUnitList() layout.Widget { for t.UnitBtns[i].Clicked() { t.CurrentUnit = i } - btnStyle := material.Button(t.Theme, t.UnitBtns[i], u.Type) - btnStyle.Background = transparent - children[i] = layout.Rigid(btnStyle.Layout) + i2 := i + labelStyle := LabelStyle{Text: u.Type, ShadeColor: black, Color: white, Font: labelDefaultFont, FontSize: unit.Sp(12)} + children[i] = layout.Rigid(func(gtx C) D { + dims := labelStyle.Layout(gtx) + gtx.Constraints = layout.Exact(dims.Size) + t.UnitBtns[i2].Layout(gtx) + return dims + }) } return layout.Flex{Axis: layout.Vertical}.Layout(gtx, children...) } diff --git a/tracker/label.go b/tracker/label.go index 1edbf20..5cea65f 100644 --- a/tracker/label.go +++ b/tracker/label.go @@ -1,20 +1,24 @@ package tracker import ( + "image" + "image/color" + "gioui.org/f32" "gioui.org/layout" "gioui.org/op" "gioui.org/op/paint" "gioui.org/text" + "gioui.org/unit" "gioui.org/widget" - "image" - "image/color" ) type LabelStyle struct { Text string Color color.RGBA ShadeColor color.RGBA + Font text.Font + FontSize unit.Value } func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions { @@ -26,7 +30,7 @@ func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions { dims := widget.Label{ Alignment: text.Start, MaxLines: 1, - }.Layout(gtx, textShaper, labelFont, labelFontSize, l.Text) + }.Layout(gtx, textShaper, l.Font, l.FontSize, l.Text) return layout.Dimensions{ Size: dims.Size.Add(image.Pt(2, 2)), Baseline: dims.Baseline, @@ -37,11 +41,11 @@ func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions { return widget.Label{ Alignment: text.Start, MaxLines: 1, - }.Layout(gtx, textShaper, labelFont, labelFontSize, l.Text) + }.Layout(gtx, textShaper, l.Font, l.FontSize, l.Text) }), ) } func Label(text string, color color.RGBA) layout.Widget { - return LabelStyle{Text: text, Color: color, ShadeColor: black}.Layout + return LabelStyle{Text: text, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize}.Layout } diff --git a/tracker/theme.go b/tracker/theme.go index 457c4c5..ca0af23 100644 --- a/tracker/theme.go +++ b/tracker/theme.go @@ -45,8 +45,10 @@ var panelLightColor = light var backgroundColor = color.RGBA{R: 18, G: 18, B: 18, A: 255} -var labelFont = fontCollection[6].Font -var labelFontSize = unit.Px(18) +var labelDefaultColor = highEmphasisTextColor +var labelDefaultBgColor = transparent +var labelDefaultFont = fontCollection[6].Font +var labelDefaultFontSize = unit.Sp(18) var separatorLineColor = color.RGBA{R: 97, G: 97, B: 97, A: 97}