TGUI  0.8-dev
Transformable.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 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_TRANSFORMABLE_HPP
26 #define TGUI_TRANSFORMABLE_HPP
27 
28 
29 #include <TGUI/Layout.hpp>
30 
32 
33 namespace tgui
34 {
35  class TGUI_API Transformable
36  {
37  public:
38 
60  virtual void setPosition(const Layout2d& position)
61  {
62  m_position = position;
63  }
64 
65 
89  {
90  setPosition({std::move(x), std::move(y)});
91  }
92 
93 
102  sf::Vector2f getPosition() const
103  {
104  return m_position.getValue();
105  }
106 
107 
123  virtual void setSize(const Layout2d& size)
124  {
125  m_size = size;
126  }
127 
128 
145  void setSize(Layout width, Layout height)
146  {
147  setSize({std::move(width), std::move(height)});
148  }
149 
150 
157  virtual sf::Vector2f getSize() const
158  {
159  return m_size.getValue();
160  }
161 
162 
172  virtual sf::Vector2f getFullSize() const
173  {
174  return getSize();
175  }
176 
177 
183  Layout2d getPositionLayout() const
184  {
185  return m_position;
186  }
187 
188 
194  Layout2d getSizeLayout() const
195  {
196  return m_size;
197  }
198 
199 
201  protected:
202 
204  // @brief Updates the position
206  void updatePosition()
207  {
208  setPosition(m_position);
209  }
210 
211 
213  // @brief Updates the size
215  void updateSize()
216  {
217  setSize(m_size);
218  }
219 
220 
222  protected:
223 
224  Layout2d m_position;
225  Layout2d m_size;
226 
228  };
229 
231 }
232 
234 
235 #endif // TGUI_TRANSFORMABLE_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Definition: Transformable.hpp:35
Class to store the position or size of a widget.
Definition: Layout.hpp:205
void setPosition(Layout x, Layout y)
Sets the position of the widget.
Definition: Transformable.hpp:88
Class to store the left, top, width or height of something.
Definition: Layout.hpp:45
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Definition: Transformable.hpp:123
virtual sf::Vector2f getSize() const
Returns the size of the widget.
Definition: Transformable.hpp:157
virtual void setPosition(const Layout2d &position)
Sets the position of the widget.
Definition: Transformable.hpp:60
void setSize(Layout width, Layout height)
Changes the size of the widget.
Definition: Transformable.hpp:145
virtual sf::Vector2f getFullSize() const
Returns the entire size that the widget is using.
Definition: Transformable.hpp:172
sf::Vector2f getPosition() const
Gets the position of the widget.
Definition: Transformable.hpp:102