TGUI 1.13
Loading...
Searching...
No Matches
RelFloatRect.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 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_REL_FLOAT_RECT_HPP
26#define TGUI_REL_FLOAT_RECT_HPP
27
28#include <TGUI/AbsoluteOrRelativeValue.hpp>
29#include <TGUI/Rect.hpp>
30
32
33namespace tgui
34{
38 struct TGUI_API RelFloatRect
39 {
43 constexpr RelFloatRect() = default;
44
57 m_left{left},
58 m_top{top},
59 m_width{width},
60 m_height{height}
61 {
62 }
63
67 [[nodiscard]] constexpr float getLeft() const
68 {
69 return m_left.getValue();
70 }
71
75 [[nodiscard]] constexpr float getTop() const
76 {
77 return m_top.getValue();
78 }
79
83 [[nodiscard]] constexpr float getWidth() const
84 {
85 return m_width.getValue();
86 }
87
91 [[nodiscard]] constexpr float getHeight() const
92 {
93 return m_height.getValue();
94 }
95
99 [[nodiscard]] constexpr Vector2f getPosition() const
100 {
101 return {m_left.getValue(), m_top.getValue()};
102 }
103
107 [[nodiscard]] constexpr Vector2f getSize() const
108 {
109 return {m_width.getValue(), m_height.getValue()};
110 }
111
115 [[nodiscard]] constexpr FloatRect getRect() const
116 {
117 return {m_left.getValue(), m_top.getValue(), m_width.getValue(), m_height.getValue()};
118 }
119
126 constexpr void updateParentSize(Vector2f newParentSize)
127 {
128 m_left.updateParentSize(newParentSize.x);
129 m_top.updateParentSize(newParentSize.y);
130 m_width.updateParentSize(newParentSize.x);
131 m_height.updateParentSize(newParentSize.y);
132 }
133
134 private:
135 AbsoluteOrRelativeValue m_left;
136 AbsoluteOrRelativeValue m_top;
137 AbsoluteOrRelativeValue m_width;
138 AbsoluteOrRelativeValue m_height;
139 };
140} // namespace tgui
141
142#endif // TGUI_REL_FLOAT_RECT_HPP
Class to store the a value that is either a constant or a ratio.
Definition AbsoluteOrRelativeValue.hpp:44
T y
Y coordinate of the vector.
Definition Vector2.hpp:136
T x
X coordinate of the vector.
Definition Vector2.hpp:135
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
constexpr RelFloatRect()=default
Default constructor.
constexpr Vector2f getSize() const
Returns the size of the rect as an absolute value.
Definition RelFloatRect.hpp:107
constexpr float getTop() const
Returns the top position of the rect as an absolute value.
Definition RelFloatRect.hpp:75
constexpr FloatRect getRect() const
Returns the the rectangle as an absolute value.
Definition RelFloatRect.hpp:115
constexpr Vector2f getPosition() const
Returns the size of the rect as an absolute value.
Definition RelFloatRect.hpp:99
constexpr float getLeft() const
Returns the left position of the rect as an absolute value.
Definition RelFloatRect.hpp:67
constexpr float getWidth() const
Returns the width of the rect as an absolute value.
Definition RelFloatRect.hpp:83
constexpr RelFloatRect(AbsoluteOrRelativeValue left, AbsoluteOrRelativeValue top, AbsoluteOrRelativeValue width, AbsoluteOrRelativeValue height)
Constructs the rectangle from its position and size.
Definition RelFloatRect.hpp:53
constexpr float getHeight() const
Returns the height of the rect as an absolute value.
Definition RelFloatRect.hpp:91