3#include "structure/design_pattern/spk_cached_data.hpp"
4#include "structure/graphics/spk_extend_2d.hpp"
5#include "structure/math/spk_vector2.hpp"
6#include "utils/spk_math_utils.hpp"
16 class ResizableElement
38 mutable CachedData<Vector2UInt> _maximal{[]() {
39 return std::numeric_limits<Vector2UInt>::max();
99 void setMinimal(
const Vector2UInt &p_minimalValue);
104 void setDesired(
const Vector2UInt &p_desiredValue);
109 void setMaximal(
const Vector2UInt &p_maximalValue);
115 const Vector2UInt &
minimal()
const;
120 const Vector2UInt &
desired()
const;
125 const Vector2UInt &
maximal()
const;
132 ResizableElement() =
default;
134 virtual ~ResizableElement() =
default;
Lazily generates and caches a value with optional custom destructor.
Definition spk_cached_data.hpp:26
std::function< TType()> Generator
Callable used to lazily produce the cached value.
Definition spk_cached_data.hpp:33
Holds minimal, desired, and maximal size generators.
Definition spk_resizable_element.hpp:24
const Vector2UInt & minimal() const
Returns the minimal size.
Definition spk_resizable_element.cpp:73
void releaseMinimal()
Releases cached minimal size.
Definition spk_resizable_element.cpp:43
void configureMaximalGenerator(Generator p_generator)
Configures the maximal size generator.
Definition spk_resizable_element.cpp:31
void setDesired(const Vector2UInt &p_desiredValue)
Sets the desired size override.
Definition spk_resizable_element.cpp:63
const Vector2UInt & maximal() const
Returns the maximal size.
Definition spk_resizable_element.cpp:81
CachedData< Vector2UInt >::Generator Generator
Generator type used to compute size hints.
Definition spk_resizable_element.hpp:29
const Vector2UInt & desired() const
Returns the desired size.
Definition spk_resizable_element.cpp:77
void configureDesiredGenerator(Generator p_generator)
Configures the desired size generator.
Definition spk_resizable_element.cpp:26
void setMaximal(const Vector2UInt &p_maximalValue)
Sets the maximal size override.
Definition spk_resizable_element.cpp:68
void release()
Releases all cached size hint values.
Definition spk_resizable_element.cpp:36
void setMinimal(const Vector2UInt &p_minimalValue)
Sets the minimal size override.
Definition spk_resizable_element.cpp:58
void releaseDesired()
Releases cached desired size.
Definition spk_resizable_element.cpp:48
void configure(Generator p_minimalGenerator, Generator p_desiredGenerator, Generator p_maximalGenerator)
Configures all size hint generators.
Definition spk_resizable_element.cpp:14
void releaseMaximal()
Releases cached maximal size.
Definition spk_resizable_element.cpp:53
void configureMinimalGenerator(Generator p_generator)
Configures the minimal size generator.
Definition spk_resizable_element.cpp:21
virtual void setGeometry(const Extend2D &p_extend)=0
Sets the element geometry.
SizeHint & sizeHint()
Returns mutable size hint data.
Definition spk_resizable_element.cpp:86
Axis-aligned rectangle defined by an anchor point and size.
Definition spk_extend_2d.hpp:24
static const IVector2 Zero
Definition spk_vector2.hpp:96