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 "structure/widget/spk_resizable_element.hpp"
23 class Layout :
public ResizableElement
55 spk::Vector2UInt _padding{};
101 void setPadding(
const spk::Vector2UInt &p_padding);
106 const spk::Vector2UInt &
padding()
const;
120 template <
typename TExtra>
123 if (p_element ==
nullptr)
125 throw std::runtime_error(
"Can't add a nullptr to a layout");
141 std::string toString(
const Layout::SizePolicy &p_sizePolicy);
142 std::wstring toWstring(
const Layout::SizePolicy &p_sizePolicy);
146 std::ostream &operator<<(std::ostream &p_stream,
const Layout::SizePolicy &p_sizePolicy);
147 std::wostream &operator<<(std::wostream &p_stream,
const Layout::SizePolicy &p_sizePolicy);
void addElement(ResizableElement *p_element, const SizePolicy &p_sizePolicy, TExtra &&p_extra)
Adds an element with extra layout data.
Definition spk_layout.hpp:121
const ElementContainer & _elements() const
Returns the stored elements.
Definition spk_layout.cpp:33
ElementContainer _elementContainer
Stored layout elements.
Definition spk_layout.hpp:86
void setPadding(const spk::Vector2UInt &p_padding)
Sets layout padding between elements.
Definition spk_layout.cpp:5
const spk::Vector2UInt & padding() const
Returns layout padding.
Definition spk_layout.cpp:11
std::vector< Element > ElementContainer
Container type used to store elements.
Definition spk_layout.hpp:81
void clear()
Removes all elements from the layout.
Definition spk_layout.cpp:16
void release()
Releases all cached size hint values.
Definition spk_resizable_element.cpp:36
Base interface for elements that can be sized by layouts.
Definition spk_resizable_element.hpp:17
SizeHint & sizeHint()
Returns mutable size hint data.
Definition spk_resizable_element.cpp:86
Layout element entry with sizing policy and extra data.
Definition spk_layout.hpp:63
SizePolicy sizePolicy
Size policy for the element.
Definition spk_layout.hpp:71
ResizableElement * element
Pointer to the resizable element.
Definition spk_layout.hpp:67
std::any extraData
Extra data used by derived layouts.
Definition spk_layout.hpp:75
Defines sizing policies for layout elements.
Definition spk_layout.hpp:31
Value
Policy value controlling sizing behavior.
Definition spk_layout.hpp:37
Value horizontal
Horizontal size policy.
Definition spk_layout.hpp:47
Value vertical
Vertical size policy.
Definition spk_layout.hpp:51