Class to store the a value that is either a constant or a ratio.
More...
#include <TGUI/AbsoluteOrRelativeValue.hpp>
|
|
constexpr | AbsoluteOrRelativeValue ()=default |
| | Default constructor.
|
| |
| template<typename T , typename = typename std::enable_if_t<std::is_arithmetic<T>::value, T>> |
| constexpr | AbsoluteOrRelativeValue (T constant) |
| | Constructor to set constant.
|
| |
| | AbsoluteOrRelativeValue (const char *expression) |
| | Construct the value from a string that either contains a value or a percentage.
|
| |
| | AbsoluteOrRelativeValue (const String &expression) |
| | Construct the value from a string that either contains a value or a percentage.
|
| |
| TGUI_NODISCARD constexpr float | getValue () const |
| | Returns the value.
|
| |
| TGUI_NODISCARD constexpr float | getRatio () const |
| | Returns the stored ratio.
|
| |
| TGUI_NODISCARD constexpr bool | isConstant () const |
| | Returns whether the value is constant or a ratio.
|
| |
|
constexpr void | updateParentSize (float newParentSize) |
| |
|
TGUI_NODISCARD String | toString () const |
| |
|
|
bool | m_constant = true |
| |
|
float | m_value = 0 |
| |
|
float | m_ratio = 0 |
| |
|
float | m_parentValue = 0 |
| |
Class to store the a value that is either a constant or a ratio.
You don't have to explicitly create an instance of this class, numbers and strings are implicitly cast.
◆ AbsoluteOrRelativeValue() [1/3]
template<typename T , typename = typename std::enable_if_t<std::is_arithmetic<T>::value, T>>
| constexpr tgui::AbsoluteOrRelativeValue::AbsoluteOrRelativeValue |
( |
T | constant | ) |
|
|
inlineconstexpr |
Constructor to set constant.
- Parameters
-
◆ AbsoluteOrRelativeValue() [2/3]
| tgui::AbsoluteOrRelativeValue::AbsoluteOrRelativeValue |
( |
const char * | expression | ) |
|
|
inline |
Construct the value from a string that either contains a value or a percentage.
- Parameters
-
◆ AbsoluteOrRelativeValue() [3/3]
| tgui::AbsoluteOrRelativeValue::AbsoluteOrRelativeValue |
( |
const String & | expression | ) |
|
|
inline |
Construct the value from a string that either contains a value or a percentage.
- Parameters
-
◆ getRatio()
| TGUI_NODISCARD constexpr float tgui::AbsoluteOrRelativeValue::getRatio |
( |
| ) |
const |
|
inlineconstexpr |
Returns the stored ratio.
- Returns
- The ratio that is multiplied with the parent size to get the value, when the value isn't a constant
◆ getValue()
| TGUI_NODISCARD constexpr float tgui::AbsoluteOrRelativeValue::getValue |
( |
| ) |
const |
|
inlineconstexpr |
Returns the value.
- Returns
- The constant value or the value based on the given ratio and parent size
◆ isConstant()
| TGUI_NODISCARD constexpr bool tgui::AbsoluteOrRelativeValue::isConstant |
( |
| ) |
const |
|
inlineconstexpr |
Returns whether the value is constant or a ratio.
- Returns
- Does the value contain a constant?
The documentation for this class was generated from the following file: