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

State of one destination of a navigation drawer: an icon, a label and an optional text at the trailing edge. More...

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

Inheritance diagram for guillaume::components::NavigationDrawerDestination:
Collaboration diagram for guillaume::components::NavigationDrawerDestination:

Public Types

using PressHandler = std::function<void(void)>
 Callback run when the user presses the destination.

Public Member Functions

 NavigationDrawerDestination (void)=default
 Create the configuration of an enabled, regular destination with no icon and no text.
 ~NavigationDrawerDestination (void)=default
 Default destructor.
const std::string & getIcon (void) const noexcept
 Get the icon of the destination.
NavigationDrawerDestination & setIcon (const std::string &icon)
 Set the icon of the destination.
const std::string & getLabel (void) const noexcept
 Get the label of the destination.
NavigationDrawerDestination & setLabel (const std::string &label)
 Set the label of the destination.
const std::string & getRight (void) const noexcept
 Get the text shown at the trailing edge of a regular item.
NavigationDrawerDestination & setRight (const std::string &right)
 Set the text shown at the trailing edge of a regular item, such as an unread count.
bool isDisabled (void) const noexcept
 Tell whether the destination ignores presses.
NavigationDrawerDestination & setDisabled (bool disabled)
 Disable or enable the destination.
bool isCollapsed (void) const noexcept
 Tell which rendering the destination uses.
NavigationDrawerDestination & setCollapsed (bool collapsed)
 Choose between the regular row and the collapsed (rail) rendering.
ecs::Entity::Identifier getLead (void) const noexcept
 Get the leading child of the destination.
NavigationDrawerDestination & setLead (ecs::Entity::Identifier identifier)
 Record the leading child of the destination.
ecs::Entity::Identifier getIconEntity (void) const noexcept
 Get the child that draws the icon.
NavigationDrawerDestination & setIconEntity (ecs::Entity::Identifier identifier)
 Record the child that draws the icon.
ecs::Entity::Identifier getLabelEntity (void) const noexcept
 Get the child that draws the label.
NavigationDrawerDestination & setLabelEntity (ecs::Entity::Identifier identifier)
 Record the child that draws the label.
ecs::Entity::Identifier getRightEntity (void) const noexcept
 Get the child that draws the trailing text.
NavigationDrawerDestination & setRightEntity (ecs::Entity::Identifier identifier)
 Record the child that draws the trailing text.
const PressHandler & getOnPress (void) const noexcept
 Get the callback run when the user presses the destination.
NavigationDrawerDestination & setOnPress (PressHandler handler)
 Set the callback run when the user presses the destination while it is enabled.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Static Public Attributes

static constexpr float Height = 56.0f
 Height of a regular destination, in dp.
static constexpr float CollapsedIndicatorWidth = 56.0f
 Width of the active indicator pill of a collapsed item, in dp.
static constexpr float CollapsedIndicatorHeight = 32.0f
 Height of the active indicator pill of a collapsed item, in dp.
static constexpr float IconSize = 24.0f
 Size of the icon, in dp.

Detailed Description

State of one destination of a navigation drawer: an icon, a label and an optional text at the trailing edge.

It has two renderings. A regular item is a 56 dp row whose whole surface is the active pill. A collapsed item (the rail of a collapsed drawer) stacks a small pill holding the icon above the label.

The entities::detail::DrawerDestination widget writes the content and the identifiers of the children it builds. systems::NavigationDrawerDestination reads everything in the Layout phase and turns it into the pill color, the content colors and the placement of those children.

Whether the destination is selected is not stored here: it is the components::Selectable of the same entity.

See also
systems::NavigationDrawerDestination, components::NavigationDrawer

Definition at line 54 of file navigation_drawer_destination.hpp.

Member Typedef Documentation

◆ PressHandler

Callback run when the user presses the destination.

Definition at line 58 of file navigation_drawer_destination.hpp.

Member Function Documentation

◆ getIcon()

const std::string & guillaume::components::NavigationDrawerDestination::getIcon ( void ) const
noexcept

Get the icon of the destination.

Returns
The glyph name.

Definition at line 29 of file navigation_drawer_destination.cpp.

◆ getIconEntity()

ecs::Entity::Identifier guillaume::components::NavigationDrawerDestination::getIconEntity ( void ) const
noexcept

Get the child that draws the icon.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 123 of file navigation_drawer_destination.cpp.

◆ getLabel()

const std::string & guillaume::components::NavigationDrawerDestination::getLabel ( void ) const
noexcept

Get the label of the destination.

Returns
The label; it is also the destination's accessible name.

Definition at line 45 of file navigation_drawer_destination.cpp.

◆ getLabelEntity()

ecs::Entity::Identifier guillaume::components::NavigationDrawerDestination::getLabelEntity ( void ) const
noexcept

Get the child that draws the label.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 139 of file navigation_drawer_destination.cpp.

◆ getLead()

ecs::Entity::Identifier guillaume::components::NavigationDrawerDestination::getLead ( void ) const
noexcept

Get the leading child of the destination.

Returns
For a regular item, the group that holds the icon and the label; for a collapsed item, the pill that holds the icon. ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 107 of file navigation_drawer_destination.cpp.

Here is the caller graph for this function:

◆ getOnPress()

const NavigationDrawerDestination::PressHandler & guillaume::components::NavigationDrawerDestination::getOnPress ( void ) const
noexcept

