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 
40  // Default constructor
42  Transformable() = default;
43 
45  // Copy constructor
47  Transformable(const Transformable& copy);
48 
50  // Copy assignment operator
52  Transformable& operator=(const Transformable& right);
53 
54 
58  virtual ~Transformable() = default;
59 
60 
85  virtual void setPosition(const Layout2d& position);
86 
87 
113  void setPosition(const Layout& x, const Layout& y)
114  {
115  setPosition({x, y});
116  }
117 
118 
127  sf::Vector2f getPosition() const
128  {
129  return m_position.getValue();
130  }
131 
132 
147  void move(const Layout2d& offset);
148 
149 
165  void move(const Layout& x, const Layout& y);
166 
167 
186  virtual void setSize(const Layout2d& size);
187 
188 
208  void setSize(const Layout& width, const Layout& height)
209  {
210  setSize({width, height});
211  }
212 
213 
220  virtual sf::Vector2f getSize() const
221  {
222  return m_size.getValue();
223  }
224 
225 
235  virtual sf::Vector2f getFullSize() const
236  {
237  return getSize();
238  }
239 
240 
253  void scale(const Layout2d& factors);
254 
255 
269  void scale(const Layout& x, const Layout& y);
270 
271 
277  Layout2d getPositionLayout() const
278  {
279  return m_position;
280  }
281 
282 
288  Layout2d getSizeLayout() const
289  {
290  return m_size;
291  }
292 
293 
295  protected:
296 
298  // @brief Updates the position
300  void updatePosition(bool forceUpdate = true);
301 
302 
304  // @brief Updates the size
306  void updateSize(bool forceUpdate = true);
307 
308 
310  protected:
311 
312  Layout2d m_position;
313  Layout2d m_size;
314 
315  sf::Vector2f m_prevPosition;
316  sf::Vector2f m_prevSize;
317 
319  };
320 
322 }
323 
325 
326 #endif // TGUI_TRANSFORMABLE_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Definition: Transformable.hpp:35
void setSize(const Layout &width, const Layout &height)
Changes the size of the widget.
Definition: Transformable.hpp:208
Class to store the position or size of a widget.
Definition: Layout.hpp:263
void setPosition(const Layout &x, const Layout &y)
Sets the position of the widget.
Definition: Transformable.hpp:113
Class to store the left, top, width or height of a widget.
Definition: Layout.hpp:121
virtual sf::Vector2f getSize() const
Returns the size of the widget.
Definition: Transformable.hpp:220
virtual sf::Vector2f getFullSize() const
Returns the entire size that the widget is using.
Definition: Transformable.hpp:235
sf::Vector2f getPosition() const
Gets the position of the widget.
Definition: Transformable.hpp:127