Style updates the style properties of the widget based on [WidgetBase.Stylers]. To specify the style properties of a widget, use [WidgetBase.Styler].
()
| 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]. |
| 46 | func (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]. |