30#include <TGUI/Widget.hpp>
31#include <TGUI/Loading/WidgetConverter.hpp>
32#include <TGUI/Loading/ThemeLoader.hpp>
42 class TGUI_API
BaseTheme :
public std::enable_shared_from_this<BaseTheme>
89 virtual void initWidget(
Widget* widget, std::string primary, std::string secondary) = 0;
117 void widgetReload(
Widget* widget,
const std::string& primary =
"",
const std::string& secondary =
"",
bool force =
false);
135 typedef std::shared_ptr<Theme>
Ptr;
146 Theme(
const std::string& filename =
"");
181 void reload(
const std::string& filename);
194 void reload(std::string oldClassName, std::string newClassName);
220 void setProperty(std::string className,
const std::string& property,
const std::string& value);
246 std::string
getProperty(std::string className, std::string property)
const;
266 std::shared_ptr<Theme>
clone()
const;
296 virtual void initWidget(
Widget* widget, std::string filename, std::string className)
override;
301 std::string m_filename;
302 bool m_resourcePathLock =
false;
303 std::map<Widget*, std::string> m_widgets;
304 std::map<std::string, std::string> m_widgetTypes;
305 std::map<std::string, std::map<std::string, std::string>> m_widgetProperties;
307 friend class ThemeTest;
Base class for the Theme classes.
Definition: Theme.hpp:43
static std::map< std::string, std::function< Widget::Ptr()> > m_constructors
Widget creator functions.
Definition: Theme.hpp:122
virtual void initWidget(Widget *widget, std::string primary, std::string secondary)=0
Virtual function called by the widget to finish its initialization.
virtual ~BaseTheme()=default
Virtual destructor.
virtual WidgetConverter internalLoad(const std::string &primary, const std::string &secondary)=0
This function can be used inside a widget to load other widgets without access to the derived theme c...
static std::shared_ptr< BaseThemeLoader > m_themeLoader
Theme loading functions, they read the theme file.
Definition: Theme.hpp:123
static void setConstructFunction(const std::string &type, const std::function< Widget::Ptr()> &constructor)
Changes the construct function of a specific widget type.
virtual void widgetAttached(Widget *widget)
Virtual function that gets called when a widget is connected to this theme.
virtual void widgetDetached(Widget *widget)
Virtual function that gets called when a widget is disconnected from this theme.
static void setThemeLoader(const std::shared_ptr< BaseThemeLoader > &themeLoader)
Change the function that will load the widget theme data.
Implicit converter for settable properties.
Definition: ObjectConverter.hpp:43
Default Theme class.
Definition: Theme.hpp:132
virtual void widgetDetached(Widget *widget) override
Function that gets called when a widget is disconnected from this theme.
Theme(const std::string &filename="")
Construct the theme class, with an optional theme file to load.
virtual void initWidget(Widget *widget, std::string filename, std::string className) override
Function called by the widget to finish its initialization.
void reload(const std::string &filename)
Reload the theme with a different filename.
WidgetConverter load(std::string className)
Load the widget from the theme.
std::shared_ptr< Theme > Ptr
Shared theme pointer.
Definition: Theme.hpp:135
static Theme::Ptr create(const std::string &filename="")
Creates a new theme instance.
void setProperty(std::string className, const std::string &property, const std::string &value)
Change a property of the renderer of all widgets that were loaded with a certain class name.
void setProperty(std::string className, const std::string &property, ObjectConverter &&value)
Change a property of the renderer of all widgets that were loaded with a certain class name.
std::string getProperty(std::string className, std::string property) const
Retrieve the serialized value of a certain property of widgets that use a certain class name.
void reload(Widget::Ptr widget, std::string className)
Reload a specific widget.
void reload(std::string oldClassName, std::string newClassName)
Reload all widgets that were loaded with a certain class name.
std::map< std::string, std::string > getPropertyValuePairs(std::string className) const
Get a map with all properties and their values from widgets loaded with a certain class name.
virtual WidgetConverter internalLoad(const std::string &filename, const std::string &className) override
This function can be used inside a widget to load other widgets without access to the derived theme c...
std::shared_ptr< Theme > clone() const
Clone the theme without its connected widgets.
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34