TGUI  0.10-beta
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
66 static Theme::Ptr create(const String& primary = "");
67
68
77 void load(const String& primary);
78
79
89 std::shared_ptr<RendererData> getRenderer(const String& id);
90
91
101 std::shared_ptr<RendererData> getRendererNoThrow(const String& id);
102
103
113 void addRenderer(const String& id, std::shared_ptr<RendererData> renderer);
114
115
123 bool removeRenderer(const String& id);
124
125
130 const String& getPrimary() const;
131
132
138 static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
139
140
146 static std::shared_ptr<BaseThemeLoader> getThemeLoader();
147
148
159 static void setDefault(const String& primary = "");
160
161
167 static void setDefault(std::shared_ptr<Theme> theme);
168
169
173 static void setDefault(std::nullptr_t);
174
175
184 static std::shared_ptr<Theme> getDefault();
185
186
188 protected:
189
190 static std::shared_ptr<Theme> m_defaultTheme;
191 static std::shared_ptr<BaseThemeLoader> m_themeLoader;
192 std::map<String, std::shared_ptr<RendererData>> m_renderers;
193 String m_primary;
194 };
195
197}
198
200
201#endif // TGUI_THEME_HPP
Wrapper class to store strings.
Definition: String.hpp:79
This class can be used to manage the widget renderers.
Definition: Theme.hpp:41
static std::shared_ptr< BaseThemeLoader > m_themeLoader
Theme loader which will do the actual loading.
Definition: Theme.hpp:191
static std::shared_ptr< Theme > getDefault()
Returns a pointer to the theme class that widgets use by default.
std::map< String, std::shared_ptr< RendererData > > m_renderers
Maps ids to renderer datas.
Definition: Theme.hpp:192
void load(const String &primary)
Changes the primary theme loader parameter.
std::shared_ptr< RendererData > getRenderer(const String &id)
Gets data for the renderers.
std::shared_ptr< Theme > Ptr
Shared widget pointer.
Definition: Theme.hpp:44
static void setDefault(const String &primary="")
Sets the theme class that widgets use by default.
void addRenderer(const String &id, std::shared_ptr< RendererData > renderer)
Manually adds a renderer data to the theme.
static void setThemeLoader(std::shared_ptr< BaseThemeLoader > themeLoader)
Changes the function that will load the widget theme data.
static std::shared_ptr< BaseThemeLoader > getThemeLoader()
Returns the function that is currently being used to load the widget theme data.
const String & getPrimary() const
Returns the primary theme loader parameter.
static Theme::Ptr create(const String &primary="")
Constructs a new theme, with an optional theme file to load.
static void setDefault(std::shared_ptr< Theme > theme)
Sets the theme class that widgets use by default.
std::shared_ptr< RendererData > getRendererNoThrow(const String &id)
Gets data for the renderers.
bool removeRenderer(const String &id)
Manually removes a renderer to the theme.
static void setDefault(std::nullptr_t)
Resets the theme that widgets use by default.
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
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36