TGUI  1.6.1
Loading...
Searching...
No Matches
Theme.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_THEME_HPP
26#define TGUI_THEME_HPP
27
28#include <TGUI/Loading/ThemeLoader.hpp>
29#include <TGUI/Renderers/WidgetRenderer.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
39 class TGUI_API Theme
40 {
41 public:
42
43 using Ptr = std::shared_ptr<Theme>;
44 using ConstPtr = std::shared_ptr<const Theme>;
45
51 Theme(const String& primary = "");
52
56 Theme(const Theme&);
57
61 Theme(Theme&&) noexcept;
62
66 virtual ~Theme();
67
71 Theme& operator=(const Theme&);
72
76 Theme& operator=(Theme&&) noexcept;
77
88 TGUI_NODISCARD static Theme::Ptr create(const String& primary = "");
89
98 void load(const String& primary);
99
110 void replace(const Theme& otherTheme);
111
121 TGUI_NODISCARD std::shared_ptr<RendererData> getRenderer(const String& id);
122
132 TGUI_NODISCARD std::shared_ptr<RendererData> getRendererNoThrow(const String& id);
133
141 TGUI_NODISCARD ObjectConverter getGlobalProperty(const String& property);
142
152 void addRenderer(const String& id, std::shared_ptr<RendererData> renderer);
153
161 bool removeRenderer(const String& id);
162
167 TGUI_NODISCARD const String& getPrimary() const;
168
174 static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
175
181 TGUI_NODISCARD static std::shared_ptr<BaseThemeLoader> getThemeLoader();
182
193 static void setDefault(const String& primary = "");
194
200 static void setDefault(std::shared_ptr<Theme> theme);
201
205 static void setDefault(std::nullptr_t);
206
215 TGUI_NODISCARD static std::shared_ptr<Theme> getDefault();
216
223 static void addRendererInheritanceParent(const String& widgetType, const String& parentType);
224
231 TGUI_NODISCARD static String getRendererInheritanceParent(const String& widgetType);
232
240 static void addRendererDefaultSubwidget(const String& widgetType, const String& property, const String& propertyWidgetType);
241
248 TGUI_NODISCARD static std::map<String, String> getRendererDefaultSubwidgets(const String& widgetType);
249
257 static void addRendererInheritedGlobalProperty(const String& widgetType, const String& property, const String& globalProperty);
258
265 TGUI_NODISCARD static std::map<String, String> getRendererInheritedGlobalProperties(const String& widgetType);
266
268 protected:
269
270 static std::map<String, String> m_rendererInheritanceParents;
271 static std::map<String, std::map<String, String>> m_rendererDefaultSubwidgets;
272 static std::map<String, std::map<String, String>> m_rendererInheritedGlobalProperties;
273 static std::shared_ptr<Theme> m_defaultTheme;
274 static std::shared_ptr<BaseThemeLoader> m_themeLoader;
275
276 std::map<String, std::shared_ptr<RendererData>> m_renderers;
277 std::map<String, ObjectConverter> m_globalProperties;
278 String m_primary;
279 };
280
282}
283
285
286#endif // TGUI_THEME_HPP
Base class for theme loader implementations.
Definition ThemeLoader.hpp:47
Implicit converter for settable properties.
Definition ObjectConverter.hpp:46
Wrapper class to store strings.
Definition String.hpp:96
This class can be used to manage the widget renderers.
Definition Theme.hpp:40
std::shared_ptr< const Theme > ConstPtr
Shared constant widget pointer.
Definition Theme.hpp:44
std::shared_ptr< Theme > Ptr
Shared widget pointer.
Definition Theme.hpp:43
Theme(Theme &&) noexcept
Move constructor.
Theme(const String &primary="")
Constructs the theme class, with an optional theme file to load.
Theme(const Theme &)
Copy constructor.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
Shared data used in renderer classes.
Definition WidgetRenderer.hpp:48