Get the callback run when the user presses the destination.

Returns
The callback; empty when none is set.

Definition at line 171 of file navigation_drawer_destination.cpp.

◆ getRight()

const std::string & guillaume::components::NavigationDrawerDestination::getRight ( void ) const
noexcept

Get the text shown at the trailing edge of a regular item.

Returns
The text; empty when there is none.

Definition at line 61 of file navigation_drawer_destination.cpp.

◆ getRightEntity()

ecs::Entity::Identifier guillaume::components::NavigationDrawerDestination::getRightEntity ( void ) const
noexcept

Get the child that draws the trailing text.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier when the destination has none.

Definition at line 155 of file navigation_drawer_destination.cpp.

◆ isCollapsed()

bool guillaume::components::NavigationDrawerDestination::isCollapsed ( void ) const
noexcept

Tell which rendering the destination uses.

Returns
True for a collapsed (rail) item, false for a regular row.

Definition at line 91 of file navigation_drawer_destination.cpp.

Here is the caller graph for this function:

◆ isDisabled()

bool guillaume::components::NavigationDrawerDestination::isDisabled ( void ) const
noexcept

Tell whether the destination ignores presses.

Returns
True when disabled.

Definition at line 76 of file navigation_drawer_destination.cpp.

◆ setCollapsed()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setCollapsed ( bool collapsed)

Choose between the regular row and the collapsed (rail) rendering.

Marks the component changed only when the flag differs.

Parameters
collapsedTrue for a collapsed item.
Returns
This component, for chaining.

Definition at line 97 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setDisabled()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setDisabled ( bool disabled)

Disable or enable the destination.

A disabled destination is drawn with the disabled content color, shows no active pill and does not run its press callback. systems::NavigationDrawerDestination copies the flag to the entity's components::StyleState. Marks the component changed only when the flag differs.

Parameters
disabledTrue to disable the destination.
Returns
This component, for chaining.

Definition at line 82 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setIcon()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setIcon ( const std::string & icon)

Set the icon of the destination.

Marks the component changed only when the name differs.

Parameters
iconThe glyph name.
Returns
This component, for chaining.

Definition at line 35 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setIconEntity()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setIconEntity ( ecs::Entity::Identifier identifier)

Record the child that draws the icon.

Marks the component changed only when the identifier differs.

Parameters
identifierThe child's identifier.
Returns
This component, for chaining.

Definition at line 128 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setLabel()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setLabel ( const std::string & label)

Set the label of the destination.

Marks the component changed only when the text differs.

Parameters
labelThe new label.
Returns
This component, for chaining.

Definition at line 51 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setLabelEntity()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setLabelEntity ( ecs::Entity::Identifier identifier)

Record the child that draws the label.

Marks the component changed only when the identifier differs.

Parameters
identifierThe child's identifier.
Returns
This component, for chaining.

Definition at line 144 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setLead()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setLead ( ecs::Entity::Identifier identifier)

Record the leading child of the destination.

Marks the component changed only when the identifier differs.

Parameters
identifierThe identifier of the icon-and-label group (regular item) or of the pill (collapsed item).
Returns
This component, for chaining.

Definition at line 113 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setOnPress()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setOnPress ( PressHandler handler)

Set the callback run when the user presses the destination while it is enabled.

Inside a navigation drawer, systems::NavigationDrawer::install sets it to select the destination, so a callback set by hand is replaced. Does not mark the component changed.

Parameters
handlerThe callback; an empty one removes it.
Returns
This component, for chaining.

Definition at line 177 of file navigation_drawer_destination.cpp.

◆ setRight()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setRight ( const std::string & right)

Set the text shown at the trailing edge of a regular item, such as an unread count.

When it is not empty, the row spreads its content so this text reaches the far edge. Marks the component changed only when the text differs.

Parameters
rightThe new text; empty for none.
Returns
This component, for chaining.

Definition at line 67 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

◆ setRightEntity()

NavigationDrawerDestination & guillaume::components::NavigationDrawerDestination::setRightEntity ( ecs::Entity::Identifier identifier)

Record the child that draws the trailing text.

Marks the component changed only when the identifier differs.

Parameters
identifierThe child's identifier.
Returns
This component, for chaining.

Definition at line 160 of file navigation_drawer_destination.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ CollapsedIndicatorHeight

float guillaume::components::NavigationDrawerDestination::CollapsedIndicatorHeight = 32.0f
staticconstexpr

Height of the active indicator pill of a collapsed item, in dp.

Definition at line 67 of file navigation_drawer_destination.hpp.

◆ CollapsedIndicatorWidth

float guillaume::components::NavigationDrawerDestination::CollapsedIndicatorWidth = 56.0f
staticconstexpr

Width of the active indicator pill of a collapsed item, in dp.

Definition at line 64 of file navigation_drawer_destination.hpp.

◆ Height

float guillaume::components::NavigationDrawerDestination::Height = 56.0f
staticconstexpr

Height of a regular destination, in dp.

Definition at line 61 of file navigation_drawer_destination.hpp.

◆ IconSize

float guillaume::components::NavigationDrawerDestination::IconSize = 24.0f
staticconstexpr

Size of the icon, in dp.

Definition at line 70 of file navigation_drawer_destination.hpp.


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