--- ---
TGUI
1.0-dev
|
This class can be used to manage the widget renderers. More...
#include <TGUI/Loading/Theme.hpp>
Public Types | |
using | Ptr = std::shared_ptr<Theme> |
Shared widget pointer. | |
using | ConstPtr = std::shared_ptr<const Theme> |
Shared constant widget pointer. | |
Public Member Functions | |
Theme (const String &primary="") | |
Constructs the theme class, with an optional theme file to load. | |
Theme (const Theme &) | |
Copy constructor. | |
Theme (Theme &&) noexcept | |
Move constructor. | |
virtual | ~Theme () |
Destructor. | |
Theme & | operator= (const Theme &) |
Overload of copy assignment operator. | |
Theme & | operator= (Theme &&) noexcept |
Move assignment. | |
void | load (const String &primary) |
Changes the primary theme loader parameter. | |
TGUI_NODISCARD std::shared_ptr< RendererData > | getRenderer (const String &id) |
Gets data for the renderers. | |
TGUI_NODISCARD std::shared_ptr< RendererData > | getRendererNoThrow (const String &id) |
Gets data for the renderers. | |
TGUI_NODISCARD ObjectConverter | getGlobalProperty (const String &property) |
Returns the value of a global property in the theme. | |
void | addRenderer (const String &id, std::shared_ptr< RendererData > renderer) |
Manually adds a renderer data to the theme. | |
bool | removeRenderer (const String &id) |
Manually removes a renderer to the theme. | |
TGUI_NODISCARD const String & | getPrimary () const |
Returns the primary theme loader parameter. | |
Static Public Member Functions | |
static TGUI_NODISCARD Theme::Ptr | create (const String &primary="") |
Constructs a new theme, with an optional theme file to load. | |
static void | setThemeLoader (std::shared_ptr< BaseThemeLoader > themeLoader) |
Changes the function that will load the widget theme data. | |
static TGUI_NODISCARD std::shared_ptr< BaseThemeLoader > | getThemeLoader () |
Returns the function that is currently being used to load the widget theme data. | |
static void | setDefault (const String &primary="") |
Sets the theme class that widgets use by default. | |
static void | setDefault (std::shared_ptr< Theme > theme) |
Sets the theme class that widgets use by default. | |
static void | setDefault (std::nullptr_t) |
Resets the theme that widgets use by default. | |
static TGUI_NODISCARD std::shared_ptr< Theme > | getDefault () |
Returns a pointer to the theme class that widgets use by default. | |
static void | addRendererInheritanceParent (const String &widgetType, const String &parentType) |
Inform the theme that a custom renderer class inherits its properties from an existing renderer. | |
static TGUI_NODISCARD String | getRendererInheritanceParent (const String &widgetType) |
Returns the parent type of a widget. | |
static void | addRendererDefaultSubwidget (const String &widgetType, const String &property, const String &propertyWidgetType) |
Inform the theme that a custom renderer has subwidgets that need a default value. | |
static TGUI_NODISCARD std::map< String, String > | getRendererDefaultSubwidgets (const String &widgetType) |
Returns the defaulted subwidgets that a renderer has. | |
static void | addRendererInheritedGlobalProperty (const String &widgetType, const String &property, const String &globalProperty) |
Inform the theme that a custom renderer has properties that can use a default value from the global properties. | |
static TGUI_NODISCARD std::map< String, String > | getRendererInheritedGlobalProperties (const String &widgetType) |
Returns the properties which a renderer inherits from the global theme properties. | |
Protected Attributes | |
std::map< String, std::shared_ptr< RendererData > > | m_renderers |
Maps ids to renderer datas. | |
std::map< String, ObjectConverter > | m_globalProperties |
Maps id to value. | |
String | m_primary |
Static Protected Attributes | |
static std::map< String, String > | m_rendererInheritanceParents |
static std::map< String, std::map< String, String > > | m_rendererDefaultSubwidgets |
static std::map< String, std::map< String, String > > | m_rendererInheritedGlobalProperties |
static std::shared_ptr< Theme > | m_defaultTheme |
static std::shared_ptr< BaseThemeLoader > | m_themeLoader |
Theme loader which will do the actual loading. | |
This class can be used to manage the widget renderers.
tgui::Theme::Theme | ( | const String & | primary = "" | ) |
Constructs the theme class, with an optional theme file to load.
primary | Primary parameter for the theme loader (filename of the theme file in DefaultThemeLoader) |
void tgui::Theme::addRenderer | ( | const String & | id, |
std::shared_ptr< RendererData > | renderer ) |
Manually adds a renderer data to the theme.
id | Identifier of the renderer |
renderer | The renderer to add |
If a renderer with the same id already exists then it will be replaced by this one. Widgets using the old renderer will keep using that old renderer and remain unchanged.
|
static |
Inform the theme that a custom renderer has subwidgets that need a default value.
widgetType | Type name of the custom widget |
property | Property of the renderer which should refer to another section in the renderer |
propertyWidgetType | Type name of subwidget, which specifies the section in the theme file to refer to |
|
static |
Inform the theme that a custom renderer class inherits its properties from an existing renderer.
widgetType | Type name of the custom widget |
parentType | Type name of the base widget |
|
static |
Inform the theme that a custom renderer has properties that can use a default value from the global properties.
widgetType | Type name of the custom widget |
property | Property of the renderer which refers to the global property |
globalProperty | Global property in the theme that would be copied as default value for the renderer property |
|
static |
Constructs a new theme, with an optional theme file to load.
primary | Primary parameter for the theme loader (filename of the theme file in DefaultThemeLoader) |
Unlike with widgets, it is not required to use a smart pointer for the theme. You do not have to use this function to create a theme.
|
static |
Returns a pointer to the theme class that widgets use by default.
When setDefault was not called or was given a nullptr as parameter, getDefault will create and return the default "White" theme.
TGUI_NODISCARD ObjectConverter tgui::Theme::getGlobalProperty | ( | const String & | property | ) |
Returns the value of a global property in the theme.
property | Name of the global property to retrieve |
TGUI_NODISCARD const String & tgui::Theme::getPrimary | ( | ) | const |
Returns the primary theme loader parameter.
TGUI_NODISCARD std::shared_ptr< RendererData > tgui::Theme::getRenderer | ( | const String & | id | ) |
Gets data for the renderers.
id | The secondary parameter for the theme loader (name of section in theme file in DefaultThemeLoader). |
Exception | if theme loader fails to load the requested renderer |
|
static |
Returns the defaulted subwidgets that a renderer has.
widgetType | Type name of the widget of which we are looking up the properties |
|
static |
Returns the parent type of a widget.
widgetType | Type name of the derived widget |
|
static |
Returns the properties which a renderer inherits from the global theme properties.
widgetType | Type name of the widget of which we are looking up the properties |
TGUI_NODISCARD std::shared_ptr< RendererData > tgui::Theme::getRendererNoThrow | ( | const String & | id | ) |
Gets data for the renderers.
id | The secondary parameter for the theme loader (name of section in theme file in DefaultThemeLoader). |
Unlike getRenderer which throws an exception, this function will return nullptr when the renderer is not found
|
static |
Returns the function that is currently being used to load the widget theme data.
void tgui::Theme::load | ( | const String & | primary | ) |
Changes the primary theme loader parameter.
primary | Primary parameter for the theme loader (filename of the theme file in DefaultThemeLoader) |
When the theme was loaded before and a renderer with the same name is encountered, the widgets that were using the old renderer will be reloaded with the new renderer.
bool tgui::Theme::removeRenderer | ( | const String & | id | ) |
Manually removes a renderer to the theme.
id | Identifier of the renderer |
|
static |
Sets the theme class that widgets use by default.
primary | Primary parameter for the theme loader (filename of the theme file in DefaultThemeLoader) |
Calling this function is equivalent to the following:
|
static |
Sets the theme class that widgets use by default.
theme | Theme to use as default |
|
static |
Changes the function that will load the widget theme data.
themeLoader | Pointer to the new loader |