TGUI  0.8.9
Theme.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2020 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
49 Theme(const std::string& primary = "");
50
51
58
59
68 void load(const std::string& primary);
69
70
80 std::shared_ptr<RendererData> getRenderer(const std::string& id);
81
82
92 std::shared_ptr<RendererData> getRendererNoThrow(const std::string& id);
93
94
104 void addRenderer(const std::string& id, std::shared_ptr<RendererData> renderer);
105
106
114 bool removeRenderer(const std::string& id);
115
116
121 const std::string& getPrimary() const;
122
123
129 static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
130
131
137 static std::shared_ptr<BaseThemeLoader> getThemeLoader();
138
139
147 static void setDefault(Theme* theme);
148
149
159 static Theme* getDefault();
160
161
163 protected:
164
165 static Theme* m_defaultTheme;
166 static std::shared_ptr<BaseThemeLoader> m_themeLoader;
167 std::map<std::string, std::shared_ptr<RendererData>> m_renderers;
168 std::string m_primary;
169 };
170
172}
173
175
176#endif // TGUI_THEME_HPP
This class can be used to manage the widget renderers.
Definition: Theme.hpp:41
std::shared_ptr< RendererData > getRenderer(const std::string &id)
Gets data for the renderers.
static void setDefault(Theme *theme)
Sets the theme class that widgets use by default.
std::map< std::string, std::shared_ptr< RendererData > > m_renderers
Maps ids to renderer datas.
Definition: Theme.hpp:167
static std::shared_ptr< BaseThemeLoader > m_themeLoader
Theme loader which will do the actual loading.
Definition: Theme.hpp:166
std::shared_ptr< RendererData > getRendererNoThrow(const std::string &id)
Gets data for the renderers.
const std::string & getPrimary() const
Returns the primary theme loader parameter.
~Theme()
Destructor.
void load(const std::string &primary)
Changes the primary theme loader parameter.
static Theme * getDefault()
Returns a pointer to the theme class that widgets use by default.
static void setThemeLoader(std::shared_ptr< BaseThemeLoader > themeLoader)
Changes the function that will load the widget theme data.
bool removeRenderer(const std::string &id)
Manually removes a renderer to the theme.
static std::shared_ptr< BaseThemeLoader > getThemeLoader()
Returns the function that is currently being used to load the widget theme data.
Theme(const std::string &primary="")
Constructs the theme class, with an optional theme file to load.
void addRenderer(const std::string &id, std::shared_ptr< RendererData > renderer)
Manually adds a renderer data to the theme.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37