TGUI  1.0-alpha
Theme.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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
34namespace tgui
35{
40 class TGUI_API Theme
41 {
42 public:
43
44 typedef std::shared_ptr<Theme> Ptr;
45 typedef std::shared_ptr<const Theme> ConstPtr;
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 static Theme::Ptr create(const String& primary = "");
93
94
103 void load(const String& primary);
104
105
115 std::shared_ptr<RendererData> getRenderer(const String& id);
116
117
127 std::shared_ptr<RendererData> getRendererNoThrow(const String& id);
128
129
137 ObjectConverter getGlobalProperty(const String& property);
138
139
149 void addRenderer(const String& id, std::shared_ptr<RendererData> renderer);
150
151
159 bool removeRenderer(const String& id);
160
161
166 const String& getPrimary() const;
167
168
174 static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
175
176
182 static std::shared_ptr<BaseThemeLoader> getThemeLoader();
183
184
195 static void setDefault(const String& primary = "");
196
197
203 static void setDefault(std::shared_ptr<Theme> theme);
204
205
209 static void setDefault(std::nullptr_t);
210
211
220 static std::shared_ptr<Theme> getDefault();
221
222
229 static void addRendererInheritanceParent(const String& widgetType, const String& parentType);
230
231
238 static String getRendererInheritanceParent(const String& widgetType);
239
240
248 static void addRendererDefaultSubwidget(const String& widgetType, const String& property, const String& propertyWidgetType);
249
250
257 static std::map<String, String> getRendererDefaultSubwidgets(const String& widgetType);
258
259
267 static void addRendererInheritedGlobalProperty(const String& widgetType, const String& property, const String& globalProperty);
268
269
276 static std::map<String, String> getRendererInheritedGlobalProperties(const String& widgetType);
277
278
280 protected:
281
282 static std::map<String, String> m_rendererInheritanceParents;
283 static std::map<String, std::map<String, String>> m_rendererDefaultSubwidgets;
284 static std::map<String, std::map<String, String>> m_rendererInheritedGlobalProperties;
285 static std::shared_ptr<Theme> m_defaultTheme;
286 static std::shared_ptr<BaseThemeLoader> m_themeLoader;
287
288 std::map<String, std::shared_ptr<RendererData>> m_renderers;
289 std::map<String, ObjectConverter> m_globalProperties;
290 String m_primary;
291 };
292
294}
295
297
298#endif // TGUI_THEME_HPP
Base class for theme loader implementations.
Definition: ThemeLoader.hpp:46
Implicit converter for settable properties.
Definition: ObjectConverter.hpp:48
Wrapper class to store strings.
Definition: String.hpp:79
This class can be used to manage the widget renderers.
Definition: Theme.hpp:41
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.
std::shared_ptr< const Theme > ConstPtr
Shared constant widget pointer.
Definition: Theme.hpp:45
Theme(const Theme &)
Copy constructor.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Shared data used in renderer classes.
Definition: WidgetRenderer.hpp:47