14#include <egt/detail/alignment.h>
15#include <egt/detail/meta.h>
61 name(
"BoxSizer" + std::to_string(m_widgetid));
107 if (detail::change_if_diff<>(m_justify,
justify))
121 if (detail::change_if_diff<>(m_orient, orient))
132 if (orient() == Orientation::flex)
134 Rect result = size();
135 for (
auto& child : children())
136 result = Rect::merge(result, child->box());
138 return result.
size();
144 if (orient() == Orientation::horizontal)
146 for (
auto& child : children())
148 if (!child->align().is_set(AlignFlag::expand_horizontal))
150 width += child->box().
width();
151 height = std::max(child->box().height(), height);
157 for (
auto& child : children())
159 if (!child->align().is_set(AlignFlag::expand_vertical))
161 width = std::max(child->box().width(), width);
162 height += child->box().height();
166 width += 2. * moat();
167 height += 2. * moat();
169 if (
align().is_set(AlignFlag::expand_horizontal))
170 if (width < box().width())
171 width = box().width();
173 if (
align().is_set(AlignFlag::expand_vertical))
174 if (height < box().height())
175 height = box().height();
177 return {width, height};
187 void deserialize(Serializer::Properties& props);
205 name(
"HorizontalBoxSizer" + std::to_string(m_widgetid));
219 deserialize_leaf(props);
248 name(
"VerticalBoxSizer" + std::to_string(m_widgetid));
262 deserialize_leaf(props);
291 name(
"FlexBoxSizer" + std::to_string(m_widgetid));
313 deserialize_leaf(props);
Positions and sizes widgets by Orientation.
Definition sizer.h:49
void orient(Orientation orient)
Set the Orientation.
Definition sizer.h:119
BoxSizer(Serializer::Properties &props, bool is_derived)
EGT_NODISCARD Justification justify() const
Get the justify.
Definition sizer.h:100
EGT_NODISCARD Orientation orient() const
Get the Orientation.
Definition sizer.h:114
BoxSizer(Serializer::Properties &props)
Definition sizer.h:80
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
void justify(Justification justify)
Set the justify.
Definition sizer.h:105
BoxSizer(Orientation orient=Orientation::horizontal, Justification justify=Justification::middle)
Definition sizer.h:56
BoxSizer(Frame &parent, Orientation orient=Orientation::horizontal, Justification justify=Justification::middle)
Definition sizer.h:69
EGT_NODISCARD Size super_rect() const
Calculate the super rectangle of all the children.
Definition sizer.h:130
FlexBoxSizer helper variation of BoxSizer.
Definition sizer.h:282
FlexBoxSizer(Justification justify=Justification::middle)
Definition sizer.h:288
FlexBoxSizer(Frame &parent, Justification justify=Justification::middle)
Definition sizer.h:298
FlexBoxSizer(Serializer::Properties &props, bool is_derived)
Definition sizer.h:309
FlexBoxSizer(Serializer::Properties &props)
Definition sizer.h:302
A Frame is a Widget that has children widgets.
Definition frame.h:45
virtual void add(const std::shared_ptr< Widget > &widget)
Add a child widget.
HorizontalBoxSizer helper variation of BoxSizer.
Definition sizer.h:196
HorizontalBoxSizer(Frame &parent, Justification justify=Justification::middle)
Definition sizer.h:228
HorizontalBoxSizer(Serializer::Properties &props)
Definition sizer.h:208
HorizontalBoxSizer(Justification justify=Justification::middle)
Definition sizer.h:202
HorizontalBoxSizer(Serializer::Properties &props, bool is_derived)
Definition sizer.h:215
EGT_NODISCARD constexpr const SizeType< Dim, DimCompat > & size() const noexcept
Get the SizeType of the rectangle.
Definition geometry.h:738
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
EGT_NODISCARD constexpr Dim width() const noexcept
Get the width value.
Definition geometry.h:457
VerticalBoxSizer helper variation of BoxSizer.
Definition sizer.h:239
VerticalBoxSizer(Frame &parent, Justification justify=Justification::middle)
Definition sizer.h:271
VerticalBoxSizer(Serializer::Properties &props)
Definition sizer.h:251
VerticalBoxSizer(Serializer::Properties &props, bool is_derived)
Definition sizer.h:258
VerticalBoxSizer(Justification justify=Justification::middle)
Definition sizer.h:245
Justification
Generic justification of children flags.
Definition widgetflags.h:667
T & align(T &widget, const AlignFlags &a)
Helper to set alignment of a widget.
Definition widgetflags.h:624
Orientation
Generic orientation flags.
Definition widgetflags.h:652
int DefaultDim
Define the default dimension type used for geometry.
Definition geometry.h:34
EGT framework namespace.
Definition animation.h:24