Loading...
Searching...
No Matches
Themeable.h
Go to the documentation of this file.
1//
2// Themeable.h
3//
4
5#ifndef MALENA_THEMEABLE_H
6#define MALENA_THEMEABLE_H
7
8#pragma once
9
13
14namespace ml
15{
16 // ── Themeable ─────────────────────────────────────────────────────────────
17
62 class MALENA_API Themeable : public Trait
63 {
64 public:
65 // ── Construction / destruction ────────────────────────────────────────
66
68 {
70 }
71
72 virtual ~Themeable()
73 {
75 }
76
77 // ── Theme lock ────────────────────────────────────────────────────────
78
85 void lockTheme() { _themeLocked = true; }
86
94 void unlockTheme() { _themeLocked = false; }
95
97 [[nodiscard]] bool isThemeLocked() const { return _themeLocked; }
98
99 // ── Settings lock ─────────────────────────────────────────────────────
100
107 void lockSettings() { _settingsLocked = true; }
108
112 void unlockSettings() { _settingsLocked = false; }
113
115 [[nodiscard]] bool isSettingsLocked() const { return _settingsLocked; }
116
117 // ── Theme change handler ──────────────────────────────────────────────
118
136 virtual void onThemeApplied(const Theme& theme) = 0;
137
138 private:
139 bool _themeLocked = false;
140 bool _settingsLocked = false;
141 };
142
143} // namespace ml
144
145#endif // MALENA_THEMEABLE_H
static void subscribe(Themeable *component)
Subscribe a component to theme change notifications.
static void unsubscribe(Themeable *component)
Unsubscribe a component from theme change notifications.
bool isSettingsLocked() const
Return true if applySettings() is currently blocked.
Definition Themeable.h:115
void unlockSettings()
Allow applySettings() to take effect again.
Definition Themeable.h:112
bool isThemeLocked() const
Return true if this component ignores theme changes.
Definition Themeable.h:97
virtual void onThemeApplied(const Theme &theme)=0
Called by ThemeManager when the active theme changes.
void lockSettings()
Prevent applySettings() from taking effect.
Definition Themeable.h:107
virtual ~Themeable()
Definition Themeable.h:72
void lockTheme()
Prevent automatic re-styling when the global theme changes.
Definition Themeable.h:85
void unlockTheme()
Resume reacting to global theme changes.
Definition Themeable.h:94
Empty marker base class for all Malena traits.
Definition Trait.h:35
#define MALENA_API
Definition Component.h:22
Universal design token set applied across all Themeable components.
Definition Theme.h:70