TGUI  0.8.9
FloatRect.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2020 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
26#ifndef TGUI_FLOAT_RECT_HPP
27#define TGUI_FLOAT_RECT_HPP
28
29#include <TGUI/Config.hpp>
30#include <SFML/Graphics/Rect.hpp>
31
33
34namespace tgui
35{
36 class FloatRect : public sf::FloatRect
37 {
38 public:
39
43 FloatRect() = default;
44
45
51 FloatRect(sf::FloatRect rect) :
52 sf::FloatRect{rect}
53 {
54 }
55
56
65 FloatRect(float rectLeft, float rectTop, float rectWidth, float rectHeight) :
66 sf::FloatRect{rectLeft, rectTop, rectWidth, rectHeight}
67 {
68 }
69
70
77 FloatRect(Vector2f position, Vector2f size) :
78 sf::FloatRect{position, size}
79 {
80 }
81
82
88 void setPosition(Vector2f position)
89 {
90 left = position.x;
91 top = position.y;
92 }
93
94
101 {
102 return {left, top};
103 }
104
105
111 void setSize(Vector2f size)
112 {
113 width = size.x;
114 height = size.y;
115 }
116
117
124 {
125 return {width, height};
126 }
127 };
128}
129
131
132#endif // TGUI_FLOAT_RECT_HPP
Definition: FloatRect.hpp:37
FloatRect(float rectLeft, float rectTop, float rectWidth, float rectHeight)
Constructs the rectangle from its position and size.
Definition: FloatRect.hpp:65
Vector2f getPosition() const
Returns the position of the rectangle.
Definition: FloatRect.hpp:100
FloatRect()=default
Default constructor.
FloatRect(Vector2f position, Vector2f size)
Constructs the rectangle from its position and size.
Definition: FloatRect.hpp:77
Vector2f getSize() const
Returns the size of the rectangle.
Definition: FloatRect.hpp:123
FloatRect(sf::FloatRect rect)
Constructs the rectangle from an sf::FloatRect.
Definition: FloatRect.hpp:51
void setPosition(Vector2f position)
Sets the position of the rectangle.
Definition: FloatRect.hpp:88
void setSize(Vector2f size)
Sets the size of the rectangle.
Definition: FloatRect.hpp:111
Definition: Vector2f.hpp:39
float x
X coordinate of the vector.
Definition: Vector2f.hpp:122
float y
Y coordinate of the vector.
Definition: Vector2f.hpp:123
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37