72 if (name ==
"textcolor") {
74 }
else if (name ==
"bgcolor") {
76 }
else if (name ==
"bgcolor_hovered") {
78 }
else if (name ==
"bgcolor_pressed") {
80 }
else if (name ==
"noclip") {
82 }
else if (name ==
"border") {
84 }
else if (name ==
"bgimg") {
86 }
else if (name ==
"bgimg_hovered") {
88 }
else if (name ==
"bgimg_middle") {
90 }
else if (name ==
"bgimg_pressed") {
92 }
else if (name ==
"fgimg") {
94 }
else if (name ==
"fgimg_hovered") {
96 }
else if (name ==
"fgimg_middle") {
98 }
else if (name ==
"fgimg_pressed") {
100 }
else if (name ==
"alpha") {
102 }
else if (name ==
"content_offset") {
104 }
else if (name ==
"padding") {
106 }
else if (name ==
"font") {
108 }
else if (name ==
"font_size") {
110 }
else if (name ==
"halign") {
112 }
else if (name ==
"valign") {
114 }
else if (name ==
"colors") {
116 }
else if (name ==
"bordercolors") {
118 }
else if (name ==
"borderwidths") {
120 }
else if (name ==
"sound") {
122 }
else if (name ==
"spacing") {
124 }
else if (name ==
"size") {
134 return val.empty() ? def : val;
146 if (name ==
"default") {
148 }
else if (name ==
"focused") {
150 }
else if (name ==
"hovered") {
152 }
else if (name ==
"pressed") {
180 if ((state & i) != 0) {
181 temp = temp | styles[i];
210 std::array<video::SColor, 4> def)
const
216 std::vector<std::string> strs;
220 for (
size_t i = 0; i <= 3; i++) {
235 std::vector<std::string> strs;
239 for (
size_t i = 0; i <= 3; i++)
240 def[i] =
stoi(strs[i]);
251 core::rect<s32> rect;
263 core::rect<s32> rect;
291 return v2s32(vec.X, vec.Y);
301 return v2s32(vec.X, vec.Y);
311 if (font.empty() && size.empty())
314 std::vector<std::string> modes =
split(font,
',');
316 for (
size_t i = 0; i < modes.size(); i++) {
317 if (modes[i] ==
"normal")
319 else if (modes[i] ==
"mono")
321 else if (modes[i] ==
"bold")
323 else if (modes[i] ==
"italic")
325 else if (modes[i] ==
"_no_server_media")
332 if (size[0] ==
'*') {
333 std::string new_size = size.substr(1);
335 }
else if (size[0] ==
'+' || size[0] ==
'-') {
338 calc_size =
stoi(size);
341 spec.
size = (unsigned)std::min(std::max(calc_size, 1), 999);
348 video::ITexture *def)
const
355 video::ITexture *texture = tsrc->
getTexture(val);
365 video::ITexture *texture = tsrc->
getTexture(val);
392 set(prop, other.
get(prop,
""));
407 bool parseArray(
const std::string &value, std::vector<std::string> &arr)
const
409 std::vector<std::string> strs =
split(value,
',');
411 if (strs.size() == 1) {
412 arr = {strs[0], strs[0], strs[0], strs[0]};
413 }
else if (strs.size() == 2) {
414 arr = {strs[0], strs[1], strs[0], strs[1]};
415 }
else if (strs.size() == 4) {
419 <<
" arguments): \"" << value <<
"\"" << std::endl;
425 bool parseRect(
const std::string &value, core::rect<s32> *parsed_rect)
const
427 core::rect<s32> rect;
428 std::vector<std::string> v_rect =
split(value,
',');
430 if (v_rect.size() == 1) {
431 s32
x =
stoi(v_rect[0]);
432 rect.UpperLeftCorner = core::vector2di(
x,
x);
433 rect.LowerRightCorner = core::vector2di(-
x, -
x);
434 }
else if (v_rect.size() == 2) {
435 s32
x =
stoi(v_rect[0]);
436 s32
y =
stoi(v_rect[1]);
437 rect.UpperLeftCorner = core::vector2di(
x,
y);
438 rect.LowerRightCorner = core::vector2di(-
x, -
y);
440 }
else if (v_rect.size() == 4) {
441 rect.UpperLeftCorner = core::vector2di(
443 rect.LowerRightCorner = core::vector2di(
446 warningstream <<
"Invalid rectangle string format: \"" << value
447 <<
"\"" << std::endl;
459 std::vector<std::string> v_vector =
split(value,
',');
461 if (v_vector.size() == 1) {
462 f32
x =
stof(v_vector[0]);
465 }
else if (v_vector.size() == 2) {
466 vec.X =
stof(v_vector[0]);
467 vec.Y =
stof(v_vector[1]);
469 warningstream <<
"Invalid 2d vector string format: \"" << value
470 <<
"\"" << std::endl;
Definition texturesource.h:34
virtual video::ITexture * getTexture(const std::string &name, u32 *id=nullptr)=0
Generates a texture string into a standard texture.
Definition StyleSpec.h:18
gui::IGUIFont * getFont() const
Definition StyleSpec.h:304
static State getStateByName(const std::string &name)
Parses a name and returns the corresponding state enum.
Definition StyleSpec.h:144
core::rect< s32 > getRect(Property prop, core::rect< s32 > def) const
Definition StyleSpec.h:245
video::SColor getColor(Property prop) const
Definition StyleSpec.h:199
std::array< bool, NUM_PROPERTIES > property_set
Definition StyleSpec.h:65
bool getBool(Property prop, bool def) const
Definition StyleSpec.h:370
State
Definition StyleSpec.h:55
@ STATE_HOVERED
Definition StyleSpec.h:58
@ STATE_INVALID
Definition StyleSpec.h:61
@ STATE_FOCUSED
Definition StyleSpec.h:57
@ STATE_DEFAULT
Definition StyleSpec.h:56
@ STATE_PRESSED
Definition StyleSpec.h:59
@ NUM_STATES
Definition StyleSpec.h:60
bool parseVector2f(const std::string &value, v2f32 *parsed_vec) const
Definition StyleSpec.h:456
core::rect< s32 > getRect(Property prop) const
Definition StyleSpec.h:258
State getState() const
Gets the state that this style is intended for.
Definition StyleSpec.h:160
std::string get(Property prop, std::string def) const
Definition StyleSpec.h:131
v2s32 getVector2i(Property prop) const
Definition StyleSpec.h:294
Property
Definition StyleSpec.h:21
@ FONT_SIZE
Definition StyleSpec.h:40
@ BGCOLOR_PRESSED
Definition StyleSpec.h:25
@ SOUND
Definition StyleSpec.h:46
@ BORDERCOLORS
Definition StyleSpec.h:44
@ BGIMG_PRESSED
Definition StyleSpec.h:31
@ ALPHA
Definition StyleSpec.h:36
@ BGCOLOR_HOVERED
Definition StyleSpec.h:24
@ SPACING
Definition StyleSpec.h:47
@ BGIMG_MIDDLE
Definition StyleSpec.h:30
@ NOCLIP
Definition StyleSpec.h:26
@ SIZE
Definition StyleSpec.h:48
@ PADDING
Definition StyleSpec.h:38
@ NUM_PROPERTIES
Definition StyleSpec.h:49
@ COLORS
Definition StyleSpec.h:43
@ FONT
Definition StyleSpec.h:39
@ BORDER
Definition StyleSpec.h:27
@ HALIGN
Definition StyleSpec.h:41
@ FGIMG_PRESSED
Definition StyleSpec.h:35
@ NONE
Definition StyleSpec.h:50
@ TEXTCOLOR
Definition StyleSpec.h:22
@ BGCOLOR
Definition StyleSpec.h:23
@ BGIMG
Definition StyleSpec.h:28
@ BGIMG_HOVERED
Definition StyleSpec.h:29
@ FGIMG
Definition StyleSpec.h:32
@ BORDERWIDTHS
Definition StyleSpec.h:45
@ VALIGN
Definition StyleSpec.h:42
@ FGIMG_MIDDLE
Definition StyleSpec.h:34
@ CONTENT_OFFSET
Definition StyleSpec.h:37
@ FGIMG_HOVERED
Definition StyleSpec.h:33
v2s32 getVector2i(Property prop, v2s32 def) const
Definition StyleSpec.h:281
static StyleSpec getStyleFromStatePropagation(const std::array< StyleSpec, NUM_STATES > &styles, State state)
Using a list of styles mapped to state values, calculate the final.
Definition StyleSpec.h:175
std::array< video::SColor, 4 > getColorArray(Property prop, std::array< video::SColor, 4 > def) const
Definition StyleSpec.h:209
static Property GetPropertyByName(const std::string &name)
Definition StyleSpec.h:70
bool isNotDefault(Property prop) const
Definition StyleSpec.h:380
StyleSpec operator|(const StyleSpec &other) const
Definition StyleSpec.h:399
void addState(State state)
Set the given state on this style.
Definition StyleSpec.h:166
bool parseArray(const std::string &value, std::vector< std::string > &arr) const
Definition StyleSpec.h:407
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc) const
Definition StyleSpec.h:360
bool parseRect(const std::string &value, core::rect< s32 > *parsed_rect) const
Definition StyleSpec.h:425
video::SColor getColor(Property prop, video::SColor def) const
Definition StyleSpec.h:188
State state_map
Definition StyleSpec.h:67
StyleSpec & operator|=(const StyleSpec &other)
Definition StyleSpec.h:387
void set(Property prop, const std::string &value)
Definition StyleSpec.h:137
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc, video::ITexture *def) const
Definition StyleSpec.h:347
std::array< s32, 4 > getIntArray(Property prop, std::array< s32, 4 > def) const
Definition StyleSpec.h:229
bool hasProperty(Property prop) const
Definition StyleSpec.h:385
std::array< std::string, NUM_PROPERTIES > properties
Definition StyleSpec.h:66
v2f32 getVector2f(Property prop, v2f32 def) const
Definition StyleSpec.h:268
#define FATAL_ERROR_IF(expr, msg)
Definition debug.h:35
FontEngine * g_fontengine
reference to access font engine, has to be initialized by main
Definition fontengine.cpp:21
@ FM_Standard
Regular font (settings "font_path*", overwritable).
Definition fontengine.h:29
@ FM_Mono
Monospace font (settings "mono_font*", overwritable).
Definition fontengine.h:32
#define FONT_SIZE_UNSPECIFIED
Definition fontengine.h:25
core::vector2d< f32 > v2f32
Definition irr_v2d.h:15
core::vector2d< s32 > v2s32
Definition irr_v2d.h:13
LogStream warningstream(warning_target)
bool parseColorString(const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha)
Definition string.cpp:559
#define stoi
Definition string.h:439
#define stof
Definition string.h:440
std::vector< std::basic_string< T > > split(const std::basic_string< T > &s, T delim)
Definition string.h:646
bool is_yes(std::string_view str)
Returns whether str should be regarded as (bool) true.
Definition string.h:389
Definition fontengine.h:47
bool italic
Definition fontengine.h:68
bool allow_server_media
Definition fontengine.h:69
bool bold
Definition fontengine.h:67
unsigned int size
Definition fontengine.h:65
FontMode mode
Definition fontengine.h:66
constexpr v3f x
Definition test_irr_matrix4.cpp:18
constexpr v3f y
Definition test_irr_matrix4.cpp:19