TGUI
=
=
Download
Tutorials
1.x
0.9
0.8
Documentation
1.x
0.9
0.8
Examples
1.x
0.9
0.8
Community
TGUI
1.x-dev
Toggle main menu visibility
Loading...
Searching...
No Matches
include
TGUI
RendererDefines.hpp
1
2
//
3
// TGUI - Texus' Graphical User Interface
4
// Copyright (C) 2012-2026 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
#ifndef TGUI_RENDERER_DEFINES_HPP
26
#define TGUI_RENDERER_DEFINES_HPP
27
28
#include <TGUI/Loading/Theme.hpp>
29
31
32
#define TGUI_RENDERER_PROPERTY_OUTLINE(CLASS, NAME) \
33
tgui::Outline CLASS::get##NAME() const \
34
{ \
35
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
36
if (it != m_data->propertyValuePairs.end()) \
37
return it->second.getOutline(); \
38
return {}; \
39
} \
40
void CLASS::set##NAME(const tgui::Outline& outline) \
41
{ \
42
setProperty(tgui::String(#NAME), {outline}); \
43
}
44
46
47
#define TGUI_RENDERER_PROPERTY_COLOR(CLASS, NAME, DEFAULT) \
48
tgui::Color CLASS::get##NAME() const \
49
{ \
50
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
51
if (it != m_data->propertyValuePairs.end()) \
52
return it->second.getColor(); \
53
return DEFAULT; \
54
} \
55
void CLASS::set##NAME(tgui::Color color) \
56
{ \
57
setProperty(tgui::String(#NAME), {color}); \
58
}
59
61
62
#define TGUI_RENDERER_PROPERTY_TEXT_STYLE(CLASS, NAME, DEFAULT) \
63
tgui::TextStyles CLASS::get##NAME() const \
64
{ \
65
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
66
if (it != m_data->propertyValuePairs.end()) \
67
return it->second.getTextStyle(); \
68
return DEFAULT; \
69
} \
70
void CLASS::set##NAME(tgui::TextStyles style) \
71
{ \
72
setProperty(tgui::String(#NAME), tgui::ObjectConverter{style}); \
73
}
74
76
77
#define TGUI_RENDERER_PROPERTY_GET_NUMBER(CLASS, NAME, DEFAULT) \
78
float CLASS::get##NAME() const \
79
{ \
80
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
81
if (it != m_data->propertyValuePairs.end()) \
82
return it->second.getNumber(); \
83
return DEFAULT; \
84
}
85
86
#define TGUI_RENDERER_PROPERTY_NUMBER(CLASS, NAME, DEFAULT) \
87
TGUI_RENDERER_PROPERTY_GET_NUMBER(CLASS, NAME, DEFAULT) \
88
void CLASS::set##NAME(float number) \
89
{ \
90
setProperty(tgui::String(#NAME), tgui::ObjectConverter{number}); \
91
}
92
94
95
#define TGUI_RENDERER_PROPERTY_GET_BOOL(CLASS, NAME, DEFAULT) \
96
bool CLASS::get##NAME() const \
97
{ \
98
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
99
if (it != m_data->propertyValuePairs.end()) \
100
return it->second.getBool(); \
101
return DEFAULT; \
102
}
103
104
#define TGUI_RENDERER_PROPERTY_BOOL(CLASS, NAME, DEFAULT) \
105
TGUI_RENDERER_PROPERTY_GET_BOOL(CLASS, NAME, DEFAULT) \
106
void CLASS::set##NAME(bool flag) \
107
{ \
108
setProperty(tgui::String(#NAME), tgui::ObjectConverter{flag}); \
109
}
110
112
113
#define TGUI_RENDERER_PROPERTY_TEXTURE(CLASS, NAME) \
114
const tgui::Texture& CLASS::get##NAME() const \
115
{ \
116
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
117
if (it != m_data->propertyValuePairs.end()) \
118
return it->second.getTexture(); \
119
m_data->propertyValuePairs[tgui::String(#NAME)] = {tgui::Texture{}}; \
120
return m_data->propertyValuePairs[tgui::String(#NAME)].getTexture(); \
121
} \
122
void CLASS::set##NAME(const tgui::Texture& texture) \
123
{ \
124
setProperty(tgui::String(#NAME), {texture}); \
125
}
126
128
129
#define TGUI_RENDERER_PROPERTY_RENDERER_WITH_DEFAULT(CLASS, NAME, RENDERER, DEFAULT) \
130
std::shared_ptr<tgui::RendererData> CLASS::get##NAME() const \
131
{ \
132
const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \
133
if (it != m_data->propertyValuePairs.end()) \
134
return it->second.getRenderer(); \
135
const auto& renderer = tgui::Theme::getDefault()->getRendererNoThrow(RENDERER); \
136
m_data->propertyValuePairs[tgui::String(#NAME)] = {renderer ? renderer : (DEFAULT)}; \
137
return renderer; \
138
} \
139
void CLASS::set##NAME(std::shared_ptr<tgui::RendererData> renderer) \
140
{ \
141
if (renderer) \
142
setProperty(tgui::String(#NAME), {std::move(renderer)}); \
143
else \
144
setProperty(tgui::String(#NAME), {tgui::RendererData::create()}); \
145
}
146
147
#define TGUI_RENDERER_PROPERTY_RENDERER(CLASS, NAME, RENDERER) \
148
TGUI_RENDERER_PROPERTY_RENDERER_WITH_DEFAULT(CLASS, NAME, RENDERER, tgui::RendererData::create())
149
150
#endif
// TGUI_RENDERER_DEFINES_HPP
Generated on
for TGUI by
1.18.0