26#ifndef TGUI_OUTLINE_HPP
27#define TGUI_OUTLINE_HPP
29#include <TGUI/Vector2.hpp>
30#include <TGUI/AbsoluteOrRelativeValue.hpp>
34TGUI_MODULE_EXPORT
namespace tgui
63 template <typename T, typename = typename std::enable_if_t<std::is_arithmetic<T>::value, T>>
99 m_left {leftBorderWidth},
100 m_top {topBorderHeight},
101 m_right {rightBorderWidth},
102 m_bottom{bottomBorderHeight}
113 TGUI_NODISCARD
constexpr float getLeft()
const
115 return m_left.getValue();
125 TGUI_NODISCARD
constexpr float getTop()
const
127 return m_top.getValue();
139 return m_right.getValue();
151 return m_bottom.getValue();
161 return {getLeft(), getTop()};
175 return (getLeft() == outline.
getLeft()) && (getTop() == outline.
getTop()) && (getRight() == outline.
getRight()) && (getBottom() == outline.
getBottom());
189 return !(*
this == outline);
200 return {getLeft() + other.
getLeft(),
201 getTop() + other.
getTop(),
213 return {getLeft() - other.
getLeft(),
214 getTop() - other.
getTop(),
226 m_left = getLeft() + other.
getLeft();
227 m_top = getTop() + other.
getTop();
228 m_right = getRight() + other.
getRight();
229 m_bottom = getBottom() + other.
getBottom();
240 m_left = getLeft() - other.
getLeft();
241 m_top = getTop() - other.
getTop();
242 m_right = getRight() - other.
getRight();
243 m_bottom = getBottom() - other.
getBottom();
255 constexpr void updateParentSize(
Vector2f newParentSize)
257 m_left.updateParentSize(newParentSize.
x);
258 m_top.updateParentSize(newParentSize.
y);
259 m_right.updateParentSize(newParentSize.
x);
260 m_bottom.updateParentSize(newParentSize.
y);
271 TGUI_NODISCARD String toString()
const
273 return U
"(" + m_left.toString() + U
", " + m_top.toString() + U
", " + m_right.toString() + U
", " + m_bottom.toString() + U
")";
280 AbsoluteOrRelativeValue m_left = 0;
281 AbsoluteOrRelativeValue m_top = 0;
282 AbsoluteOrRelativeValue m_right = 0;
283 AbsoluteOrRelativeValue m_bottom = 0;
289 using Borders = Outline;
290 using Padding = Outline;
Class to store the a value that is either a constant or a ratio.
Definition AbsoluteOrRelativeValue.hpp:46
Definition Outline.hpp:39
TGUI_NODISCARD constexpr float getRight() const
Returnes the width of the right border.
Definition Outline.hpp:137
TGUI_NODISCARD constexpr bool operator!=(const Outline &outline) const
Compares two outlines.
Definition Outline.hpp:187
TGUI_NODISCARD constexpr bool operator==(const Outline &outline) const
Compares two outlines.
Definition Outline.hpp:173
TGUI_NODISCARD constexpr float getLeft() const
Returnes the width of the left border.
Definition Outline.hpp:113
constexpr Outline & operator-=(const Outline &other)
Subtracts an outline from this instance.
Definition Outline.hpp:238
constexpr Outline(AbsoluteOrRelativeValue leftBorderWidth, AbsoluteOrRelativeValue topBorderHeight, AbsoluteOrRelativeValue rightBorderWidth, AbsoluteOrRelativeValue bottomBorderHeight)
Constructor that initializes the outline.
Definition Outline.hpp:98
constexpr Outline(AbsoluteOrRelativeValue width, AbsoluteOrRelativeValue height)
Constructor that initializes the outline.
Definition Outline.hpp:80
constexpr Outline & operator+=(const Outline &other)
Adds an outline to this instance (e.g. to add padding and borders)
Definition Outline.hpp:224
TGUI_NODISCARD constexpr float getBottom() const
Returnes the height of the bottom border.
Definition Outline.hpp:149
TGUI_NODISCARD constexpr float getTop() const
Returnes the height of the top border.
Definition Outline.hpp:125
constexpr Outline(T size)
Constructor that initializes the outline.
Definition Outline.hpp:64
TGUI_NODISCARD constexpr Vector2f getOffset() const
Returnes the width of the left and top borders.
Definition Outline.hpp:159
TGUI_NODISCARD constexpr Outline operator+(const Outline &other) const
Adds two outlines together (e.g. to add padding and borders)
Definition Outline.hpp:198
constexpr Outline(AbsoluteOrRelativeValue size=0)
Default constructor that initializes the outline.
Definition Outline.hpp:48
TGUI_NODISCARD constexpr Outline operator-(const Outline &other) const
Subtracts two outlines from each other.
Definition Outline.hpp:211
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