Loading...
Searching...
No Matches
25#ifndef TGUI_RENDERER_DEFINES_HPP
26#define TGUI_RENDERER_DEFINES_HPP
28#include <TGUI/Loading/Theme.hpp>
32#define TGUI_RENDERER_PROPERTY_OUTLINE(CLASS, NAME) \
33 tgui::Outline CLASS::get##NAME() const \
35 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
36 if (it != m_data->propertyValuePairs.end()) \
37 return it->second.getOutline(); \
41 void CLASS::set##NAME(const tgui::Outline& outline) \
43 setProperty(tgui::String(#NAME), {outline}); \
48#define TGUI_RENDERER_PROPERTY_COLOR(CLASS, NAME, DEFAULT) \
49 tgui::Color CLASS::get##NAME() const \
51 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
52 if (it != m_data->propertyValuePairs.end()) \
53 return it->second.getColor(); \
57 void CLASS::set##NAME(tgui::Color color) \
59 setProperty(tgui::String(#NAME), {color}); \
64#define TGUI_RENDERER_PROPERTY_TEXT_STYLE(CLASS, NAME, DEFAULT) \
65 tgui::TextStyles CLASS::get##NAME() const \
67 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
68 if (it != m_data->propertyValuePairs.end()) \
69 return it->second.getTextStyle(); \
73 void CLASS::set##NAME(tgui::TextStyles style) \
75 setProperty(tgui::String(#NAME), tgui::ObjectConverter{style}); \
80#define TGUI_RENDERER_PROPERTY_GET_NUMBER(CLASS, NAME, DEFAULT) \
81 float CLASS::get##NAME() const \
83 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
84 if (it != m_data->propertyValuePairs.end()) \
85 return it->second.getNumber(); \
90#define TGUI_RENDERER_PROPERTY_NUMBER(CLASS, NAME, DEFAULT) \
91 TGUI_RENDERER_PROPERTY_GET_NUMBER(CLASS, NAME, DEFAULT) \
92 void CLASS::set##NAME(float number) \
94 setProperty(tgui::String(#NAME), tgui::ObjectConverter{number}); \
99#define TGUI_RENDERER_PROPERTY_GET_BOOL(CLASS, NAME, DEFAULT) \
100 bool CLASS::get##NAME() const \
102 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
103 if (it != m_data->propertyValuePairs.end()) \
104 return it->second.getBool(); \
109#define TGUI_RENDERER_PROPERTY_BOOL(CLASS, NAME, DEFAULT) \
110 TGUI_RENDERER_PROPERTY_GET_BOOL(CLASS, NAME, DEFAULT) \
111 void CLASS::set##NAME(bool flag) \
113 setProperty(tgui::String(#NAME), tgui::ObjectConverter{flag}); \
118#define TGUI_RENDERER_PROPERTY_TEXTURE(CLASS, NAME) \
119 const tgui::Texture& CLASS::get##NAME() const \
121 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
122 if (it != m_data->propertyValuePairs.end()) \
123 return it->second.getTexture(); \
126 m_data->propertyValuePairs[tgui::String(#NAME)] = {tgui::Texture{}}; \
127 return m_data->propertyValuePairs[tgui::String(#NAME)].getTexture(); \
130 void CLASS::set##NAME(const tgui::Texture& texture) \
132 setProperty(tgui::String(#NAME), {texture}); \
137#define TGUI_RENDERER_PROPERTY_RENDERER_WITH_DEFAULT(CLASS, NAME, RENDERER, DEFAULT) \
138 std::shared_ptr<tgui::RendererData> CLASS::get##NAME() const \
140 const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
141 if (it != m_data->propertyValuePairs.end()) \
142 return it->second.getRenderer(); \
145 const auto& renderer = tgui::Theme::getDefault()->getRendererNoThrow(RENDERER); \
146 m_data->propertyValuePairs[tgui::String(#NAME)] = {renderer ? renderer : (DEFAULT)}; \
150 void CLASS::set##NAME(std::shared_ptr<tgui::RendererData> renderer) \
153 setProperty(tgui::String(#NAME), {std::move(renderer)}); \
155 setProperty(tgui::String(#NAME), {RendererData::create()}); \
158#define TGUI_RENDERER_PROPERTY_RENDERER(CLASS, NAME, RENDERER) \
159 TGUI_RENDERER_PROPERTY_RENDERER_WITH_DEFAULT(CLASS, NAME, RENDERER, tgui::RendererData::create()) \