Tracks OS-level appearance (light/dark mode) and auto-switches themes. More...
#include <appearance_tracker.hpp>
Public Member Functions | |
| AppearanceTracker () | |
| ~AppearanceTracker () | |
| Appearance | current_appearance () const |
| Get current system appearance. | |
| bool | poll () |
| Poll for appearance changes. | |
| void | on_appearance_changed (std::function< void(Appearance)> callback) |
| Register a callback for appearance changes. | |
| void | lock (Appearance appearance) |
| Lock to a specific appearance, ignoring OS changes. | |
| void | unlock () |
| Unlock and resume tracking OS appearance. | |
| bool | is_locked () const |
| Check if appearance is locked. | |
| Appearance | locked_appearance () const |
| Get the locked appearance (only valid when is_locked() is true). | |
Tracks OS-level appearance (light/dark mode) and auto-switches themes.
On macOS, observes NSAppearance changes via NSApp effective appearance. On Windows, monitors the AppsUseLightTheme registry key. On Linux/other platforms, defaults to dark and does not auto-detect.
| pulp::view::AppearanceTracker::AppearanceTracker | ( | ) |
| pulp::view::AppearanceTracker::~AppearanceTracker | ( | ) |
| Appearance pulp::view::AppearanceTracker::current_appearance | ( | ) | const |
Get current system appearance.
|
inline |
Check if appearance is locked.
| void pulp::view::AppearanceTracker::lock | ( | Appearance | appearance | ) |
Lock to a specific appearance, ignoring OS changes.
|
inline |
Get the locked appearance (only valid when is_locked() is true).
| void pulp::view::AppearanceTracker::on_appearance_changed | ( | std::function< void(Appearance)> | callback | ) |
Register a callback for appearance changes.
The callback receives the new appearance.
| bool pulp::view::AppearanceTracker::poll | ( | ) |
Poll for appearance changes.
Call this periodically (e.g., once per frame). Returns true if the appearance changed since last poll.
| void pulp::view::AppearanceTracker::unlock | ( | ) |
Unlock and resume tracking OS appearance.