TGUI  1.3-dev
Loading...
Searching...
No Matches
RelFloatRect.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 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_REL_FLOAT_RECT_HPP
27#define TGUI_REL_FLOAT_RECT_HPP
28
29
30#include <TGUI/AbsoluteOrRelativeValue.hpp>
31#include <TGUI/Rect.hpp>
32
34
35TGUI_MODULE_EXPORT namespace tgui
36{
41 {
45 constexpr RelFloatRect() = default;
46
47
58 m_left{left},
59 m_top{top},
60 m_width{width},
61 m_height{height}
62 {
63 }
64
65
69 TGUI_NODISCARD constexpr float getLeft() const
70 {
71 return m_left.getValue();
72 }
73
74
78 TGUI_NODISCARD constexpr float getTop() const
79 {
80 return m_top.getValue();
81 }
82
83
87 TGUI_NODISCARD constexpr float getWidth() const
88 {
89 return m_width.getValue();
90 }
91
92
96 TGUI_NODISCARD constexpr float getHeight() const
97 {
98 return m_height.getValue();
99 }
100
104 TGUI_NODISCARD constexpr Vector2f getPosition() const
105 {
106 return {m_left.getValue(), m_top.getValue()};
107 }
108
109
113 TGUI_NODISCARD constexpr Vector2f getSize() const
114 {
115 return {m_width.getValue(), m_height.getValue()};
116 }
117
118
122 TGUI_NODISCARD constexpr FloatRect getRect() const
123 {
124 return {m_left.getValue(), m_top.getValue(), m_width.getValue(), m_height.getValue()};
125 }
126
127
134 constexpr void updateParentSize(Vector2f newParentSize)
135 {
136 m_left.updateParentSize(newParentSize.x);
137 m_top.updateParentSize(newParentSize.y);
138 m_width.updateParentSize(newParentSize.x);
139 m_height.updateParentSize(newParentSize.y);
140 }
141
143 private:
144
145 AbsoluteOrRelativeValue m_left;
146 AbsoluteOrRelativeValue m_top;
147 AbsoluteOrRelativeValue m_width;
148 AbsoluteOrRelativeValue m_height;
149 };
150}
151
153
154#endif // TGUI_REL_FLOAT_RECT_HPP
Class to store the a value that is either a constant or a ratio.
Definition AbsoluteOrRelativeValue.hpp:46
TGUI_NODISCARD constexpr float getValue() const
Returns the value.
Definition AbsoluteOrRelativeValue.hpp:104
T y
Y coordinate of the vector.
Definition Vector2.hpp:139
T x
X coordinate of the vector.
Definition Vector2.hpp:138
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
FloatRect that can contain absolute values or values relative to the parent size.
Definition RelFloatRect.hpp:41
constexpr RelFloatRect()=default
Default constructor.
TGUI_NODISCARD constexpr FloatRect getRect() const
Returns the the rectangle as an absolute value.
Definition RelFloatRect.hpp:122
TGUI_NODISCARD constexpr Vector2f getPosition() const
Returns the size of the rect as an absolute value.
Definition RelFloatRect.hpp:104
TGUI_NODISCARD constexpr float getHeight() const
Returns the height of the rect as an absolute value.
Definition RelFloatRect.hpp:96
TGUI_NODISCARD constexpr float getLeft() const
Returns the left position of the rect as an absolute value.
Definition RelFloatRect.hpp:69
TGUI_NODISCARD constexpr float getWidth() const
Returns the width of the rect as an absolute value.
Definition RelFloatRect.hpp:87
constexpr RelFloatRect(AbsoluteOrRelativeValue left, AbsoluteOrRelativeValue top, AbsoluteOrRelativeValue width, AbsoluteOrRelativeValue height)
Constructs the rectangle from its position and size.
Definition RelFloatRect.hpp:56
TGUI_NODISCARD constexpr float getTop() const
Returns the top position of the rect as an absolute value.
Definition RelFloatRect.hpp:78
TGUI_NODISCARD constexpr Vector2f getSize() const
Returns the size of the rect as an absolute value.
Definition RelFloatRect.hpp:113