guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::entities::DrawerDestination Class Reference

One destination of a NavigationDrawer: a pressable row with an icon, a label and an optional trailing text, or, collapsed, an icon in a pill with the label under it (Paper Drawer.Item and Drawer.CollapsedItem). More...

#include <headers/guillaume/entities/navigation_drawer_destination.hpp>

Inheritance diagram for guillaume::entities::DrawerDestination:
Collaboration diagram for guillaume::entities::DrawerDestination:

Public Member Functions

 ~DrawerDestination (void) override=default
 Default destructor.
void setOnPress (std::function< void(void)> onPress)
 Set the handler called when the user presses the destination while it is enabled.
void setDisabled (bool disabled)
 Enable or disable the destination. Restyles at once.
bool isDisabled (void) const
 Whether the destination ignores presses.
void setOnSelectionChanged (const components::Selectable::Handler &handler)
 Set the handler of the destination's components::Selectable.
bool isSelected (void) const
 Whether the destination is the selected one of its drawer.
ecs::Entity::Identifier getRightIdentifier (void) const
 Get the trailing text entity.
Public Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, components::Selectable, components::NavigationDrawerDestination >
 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).
Public Member Functions inherited from guillaume::ecs::Entity
 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.
Public Member Functions inherited from guillaume::ecs::EntityRegistry
 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.

Static Public Member Functions

template<typename... Arguments>
static std::shared_ptr< DrawerDestination > create (Arguments &&...arguments)
 Create a destination and its children, without registering it in an entity registry or setting its parent.
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.

Additional Inherited Members

Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).
Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity
Protected Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, components::Selectable, components::NavigationDrawerDestination >
ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
Protected Member Functions inherited from guillaume::ecs::ParentEntity
std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) override
 Give access to the list of entities this entity owns directly.
const std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) const override
 Give read access to the list of entities this entity owns directly.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Detailed Description

One destination of a NavigationDrawer: a pressable row with an icon, a label and an optional trailing text, or, collapsed, an icon in a pill with the label under it (Paper Drawer.Item and Drawer.CollapsedItem).

Internal to NavigationDrawer, which creates one per destination entry with DrawerDestination::create(registry, entry, collapsed, width) and adds it to itself; applications use the NavigationDrawer methods instead. Its state lives in components::NavigationDrawerDestination (icon, label, trailing text, disabled and collapsed flags, child identifiers, press handler) and its selection in components::Selectable; systems::NavigationDrawerDestination styles it for its selection and places its children each frame, in the Layout phase. The class itself holds no field.

The collapsed flag is chosen at creation and decides which children are built; NavigationDrawer creates new destinations to change it. systems::NavigationDrawer overwrites the width of the destination, its press handler and its selection-change handler.

See also
NavigationDrawer, components::NavigationDrawerDestination, systems::NavigationDrawerDestination

Definition at line 72 of file navigation_drawer_destination.hpp.

Member Function Documentation

◆ create()

template<typename... Arguments>
std::shared_ptr< DrawerDestination > guillaume::entities::detail::DrawerDestination::create ( Arguments &&... arguments)
inlinestatic

Create a destination and its children, without registering it in an entity registry or setting its parent.

The constructor is private because the children need the destination to be owned by a shared pointer before they can take it as parent; create() constructs it, then builds the icon, the label and the trailing text.

Template Parameters
ArgumentsThe types of the constructor arguments.
Parameters
argumentsForwarded to the private constructor: (registry, entry, collapsed, width).
Returns
The new destination.

Definition at line 95 of file navigation_drawer_destination.hpp.

◆ getRightIdentifier()

Get the trailing text entity.

Returns
The identifier of the text, or ecs::Entity::InvalidIdentifier when the destination has no trailing text or is collapsed.

Definition at line 208 of file navigation_drawer_destination.cpp.

◆ isDisabled()

Whether the destination ignores presses.

Returns
True when disabled.

Definition at line 188 of file navigation_drawer_destination.cpp.

◆ isSelected()

Whether the destination is the selected one of its drawer.

Returns
True when its components::Selectable is selected.

Definition at line 202 of file navigation_drawer_destination.cpp.

◆ setDisabled()

Enable or disable the destination. Restyles at once.

Parameters
disabledTrue to make the destination ignore presses and use the disabled content color.

Definition at line 182 of file navigation_drawer_destination.cpp.

◆ setOnPress()

void guillaume::entities::detail::DrawerDestination::setOnPress ( std::function< void(void)> onPress)

Set the handler called when the user presses the destination while it is enabled.

systems::NavigationDrawer::install sets this handler on every destination of a drawer; setting another one replaces it.

Parameters
onPressThe handler; an empty function for none.

Definition at line 174 of file navigation_drawer_destination.cpp.

◆ setOnSelectionChanged()

Set the handler of the destination's components::Selectable.

systems::NavigationDrawer::install sets this handler on every destination of a drawer; setting another one replaces it.

Parameters
handlerCalled with the new state when the destination becomes selected or deselected.

Definition at line 194 of file navigation_drawer_destination.cpp.


The documentation for this class was generated from the following files: