30#include <utility/graphic/color.hpp>
32#include "guillaume/ecs/component_registry.hpp"
33#include "guillaume/entities/builder_base.hpp"
34#include "guillaume/ecs/entity.hpp"
35#include "guillaume/ecs/entity_builder.hpp"
36#include "guillaume/ecs/parent_entity_filler.hpp"
38#include "guillaume/components/borders.hpp"
39#include "guillaume/components/bound.hpp"
40#include "guillaume/components/color.hpp"
41#include "guillaume/components/layout.hpp"
42#include "guillaume/components/transform.hpp"
99 public std::enable_shared_from_this<View>,
101 components::Transform, components::Bound,
102 components::Color, components::Borders>
120 utility::graphic::PoseF _pose;
121 utility::graphic::Color32Bit _color;
130 bool _hasFixedHeight;
133 std::vector<std::shared_ptr<ecs::Entity>>
163 void reset(
void)
override;
256 const std::vector<std::shared_ptr<ecs::Entity>> &
entities);
273 std::shared_ptr<Entity> parent,
274 const utility::graphic::PoseF &pose,
275 const std::vector<std::shared_ptr<ecs::Entity>> &
entities);
290 std::shared_ptr<Entity> parent,
291 const utility::graphic::PoseF &pose,
292 const utility::graphic::Color32Bit &color,
293 const std::vector<std::shared_ptr<ecs::Entity>> &
entities);
309 template<
typename... Arguments>
310 static std::shared_ptr<View>
create(Arguments &&...arguments)
312 std::shared_ptr<View> entity(
313 new View(std::forward<Arguments>(arguments)...));
328 View &
setPose(
const utility::graphic::PoseF &pose);
336 View &
setColor(
const utility::graphic::Color32Bit &color);
433 const std::vector<std::shared_ptr<ecs::Entity>> &
entities);
442 void applyGeometry(
void);
469 const utility::graphic::PoseF &pose,
470 const utility::graphic::Color32Bit &color,
float borderRadius,
473 float padding,
bool hasFixedWidth,
float fixedWidth,
474 bool hasFixedHeight,
float fixedHeight,
475 const std::vector<std::shared_ptr<ecs::Entity>> &
entities);
CrossAxisAlignment
Where each child goes along the cross axis, inside the padding. In a container that wraps its childre...
MainAxisAlignment
Where the children go along the main axis when the container is larger than them.
Axis
Direction along which children are arranged.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
The base class of a widget with children: an EntityFiller that is also a ParentEntity.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Builder & withMainAxisAlignment(MainAxisAlignment alignment)
Set how the children are distributed along the axis.
Builder & withCrossAxisAlignment(CrossAxisAlignment alignment)
Set how each child is aligned across the axis.
Builder & withColor(const utility::graphic::Color32Bit &color)
Set the background color.
Builder & withEntities(const std::vector< std::shared_ptr< ecs::Entity > > &entities)
Set the entities the view arranges, in layout order.
void reset(void) override
Restore the defaults: default pose, transparent background, corner radius 16 dp, horizontal axis,...
Builder & withSpacing(float spacing)
Set the gap between two consecutive children.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
Builder & withBorderRadius(float borderRadius)
Set the corner radius of the background.
Builder & withFixedWidth(float width)
Force the width of the view.
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the view is.
Builder & withFixedHeight(float height)
Force the height of the view.
std::shared_ptr< View > buildEntity(void) override
Build a view from the current configuration, without registering it or giving it a parent.
Builder & withPadding(float padding)
Set the space between the edges of the view and its children.
std::shared_ptr< View > makeDefaultView(std::shared_ptr< Entity > parent, const utility::graphic::PoseF &pose, const std::vector< std::shared_ptr< ecs::Entity > > &entities)
Build a transparent view, register it under parent and reset the builder.
Builder & withAxis(Axis axis)
Choose between a row and a column.
std::shared_ptr< View > makeColorView(std::shared_ptr< Entity > parent, const utility::graphic::PoseF &pose, const utility::graphic::Color32Bit &color, const std::vector< std::shared_ptr< ecs::Entity > > &entities)
Build a view with a background color, register it under parent and reset the builder.
A rectangle, colored or transparent, that lays its children out in a row or a column.
components::Layout::Axis Axis
components::Layout::CrossAxisAlignment CrossAxisAlignment
How each child is aligned across the axis.
View & setAxis(Axis axis)
Choose between a row and a column. Arranges the children at once.
components::Layout::MainAxisAlignment MainAxisAlignment
How the children are distributed along the axis.
View & setPadding(float padding)
Set the space between the edges of the view and its children. Arranges the children at once.
View & clearFixedWidth(void)
Let the width follow the children again: their extent plus the padding. Arranges the children at once...
View & setEntities(const std::vector< std::shared_ptr< ecs::Entity > > &entities)
Replace the entities the view arranges.
View & setColor(const utility::graphic::Color32Bit &color)
Set the background color.
View & setCrossAxisAlignment(CrossAxisAlignment alignment)
Set how each child is aligned across the axis. Arranges the children at once.
View & setFixedHeight(float height)
Force the height of the view, whatever its children. Arranges the children at once.
View & setFixedWidth(float width)
Force the width of the view, whatever its children. Arranges the children at once.
View & setMainAxisAlignment(MainAxisAlignment alignment)
Set how the children are distributed along the axis. Arranges the children at once.
View & setPose(const utility::graphic::PoseF &pose)
Move the view. Moves its layout children at once.
static std::shared_ptr< View > create(Arguments &&...arguments)
Build a view without registering it in an entity registry.
View & setSpacing(float spacing)
Set the gap between two consecutive children. Arranges the children at once.
View & clearFixedHeight(void)
Let the height follow the children again: their extent plus the padding. Arranges the children at onc...
View & setBorderRadius(float borderRadius)
Set the corner radius of the background.
Widgets: the classes used to create entities with the right components and children.