A rectangle, colored or transparent, that lays its children out in a row or a column.
More...
|
| | ~View (void) |
| | Destructor.
|
| View & | setPose (const utility::graphic::PoseF &pose) |
| | Move the view. Moves its layout children at once.
|
| View & | setColor (const utility::graphic::Color32Bit &color) |
| | Set the background color.
|
| View & | setBorderRadius (float borderRadius) |
| | Set the corner radius of the background.
|
| View & | setAxis (Axis axis) |
| | Choose between a row and a column. Arranges the children at once.
|
| View & | setMainAxisAlignment (MainAxisAlignment alignment) |
| | Set how the children are distributed along the axis. Arranges the children at once.
|
| View & | setCrossAxisAlignment (CrossAxisAlignment alignment) |
| | Set how each child is aligned across the axis. Arranges the children at once.
|
| View & | setSpacing (float spacing) |
| | Set the gap between two consecutive children. Arranges the children at once.
|
| View & | setPadding (float padding) |
| | Set the space between the edges of the view and 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 & | clearFixedWidth (void) |
| | Let the width follow the children again: their extent plus the padding. Arranges the children at once.
|
| View & | setFixedHeight (float height) |
| | Force the height of the view, whatever its 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 once.
|
| View & | setEntities (const std::vector< std::shared_ptr< ecs::Entity > > &entities) |
| | Replace the entities the view arranges.
|
| | ParentEntityFiller (ComponentRegistry &componentRegistry) |
| | Create the entity, its listed components and its components::Hierarchy. It owns no child yet.
|
|
virtual | ~ParentEntityFiller (void)=default |
| | Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity).
|
| | Entity (void) |
| | Create an entity with a fresh identifier, an empty signature, no parent and no component.
|
| virtual | ~Entity (void)=default |
| | Destroy the entity object.
|
| Entity::Identifier | getIdentifier (void) const noexcept |
| | Get the identifier of the entity.
|
| Entity::Signature | getSignature (void) const noexcept |
| | Get the set of component types the entity declares.
|
| void | setSignature (const Signature &signature) |
| | Replace the signature of the entity.
|
| std::int32_t | getLayer (void) const noexcept |
| | Get the depth of the entity in the tree.
|
| Entity & | setParent (std::shared_ptr< Entity > parent) |
| | Attach the entity under another one, or detach it.
|
| std::vector< Identifier > | releaseComponents (void) |
| | Drop the entity's place in the tree and all its components.
|
| std::shared_ptr< Entity > | getParent (void) const noexcept |
| | Get the parent entity.
|
|
| EntityRegistry (void)=default |
| | Create a registry.
|
| virtual | ~EntityRegistry (void)=default |
| | Virtual destructor.
|
| void | addEntity (std::shared_ptr< Entity > entity) |
| | Make this registry own an entity, so that it stays alive and systems visit it.
|
| bool | removeEntity (Entity::Identifier identifier) |
| | Remove an entity, with its children and all their components.
|
| void | clearEntities (void) |
| | Remove every entity owned by this registry, with everything they own and all their components.
|
| const std::vector< std::shared_ptr< Entity > > & | getEntities (void) const |
| | Get the entities this registry owns directly.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) |
| | List every entity of this registry and of the registries nested in it, level by level.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) const |
| | List every entity of this registry and of the registries nested in it, level by level (const overload).
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< EntityType > | getEntity (Entity::Identifier identifier) |
| | Find an entity owned directly by this registry, by identifier.
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< const EntityType > | getEntity (Entity::Identifier identifier) const |
| | Find an entity owned directly by this registry, by identifier (const overload).
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature) const |
| | List the entities that have every component type of a signature, from the root down.
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const |
| | List the entities that have every component type of a signature, in the order chosen by a traveler.
|
A rectangle, colored or transparent, that lays its children out in a row or a column.
View has no component of its own. Its state lives in components::Transform (pose of its top-left corner), components::Color (background), components::Borders (corner radius) and components::Layout (axis, alignments, spacing, padding, fixed size and the ordered identifiers of the children to arrange). systems::Layout holds the rules: each frame, in the Layout phase, it places every layout child along the axis and writes the size of the view into components::Bound. The class itself holds no field: its layout setters write the components and arrange the children at once.
A view is also an entity registry (ecs::ParentEntityFiller), so it can own the widgets built inside it: pass *view as the entity registry of their builder.
auto row = viewBuilder.withAxis(View::Axis::Horizontal)
.withSpacing(8.0f)
.makeDefaultView(nullptr, utility::graphic::PoseF(), {});
auto name = textBuilder.makeText(row, "Name",
row->setEntities({ name });
ComponentRegistry & getComponentRegistry(void)
Configures Text widgets and registers them in the scene's entity registry.
Configures View widgets and registers them in the scene's entity registry.
@ BodyLarge
16 / 24, regular.
utility::graphic::Color32Bit getActiveColor(SchemeColorRole role)
Get the color the active scheme gives to a role.
View::create(registry, pose, color, borderRadius, axis,
mainAxisAlignment, crossAxisAlignment, spacing, padding,
hasFixedWidth, fixedWidth, hasFixedHeight, fixedHeight, entities) builds the same widget without registering it in an entity registry.
Watch out:
- Sizes, spacing, padding and radius are in dp.
- Only the entities given to setEntities() (or to the builder) are arranged. Parenting an entity to the view is not enough.
- Attaching an entity does not make the view own it. Each child must be owned by an entity registry (the view itself or another one), or it is destroyed when the last pointer to it goes away.
- The position of each layout child and the Bound of the view are overwritten every frame. The size of a child is never changed.
- Without a fixed width or height, the view takes the size of its children plus the padding.
- See also
- components::Layout, systems::Layout, SurfaceBase
Definition at line 98 of file view.hpp.
template<typename... Arguments>
| std::shared_ptr< View > guillaume::entities::View::create |
( |
Arguments &&... | arguments | ) |
|
|
inlinestatic |
Build a view without registering it in an entity registry.
The arguments are forwarded to the private constructor: (registry, pose, color, borderRadius, axis, mainAxisAlignment,
crossAxisAlignment, spacing, padding, hasFixedWidth, fixedWidth,
hasFixedHeight, fixedHeight, entities). It then calls build(), which parents the given entities to the view and arranges them. A view creates no child of its own.
- Template Parameters
-
| Arguments | The constructor argument types. |
- Parameters
-
| arguments | The constructor arguments, as listed above. |
- Returns
- The new view. The caller owns it.
Definition at line 310 of file view.hpp.