28#include <TGUI/Vector2.hpp>
30#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
31 #include <SFML/Graphics/Rect.hpp>
47 constexpr Rect() =
default;
57 top{static_cast<T>(rect.
top)},
63#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
69 explicit constexpr Rect(sf::Rect<T> rect) :
70#if SFML_VERSION_MAJOR >= 3
71 left{rect.position.x},
93 constexpr Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) :
157#if TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS && !TGUI_DISABLE_SFML_CONVERSIONS
161 explicit operator sf::Rect<T>()
const
195 const T interLeft = std::max(
left, rect.
left);
196 const T interTop = std::max(
top, rect.
top);
201 return (interLeft < interRight) && (interTop < interBottom);
216 template <
typename T>
217 [[nodiscard]]
constexpr bool operator==(
const Rect<T>& left,
const Rect<T>& right)
225 template <
typename T>
226 [[nodiscard]]
constexpr bool operator!=(
const Rect<T>& left,
const Rect<T>& right)
228 return !(left == right);
233 using FloatRect = Rect<float>;
234 using IntRect = Rect<int>;
235 using UIntRect = Rect<unsigned int>;
constexpr Rect()=default
Default constructor.
float width
Definition Rect.hpp:209
float height
Definition Rect.hpp:210
constexpr Rect(sf::Rect< T > rect)
Constructs the rectangle from an sf::Rect.
Definition Rect.hpp:69
constexpr bool intersects(const Rect< T > &rect) const
Check the intersection between two rectangles.
Definition Rect.hpp:192
constexpr Vector2< T > getSize() const
Returns the size of the rectangle.
Definition Rect.hpp:152
constexpr Rect(const Rect< U > &rect)
Constructs the rectangle from an another Rect with a different type.
Definition Rect.hpp:55
float left
Definition Rect.hpp:207
constexpr void setPosition(Vector2< T > position)
Sets the position of the rectangle.
Definition Rect.hpp:120
constexpr Vector2< T > getPosition() const
Returns the position of the rectangle.
Definition Rect.hpp:131
constexpr bool contains(const Vector2< T > &pos) const
Check if a point is inside the rectangle's area.
Definition Rect.hpp:178
float top
Definition Rect.hpp:208
constexpr void setSize(Vector2< T > size)
Sets the size of the rectangle.
Definition Rect.hpp:141
constexpr Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight)
Constructs the rectangle from its position and size.
Definition Rect.hpp:93
constexpr Rect(Vector2< T > position, Vector2< T > size)
Constructs the rectangle from its position and size.
Definition Rect.hpp:107
Definition Vector2.hpp:42
T y
Y coordinate of the vector.
Definition Vector2.hpp:144
T x
X coordinate of the vector.
Definition Vector2.hpp:143
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37