Trait that makes a component react to global theme changes. More...
#include <Malena/Traits/Theme/Themeable.h>
Inherits ml::Trait.
Inherited by ml::ButtonToggle, ml::Checkbox, ml::CheckboxGroup, ml::List, ml::ListItem, ml::MenuBar, ml::Panel, ml::PillToggle, ml::RadioButton, ml::RadioGroup, ml::SegmentToggle, ml::Select, ml::SideMenu, ml::SplitPanel, ml::TabbedPanel, ml::TextInput, and ml::Toolbar.
Public Member Functions | |
| Themeable () | |
| virtual | ~Themeable () |
| bool | isSettingsLocked () const |
Return true if applySettings() is currently blocked. | |
| bool | isThemeLocked () const |
Return true if this component ignores theme changes. | |
| void | lockSettings () |
Prevent applySettings() from taking effect. | |
| void | lockTheme () |
| Prevent automatic re-styling when the global theme changes. | |
| virtual void | onThemeApplied (const Theme &theme)=0 |
Called by ThemeManager when the active theme changes. | |
| void | unlockSettings () |
Allow applySettings() to take effect again. | |
| void | unlockTheme () |
| Resume reacting to global theme changes. | |
Trait that makes a component react to global theme changes.
Any component that inherits Themeable automatically subscribes to ThemeManager on construction and unsubscribes on destruction. When ThemeManager::apply() or ThemeManager::set() is called, every subscribed component's onThemeApplied() is invoked.
Explicit calls to individual setters (e.g. setTrackOnColor()) always take effect regardless of lock state — locks only block automatic updates from ThemeManager and applySettings().
Definition at line 62 of file Themeable.h.
|
inline |
Definition at line 67 of file Themeable.h.
|
inlinevirtual |
Definition at line 72 of file Themeable.h.
|
inlinenodiscard |
Return true if applySettings() is currently blocked.
Definition at line 115 of file Themeable.h.
|
inlinenodiscard |
Return true if this component ignores theme changes.
Definition at line 97 of file Themeable.h.
|
inline |
Prevent applySettings() from taking effect.
Explicit individual setter calls still work normally. Only blocks the batch applySettings() path.
Definition at line 107 of file Themeable.h.
|
inline |
Prevent automatic re-styling when the global theme changes.
The component keeps its current visual state. Explicit individual setter calls still work normally.
Definition at line 85 of file Themeable.h.
|
pure virtual |
Called by ThemeManager when the active theme changes.
Override in your component to re-style from the new theme. Always check isThemeLocked() first:
| theme | The newly active theme. |
Implemented in ml::ButtonToggle, ml::Checkbox, ml::CheckboxGroup, ml::List, ml::ListItem, ml::MenuBar, ml::Panel, ml::PillToggle, ml::RadioButton, ml::RadioGroup, ml::SegmentToggle, ml::Select, ml::SideMenu, ml::SplitPanel, ml::TabbedPanel, ml::TextArea, ml::TextInput, and ml::Toolbar.
|
inline |
Allow applySettings() to take effect again.
Definition at line 112 of file Themeable.h.
|
inline |
Resume reacting to global theme changes.
Does NOT immediately re-apply the current theme — call ThemeManager::get() and pass it to onThemeApplied() manually if you want to re-sync immediately after unlocking.
Definition at line 94 of file Themeable.h.