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

Method Style

core/style.go:46–79  ·  view source on GitHub ↗

Style updates the style properties of the widget based on [WidgetBase.Stylers]. To specify the style properties of a widget, use [WidgetBase.Styler].

()

Source from the content-addressed store, hash-verified

44// Style updates the style properties of the widget based on [WidgetBase.Stylers].
45// To specify the style properties of a widget, use [WidgetBase.Styler].
46func (wb *WidgetBase) Style() {
47 if wb.This == nil {
48 return
49 }
50
51 pw := wb.parentWidget()
52
53 // we do these things even if we are overriding the style
54 defer func() {
55 // note: this does not un-set the Invisible if not None, because all kinds of things
56 // can turn invisible to off.
57 if wb.Styles.Display == styles.DisplayNone {
58 wb.SetState(true, states.Invisible)
59 }
60 psz := math32.Vector2{}
61 if pw != nil {
62 psz = pw.Geom.Size.Alloc.Content
63 }
64 setUnitContext(&wb.Styles, wb.Scene, wb.Geom.Size.Alloc.Content, psz)
65 }()
66
67 if wb.OverrideStyle {
68 return
69 }
70 wb.resetStyleWidget()
71
72 if pw != nil {
73 wb.Styles.InheritFields(&pw.Styles)
74 }
75
76 wb.resetStyleSettings()
77 wb.runStylers()
78 wb.styleSettings()
79}
80
81// resetStyleWidget resets the widget styles and applies the basic
82// default styles specified in [styles.Style.Defaults].

Callers 1

TestHandleWidgetStateFunction · 0.95

Calls 8

parentWidgetMethod · 0.95
SetStateMethod · 0.95
resetStyleWidgetMethod · 0.95
resetStyleSettingsMethod · 0.95
runStylersMethod · 0.95
styleSettingsMethod · 0.95
setUnitContextFunction · 0.85
InheritFieldsMethod · 0.45

Tested by 1

TestHandleWidgetStateFunction · 0.76