23#include "guillaume/components/layout.hpp"
44 return _mainAxisAlignment;
49 if (_mainAxisAlignment == alignment) {
52 _mainAxisAlignment = alignment;
59 return _crossAxisAlignment;
64 if (_crossAxisAlignment == alignment) {
67 _crossAxisAlignment = alignment;
79 if (_spacing == spacing) {
94 if (_padding == padding) {
104 return _hasFixedWidth;
114 if (_hasFixedWidth && _fixedWidth == width) {
117 _hasFixedWidth =
true;
125 if (!_hasFixedWidth) {
128 _hasFixedWidth =
false;
136 return _hasFixedHeight;
146 if (_hasFixedHeight && _fixedHeight == height) {
149 _hasFixedHeight =
true;
150 _fixedHeight = height;
157 if (!_hasFixedHeight) {
160 _hasFixedHeight =
false;
172 const std::vector<ecs::Entity::Identifier> &children)
174 if (_children == children) {
177 _children = children;
184 _children.push_back(child);
191 if (_children.empty()) {
bool hasFixedHeight(void) const
Check whether the container height is forced.
Layout & setFixedWidth(float width)
Force the container width instead of wrapping the children.
CrossAxisAlignment getCrossAxisAlignment(void) const
Get the alignment along the cross axis.
Layout & setChildren(const std::vector< ecs::Entity::Identifier > &children)
Replace the list of children to arrange.
Layout & setAxis(Axis axis)
Choose between a row and a column.
float getSpacing(void) const
Get the gap between two consecutive children.
Layout & setPadding(float padding)
Set the inset between the container's edges and its children.
Layout & setMainAxisAlignment(MainAxisAlignment alignment)
Set where the children go along the main axis.
const std::vector< ecs::Entity::Identifier > & getChildren(void) const
Get the children systems::Layout arranges, in order.
float getPadding(void) const
Get the inset between the container's edges and its children.
Layout(void)=default
Default constructor for the Layout component.
float getFixedWidth(void) const
Get the forced container width.
Layout & clearFixedWidth(void)
Let the width wrap the children again.
CrossAxisAlignment
Where each child goes along the cross axis, inside the padding. In a container that wraps its childre...
Layout & clearFixedHeight(void)
Let the height wrap the children again.
float getFixedHeight(void) const
Get the forced container height.
Layout & clearChildren(void)
Empty the list of children; the entities themselves are left untouched.
Layout & setFixedHeight(float height)
Force the container height instead of wrapping the children.
bool hasFixedWidth(void) const
Check whether the container width is forced.
Layout & addChild(ecs::Entity::Identifier child)
Add a child at the end of the list.
MainAxisAlignment getMainAxisAlignment(void) const
Get the alignment along the main axis.
Layout & setCrossAxisAlignment(CrossAxisAlignment alignment)
Set where each child goes along the cross axis.
MainAxisAlignment
Where the children go along the main axis when the container is larger than them.
Axis getAxis(void) const
Get the main axis.
Axis
Direction along which children are arranged.
Layout & setSpacing(float spacing)
Set the gap between two consecutive children.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
State. Every class here is plain data attached to an entity.