MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

core/meter.go:70–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68func (m *Meter) WidgetValue() any { return &m.Value }
69
70func (m *Meter) Init() {
71 m.WidgetBase.Init()
72 m.Value = 0.5
73 m.Max = 1
74 m.Styler(func(s *styles.Style) {
75 m.ValueColor = colors.Scheme.Primary.Base
76 s.Background = colors.Scheme.SurfaceVariant
77 s.Border.Radius = styles.BorderRadiusFull
78 })
79 m.FinalStyler(func(s *styles.Style) {
80 switch m.Type {
81 case MeterLinear:
82 if s.Direction == styles.Row {
83 s.Min.Set(units.Dp(320), units.Dp(8))
84 } else {
85 s.Min.Set(units.Dp(8), units.Dp(320))
86 }
87 case MeterCircle:
88 s.Min.Set(units.Dp(128))
89 m.Width.Dp(8)
90 s.Font.Size.Dp(32)
91 s.Text.LineHeight.Dp(40)
92 s.Text.Align = styles.Center
93 s.Text.AlignV = styles.Center
94 case MeterSemicircle:
95 s.Min.Set(units.Dp(112), units.Dp(64))
96 m.Width.Dp(16)
97 s.Font.Size.Dp(22)
98 s.Text.LineHeight.Dp(28)
99 s.Text.Align = styles.Center
100 s.Text.AlignV = styles.Center
101 }
102 })
103}
104
105func (m *Meter) Style() {
106 m.WidgetBase.Style()

Callers

nothing calls this directly

Calls 6

DpFunction · 0.92
StylerMethod · 0.80
FinalStylerMethod · 0.80
InitMethod · 0.65
SetMethod · 0.65
DpMethod · 0.45

Tested by

no test coverage detected