RADLib
RADical C++ application framework
RADUi::ThemeManager Class Reference

Process/application theme manager with RADCore events. More...

#include <RADTheme.h>

+ Inheritance diagram for RADUi::ThemeManager:
+ Collaboration diagram for RADUi::ThemeManager:

Public Member Functions

 ThemeManager ()
 Creates a manager using the default light theme. More...
 
ThemeMode mode () const
 Returns current mode. More...
 
void setMode (ThemeMode mode)
 Sets current theme mode. More...
 
const Themetheme () const
 Returns active theme tokens. More...
 
void setTheme (Theme theme)
 Replaces active theme tokens. More...
 
bool loadFromFile (const std::string &path, std::string *error=nullptr)
 Loads theme JSON from path. More...
 
bool saveToFile (const std::string &path, std::string *error=nullptr) const
 Saves current theme JSON to path. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Static Public Member Functions

static Theme lightTheme ()
 Returns RADUi's default light theme. More...
 
static Theme darkTheme ()
 Returns RADUi's default dark theme. More...
 
static RADCore::RADJsonValue toJson (const Theme &theme)
 Converts a theme to JSON. More...
 
static Theme fromJson (const RADCore::RADJsonValue &value, const Theme &defaults=lightTheme())
 Converts JSON to a theme, using defaults for missing fields. More...
 
static std::string modeName (ThemeMode mode)
 Converts ThemeMode to stable text. More...
 
static ThemeMode modeFromName (const std::string &name)
 Parses ThemeMode text. More...
 

Public Attributes

RADCore::Event< void() > changed
 Raised when mode or theme tokens change. More...
 

Detailed Description

Process/application theme manager with RADCore events.

Constructor & Destructor Documentation

◆ ThemeManager()

RADUi::ThemeManager::ThemeManager ( )

Creates a manager using the default light theme.

Member Function Documentation

◆ darkTheme()

static Theme RADUi::ThemeManager::darkTheme ( )
static

Returns RADUi's default dark theme.

◆ fromJson()

static Theme RADUi::ThemeManager::fromJson ( const RADCore::RADJsonValue value,
const Theme defaults = lightTheme() 
)
static

Converts JSON to a theme, using defaults for missing fields.

◆ lightTheme()

static Theme RADUi::ThemeManager::lightTheme ( )
static

Returns RADUi's default light theme.

◆ loadFromFile()

bool RADUi::ThemeManager::loadFromFile ( const std::string &  path,
std::string *  error = nullptr 
)

Loads theme JSON from path.

◆ mode()

ThemeMode RADUi::ThemeManager::mode ( ) const

Returns current mode.

◆ modeFromName()

static ThemeMode RADUi::ThemeManager::modeFromName ( const std::string &  name)
static

Parses ThemeMode text.

◆ modeName()

static std::string RADUi::ThemeManager::modeName ( ThemeMode  mode)
static

Converts ThemeMode to stable text.

◆ saveToFile()

bool RADUi::ThemeManager::saveToFile ( const std::string &  path,
std::string *  error = nullptr 
) const

Saves current theme JSON to path.

◆ setMode()

void RADUi::ThemeManager::setMode ( ThemeMode  mode)

Sets current theme mode.

◆ setTheme()

void RADUi::ThemeManager::setTheme ( Theme  theme)

Replaces active theme tokens.

◆ theme()

const Theme& RADUi::ThemeManager::theme ( ) const

Returns active theme tokens.

◆ toJson()

static RADCore::RADJsonValue RADUi::ThemeManager::toJson ( const Theme theme)
static

Converts a theme to JSON.

Member Data Documentation

◆ changed

RADCore::Event<void () > RADUi::ThemeManager::changed

Raised when mode or theme tokens change.


The documentation for this class was generated from the following file: