MyGUI 3.4.3
MyGUI_CommonStateInfo.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_COMMON_STATE_INFO_H_
8#define MYGUI_COMMON_STATE_INFO_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_IStateInfo.h"
15
16namespace MyGUI
17{
18
20 {
22
23 public:
24 const FloatRect& getRect() const
25 {
26 return mRect;
27 }
28
29 private:
30 void deserialization(xml::ElementPtr _node, Version _version) override
31 {
32 std::string texture{_node->getParent()->getParent()->findAttribute("texture")};
33
34 // tags replacement support for Skins
35 if (_version >= Version(1, 1))
36 {
37 texture = LanguageManager::getInstance().replaceTags(texture);
38 }
39
40 const IntSize& size = texture_utility::getTextureSize(texture);
41 IntCoord coord = IntCoord::parse(_node->findAttribute("offset"));
42 mRect = CoordConverter::convertTextureCoord(coord, size);
43 }
44
45 private:
46 FloatRect mRect;
47 };
48
50 {
52
53 public:
54 const FloatRect& getRect() const
55 {
56 return mRect;
57 }
58
59 const IntSize& getTileSize() const
60 {
61 return mTileSize;
62 }
63
64 bool getTileH() const
65 {
66 return mTileH;
67 }
68
69 bool getTileV() const
70 {
71 return mTileV;
72 }
73
74 private:
75 void deserialization(xml::ElementPtr _node, Version _version) override
76 {
77 std::string texture{_node->getParent()->getParent()->findAttribute("texture")};
78
79 // tags replacement support for Skins
80 if (_version >= Version(1, 1))
81 {
82 texture = LanguageManager::getInstance().replaceTags(texture);
83 }
84
85 const IntSize& size = texture_utility::getTextureSize(texture);
86 IntCoord coord = IntCoord::parse(_node->findAttribute("offset"));
87 mRect = CoordConverter::convertTextureCoord(coord, size);
88
89 xml::ElementEnumerator prop = _node->getElementEnumerator();
90 while (prop.next("Property"))
91 {
92 std::string_view key = prop->findAttribute("key");
93 std::string_view value = prop->findAttribute("value");
94 if (key == "TileH")
95 mTileH = utility::parseBool(value);
96 else if (key == "TileV")
97 mTileV = utility::parseBool(value);
98 else if (key == "TileSize")
99 mTileSize = IntSize::parse(value);
100 }
101 }
102
103 private:
104 FloatRect mRect;
105 IntSize mTileSize;
106 bool mTileH{true};
107 bool mTileV{true};
108 };
109
111 {
113
114 public:
115 float getAngle() const
116 {
117 return mAngle;
118 }
119
120 const IntPoint& getCenter() const
121 {
122 return mCenter;
123 }
124
125 const FloatRect& getRect() const
126 {
127 return mRect;
128 }
129
130 private:
131 void deserialization(xml::ElementPtr _node, Version _version) override
132 {
134 while (prop.next("Property"))
135 {
136 std::string_view key = prop->findAttribute("key");
137 std::string_view value = prop->findAttribute("value");
138 if (key == "Angle")
139 mAngle = utility::parseFloat(value);
140 if (key == "Center")
141 mCenter = IntPoint::parse(value);
142 }
143
144 std::string texture{_node->getParent()->getParent()->findAttribute("texture")};
145
146 // tags replacement support for Skins
147 if (_version >= Version(1, 1))
148 {
149 texture = LanguageManager::getInstance().replaceTags(texture);
150 }
151
152 const IntSize& size = texture_utility::getTextureSize(texture);
153 IntCoord coord = IntCoord::parse(_node->findAttribute("offset"));
154 mRect = CoordConverter::convertTextureCoord(coord, size);
155 }
156
157 private:
158 FloatRect mRect;
159 IntPoint mCenter;
160 float mAngle{0}; // Angle in radians
161 };
162
163
165 {
167
168 public:
169 const Colour& getColour() const
170 {
171 return mColour;
172 }
173
174 bool getShift() const
175 {
176 return mShift;
177 }
178
179 private:
180 void deserialization(xml::ElementPtr _node, Version _version) override
181 {
182 mShift = utility::parseBool(_node->findAttribute("shift"));
183
184 std::string colour{_node->findAttribute("colour")};
185 if (_version >= Version(1, 1))
186 {
187 colour = LanguageManager::getInstance().replaceTags(colour);
188 }
189
190 mColour = Colour::parse(colour);
191 }
192
193 private:
194 Colour mColour{Colour::White};
195 bool mShift{false};
196 };
197
198} // namespace MyGUI
199
200#endif // MYGUI_COMMON_STATE_INFO_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
const Colour & getColour() const
const IntPoint & getCenter() const
const FloatRect & getRect() const
const FloatRect & getRect() const
const FloatRect & getRect() const
const IntSize & getTileSize() const
bool findAttribute(std::string_view _name, std::string &_value)
ElementEnumerator getElementEnumerator()
ElementPtr getParent() const
bool parseBool(std::string_view _value)
float parseFloat(std::string_view _value)
Element * ElementPtr
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
types::TRect< float > FloatRect
Definition MyGUI_Types.h:34
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
static TPoint< int > parse(std::string_view _value)