TGUI  0.7.4
Transformable.hpp
1 //
3 // TGUI - Texus's 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/Global.hpp>
30 #include <TGUI/Layout.hpp>
31 
33 
34 namespace tgui
35 {
36  class TGUI_API Transformable
37  {
38  public:
39 
41  // Default constructor
43  Transformable() = default;
44 
46  // Copy constructor
48  Transformable(const Transformable& other);
49 
51  // Copy assignment operator
53  Transformable& operator=(const Transformable& other);
54 
55 
59  virtual ~Transformable() = default;
60 
61 
86  virtual void setPosition(const Layout2d& position);
87 
88 
114  void setPosition(const Layout& x, const Layout& y)
115  {
116  setPosition({x, y});
117  }
118 
119 
128  sf::Vector2f getPosition() const
129  {
130  return m_position.getValue();
131  }
132 
133 
148  void move(const Layout2d& offset);
149 
150 
166  void move(const Layout& x, const Layout& y);
167 
168 
187  virtual void setSize(const Layout2d& size);
188 
189 
209  void setSize(const Layout& width, const Layout& height)
210  {
211  setSize({width, height});
212  }
213 
214 
221  virtual sf::Vector2f getSize() const
222  {
223  return m_size.getValue();
224  }
225 
226 
236  virtual sf::Vector2f getFullSize() const
237  {
238  return getSize();
239  }
240 
241 
254  void scale(const Layout2d& factors);
255 
256 
270  void scale(const Layout& x, const Layout& y);
271 
272 
278  Layout2d getPositionLayout() const
279  {
280  return m_position;
281  }
282 
283 
289  Layout2d getSizeLayout() const
290  {
291  return m_size;
292  }
293 
294 
296  protected:
297 
299  // Updates the position
301  void updatePosition(bool forceUpdate = true);
302 
303 
305  // Updates the size
307  void updateSize(bool forceUpdate = true);
308 
309 
311  protected:
312 
313  Layout2d m_position;
314  Layout2d m_size;
315 
316  sf::Vector2f m_prevPosition;
317  sf::Vector2f m_prevSize;
318 
320  };
321 
323 }
324 
326 
327 #endif // TGUI_TRANSFORMABLE_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Definition: Transformable.hpp:36
void setSize(const Layout &width, const Layout &height)
Changes the size of the widget.
Definition: Transformable.hpp:209
Class to store the position or size of a widget.
Definition: Layout.hpp:262
void setPosition(const Layout &x, const Layout &y)
set the position of the widget
Definition: Transformable.hpp:114
Class to store the left, top, width or height of a widget.
Definition: Layout.hpp:120
virtual sf::Vector2f getSize() const
Returns the size of the widget.
Definition: Transformable.hpp:221
virtual sf::Vector2f getFullSize() const
Returns the entire size that the widget is using.
Definition: Transformable.hpp:236
sf::Vector2f getPosition() const
get the position of the widget
Definition: Transformable.hpp:128