TGUI  1.3-dev
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
26#ifndef TGUI_THEME_HPP
27#define TGUI_THEME_HPP
28
29#include <TGUI/Loading/ThemeLoader.hpp>
30#include <TGUI/Renderers/WidgetRenderer.hpp>
31
33
34TGUI_MODULE_EXPORT namespace tgui
35{
40 class TGUI_API Theme
41 {
42 public:
43
44 using Ptr = std::shared_ptr<Theme>;
45 using ConstPtr = std::shared_ptr<const Theme>;
46
47
53 Theme(const String& primary = "");
54
55
59 Theme(const Theme&);
60
64 Theme(Theme&&) noexcept;
65
69 virtual ~Theme();
70
74 Theme& operator=(const Theme&);
75
79 Theme& operator=(Theme&&) noexcept;
80
81
92 TGUI_NODISCARD static Theme::Ptr create(const String& primary = "");
93
94
103 void load(const String& primary);
104
105
116 void replace(const Theme& otherTheme);
117
118
128 TGUI_NODISCARD std::shared_ptr<RendererData> getRenderer(const String& id);
129
130
140 TGUI_NODISCARD std::shared_ptr<RendererData> getRendererNoThrow(const String& id);
141
142
150 TGUI_NODISCARD ObjectConverter getGlobalProperty(const String& property);
151
152
162 void addRenderer(const String& id, std::shared_ptr<RendererData> renderer);
163
164
172 bool removeRenderer(const String& id);
173
174
179 TGUI_NODISCARD const String& getPrimary() const;
180
181
187 static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
188
189
195 TGUI_NODISCARD static std::shared_ptr<BaseThemeLoader> getThemeLoader();
196
197
208 static void setDefault(const String& primary = "");
209
210
216 static void setDefault(std::shared_ptr<Theme> theme);
217
218
222 static void setDefault(std::nullptr_t);
223
224
233 TGUI_NODISCARD static std::shared_ptr<Theme> getDefault();
234
235
242 static void addRendererInheritanceParent(const String& widgetType, const String& parentType);
243
244
251 TGUI_NODISCARD static String getRendererInheritanceParent(const String& widgetType);
252
253
261 static void addRendererDefaultSubwidget(const String& widgetType, const String& property, const String& propertyWidgetType);
262
263
270 TGUI_NODISCARD static std::map<String, String> getRendererDefaultSubwidgets(const String& widgetType);
271
272
280 static void addRendererInheritedGlobalProperty(const String& widgetType, const String& property, const String& globalProperty);
281
282
289 TGUI_NODISCARD static std::map<String, String> getRendererInheritedGlobalProperties(const String& widgetType);
290
291
293 protected:
294
295 static std::map<String, String> m_rendererInheritanceParents;
296 static std::map<String, std::map<String, String>> m_rendererDefaultSubwidgets;
297 static std::map<String, std::map<String, String>> m_rendererInheritedGlobalProperties;
298 static std::shared_ptr<Theme> m_defaultTheme;
299 static std::shared_ptr<BaseThemeLoader> m_themeLoader;
300
301 std::map<String, std::shared_ptr<RendererData>> m_renderers;
302 std::map<String, ObjectConverter> m_globalProperties;
303 String m_primary;
304 };
305
307}
308
310
311#endif // TGUI_THEME_HPP
Base class for theme loader implementations.
Definition ThemeLoader.hpp:49
Implicit converter for settable properties.
Definition ObjectConverter.hpp:48
Wrapper class to store strings.
Definition String.hpp:101
This class can be used to manage the widget renderers.
Definition Theme.hpp:41
std::shared_ptr< const Theme > ConstPtr
Shared constant widget pointer.
Definition Theme.hpp:45
std::shared_ptr< Theme > Ptr
Shared widget pointer.
Definition Theme.hpp:44
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:39
Shared data used in renderer classes.
Definition WidgetRenderer.hpp:50