27#include <utility/graphic/pose.hpp>
28#include <utility/graphic/position.hpp>
30#include "guillaume/ecs/component_registry.hpp"
31#include "guillaume/ecs/entity.hpp"
33#include "guillaume/components/bound.hpp"
34#include "guillaume/components/layout_extent.hpp"
35#include "guillaume/components/transform.hpp"
37#include "guillaume/systems/layout.hpp"
80 inline utility::graphic::PoseF
85 return utility::graphic::PoseF();
120 const utility::graphic::PositionF &offset,
121 std::uint32_t parentLayer)
127 const auto origin =
poseOf(registry, parentIdentifier);
129 const utility::graphic::PositionF basePosition(
130 origin.getPosition().getX() + offset.x,
131 origin.getPosition().getY() - offset.y,
132 origin.getPosition().getZ());
135 basePosition, origin.getOrientation(), parentLayer);
157 std::uint32_t parentLayer)
164 const auto &parentBound =
166 const auto &childBound =
170 registry, parentIdentifier, childIdentifier,
171 utility::graphic::PositionF(
172 (parentBound.getWidth() - childBound.getWidth()) / 2.0f,
173 (parentBound.getHeight() - childBound.getHeight()) / 2.0f,
200 float normalized,
float inset,
201 std::uint32_t parentLayer)
208 const auto &parentBound =
210 const auto &childBound =
214 parentBound.getWidth() - childBound.getWidth() - 2.0f * inset;
217 registry, parentIdentifier, childIdentifier,
218 utility::graphic::PositionF(
219 inset + normalized * (travel > 0.0f ? travel : 0.0f),
220 (parentBound.getHeight() - childBound.getHeight()) / 2.0f,
247 .setTrailingWidth(width);
Size of an entity: the width and height, in dp, of the rectangle that starts at the position of its c...
Space a widget takes in its parent's layout beyond its Bound.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
ComponentType & addComponent(const Entity::Identifier &entityIdentifier, Args &&...args)
Construct a component for an entity, replacing the one it already has, if any.
bool hasComponent(const Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component of a given type.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static const utility::graphic::PoseF contentLayerPose(const utility::graphic::PositionF &position, const utility::graphic::OrientationF &orientation, const std::uint32_t &containerLayer)
Compute the pose of content placed by hand on a container.
Helpers that position a child relative to its parent by writing the child's components::Transform.
void centerChild(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &parentIdentifier, const ecs::Entity::Identifier &childIdentifier, std::uint32_t parentLayer)
Center a child inside the bound of its parent, on both axes.
utility::graphic::PoseF poseOf(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier)
Read the pose (position and orientation) of an entity.
void placeChild(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &parentIdentifier, const ecs::Entity::Identifier &childIdentifier, const utility::graphic::PositionF &offset, std::uint32_t parentLayer)
Place a child at an offset from the position of its parent.
void reserveTrailingWidth(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier, float width)
Reserve layout room after an entity's Bound.
void placeNormalized(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &parentIdentifier, const ecs::Entity::Identifier &childIdentifier, float normalized, float inset, std::uint32_t parentLayer)
Place a child along the width of its parent from a 0 to 1 value, vertically centered.