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

State of one destination of a navigation bar: an icon in a pill, a label under it and an optional badge. More...

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

Inheritance diagram for guillaume::components::NavigationBarDestination:
Collaboration diagram for guillaume::components::NavigationBarDestination:

Public Types

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

Public Member Functions

 NavigationBarDestination (void)=default
 Create the configuration of a destination with no icon, no text and a visible label.
 ~NavigationBarDestination (void)=default
 Default destructor.
const std::string & getIcon (void) const noexcept
 Get the icon shown while the destination is not selected.
NavigationBarDestination & setIcon (const std::string &icon)
 Set the icon shown while the destination is not selected.
const std::string & getFocusedIcon (void) const noexcept
 Get the icon shown while the destination is selected.
NavigationBarDestination & setFocusedIcon (const std::string &icon)
 Set the icon shown while the destination is selected, typically the filled version of the unselected one.
const std::string & getLabel (void) const noexcept
 Get the text shown under the icon.
NavigationBarDestination & setLabel (const std::string &label)
 Set the text shown under the icon.
const std::string & getBadge (void) const noexcept
 Get the text of the badge.
NavigationBarDestination & setBadge (const std::string &badge)
 Set the text of the badge.
bool isLabelShown (void) const noexcept
 Tell whether the label is visible.
NavigationBarDestination & setShowLabel (bool show)
 Show or hide the label.
ecs::Entity::Identifier getIndicator (void) const noexcept
 Get the pill drawn behind the icon of the selected destination.
NavigationBarDestination & setIndicator (ecs::Entity::Identifier identifier)
 Record the active indicator pill child.
ecs::Entity::Identifier getIconEntity (void) const noexcept
 Get the child that draws the icon.
NavigationBarDestination & 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.
NavigationBarDestination & setLabelEntity (ecs::Entity::Identifier identifier)
 Record the child that draws the label.
ecs::Entity::Identifier getBadgeEntity (void) const noexcept
 Get the child that draws the badge.
NavigationBarDestination & setBadgeEntity (ecs::Entity::Identifier identifier)
 Record the child that draws the badge.
const PressHandler & getOnPress (void) const noexcept
 Get the callback run when the user presses the destination.
NavigationBarDestination & setOnPress (PressHandler handler)
 Set the callback run when the user presses the destination.
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 IndicatorWidth = 64.0f
 Width of the active indicator pill, in dp.
static constexpr float IndicatorHeight = 32.0f
 Height of the active indicator pill, in dp.
static constexpr float IconSize = 24.0f
 Size of the icon, in dp.
static constexpr float BadgeOffsetX = 36.0f
static constexpr float BadgeOffsetY = 2.0f
 Vertical offset of the badge from the indicator origin, in dp.

Detailed Description

State of one destination of a navigation bar: an icon in a pill, a label under it and an optional badge.

The entities::detail::BarDestination widget writes the glyphs, the label and the badge text, and records the identifiers of the children it builds (pill, icon, label, badge). systems::NavigationBar writes the label visibility and the press callback. systems::NavigationBarDestination reads everything in the Layout phase and turns it into the colors, the glyph 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::NavigationBarDestination, components::NavigationBar

Definition at line 51 of file navigation_bar_destination.hpp.

Member Typedef Documentation

◆ PressHandler

Callback run when the user presses the destination.

Definition at line 55 of file navigation_bar_destination.hpp.

Member Function Documentation

◆ getBadge()

const std::string & guillaume::components::NavigationBarDestination::getBadge ( void ) const
noexcept

Get the text of the badge.

Returns
The badge text. When the badge child exists, an empty text draws it as a dot.

Definition at line 75 of file navigation_bar_destination.cpp.

◆ getBadgeEntity()

ecs::Entity::Identifier guillaume::components::NavigationBarDestination::getBadgeEntity ( void ) const
noexcept

Get the child that draws the badge.

Returns
The child's identifier, or ecs::Entity::InvalidIdentifier when the destination has no badge.

Definition at line 153 of file navigation_bar_destination.cpp.

Here is the caller graph for this function:

◆ getFocusedIcon()

const std::string & guillaume::components::NavigationBarDestination::getFocusedIcon ( void ) const
noexcept

Get the icon shown while the destination is selected.

Returns
The glyph name; empty when the destination keeps its unselected icon.

Definition at line 45 of file navigation_bar_destination.cpp.

◆ getIcon()

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

Get the icon shown while the destination is not selected.

Returns
The glyph name.

Definition at line 29 of file navigation_bar_destination.cpp.

◆ getIconEntity()

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

Get the child that draws the icon.

Returns
The child's identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 121 of file navigation_bar_destination.cpp.

Here is the caller graph for this function:

◆ getIndicator()

ecs::Entity::Identifier guillaume::components::NavigationBarDestination::getIndicator ( void ) const
noexcept

Get the pill drawn behind the icon of the selected destination.

Returns
The child's identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 105 of file navigation_bar_destination.cpp.

Here is the caller graph for this function:

◆ getLabel()

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

Get the text shown under the icon.

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

Definition at line 60 of file navigation_bar_destination.cpp.

◆ getLabelEntity()

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

Get the child that draws the label.

Returns
The child's identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 137 of file navigation_bar_destination.cpp.

Here is the caller graph for this function:

◆ getOnPress()

const NavigationBarDestination::PressHandler & guillaume::components::NavigationBarDestination::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 169 of file navigation_bar_destination.cpp.

◆ isLabelShown()

bool guillaume::components::NavigationBarDestination::isLabelShown ( void ) const
noexcept

Tell whether the label is visible.

Returns
True when the label is drawn; false when it is transparent.

Definition at line 90 of file navigation_bar_destination.cpp.

◆ setBadge()

NavigationBarDestination & guillaume::components::NavigationBarDestination::setBadge ( const std::string & badge)

Set the text of the badge.

systems::NavigationBarDestination shows it on the badge child, when that child exists: a large badge with the text, or a dot when the text is empty. Marks the component changed only when the text differs.

Parameters
badgeThe new badge text.
Returns
This component, for chaining.

Definition at line 81 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setBadgeEntity()

NavigationBarDestination & guillaume::components::NavigationBarDestination::setBadgeEntity ( ecs::Entity::Identifier identifier)

Record the child that draws the badge.

The widget builds it the first time the badge text is not empty. Marks the component changed only when the identifier differs.

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

Definition at line 158 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setFocusedIcon()

NavigationBarDestination & guillaume::components::NavigationBarDestination::setFocusedIcon ( const std::string & icon)

Set the icon shown while the destination is selected, typically the filled version of the unselected one.

Marks the component changed only when the name differs.

Parameters
iconThe glyph name; empty keeps the unselected icon.
Returns
This component, for chaining.

Definition at line 51 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setIcon()

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

Set the icon shown while the destination is not selected.

It is also the icon of a selected destination that has no focused icon. 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_bar_destination.cpp.

Here is the call graph for this function:

◆ setIconEntity()

NavigationBarDestination & guillaume::components::NavigationBarDestination::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 126 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setIndicator()

NavigationBarDestination & guillaume::components::NavigationBarDestination::setIndicator ( ecs::Entity::Identifier identifier)

Record the active indicator pill child.

Marks the component changed only when the identifier differs.

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

Definition at line 110 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setLabel()

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

Set the text shown under the icon.

Marks the component changed only when the text differs.

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

Definition at line 66 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setLabelEntity()

NavigationBarDestination & guillaume::components::NavigationBarDestination::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 142 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

◆ setOnPress()

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

Set the callback run when the user presses the destination.

Inside a navigation bar, systems::NavigationBar::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 175 of file navigation_bar_destination.cpp.

◆ setShowLabel()

NavigationBarDestination & guillaume::components::NavigationBarDestination::setShowLabel ( bool show)

Show or hide the label.

A hidden label is drawn transparent and keeps its place in the column. systems::NavigationBar overwrites this flag every frame from the bar's variant and the selection. Marks the component changed only when the flag differs.

Parameters
showTrue to draw the label.
Returns
This component, for chaining.

Definition at line 95 of file navigation_bar_destination.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ BadgeOffsetX

float guillaume::components::NavigationBarDestination::BadgeOffsetX = 36.0f
staticconstexpr

Horizontal offset of the badge from the indicator origin, in dp, so the badge sits on the top-right corner of the icon.

Definition at line 68 of file navigation_bar_destination.hpp.

◆ BadgeOffsetY

float guillaume::components::NavigationBarDestination::BadgeOffsetY = 2.0f
staticconstexpr

Vertical offset of the badge from the indicator origin, in dp.

Definition at line 71 of file navigation_bar_destination.hpp.

◆ IconSize

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

Size of the icon, in dp.

Definition at line 64 of file navigation_bar_destination.hpp.

◆ IndicatorHeight

float guillaume::components::NavigationBarDestination::IndicatorHeight = 32.0f
staticconstexpr

Height of the active indicator pill, in dp.

Definition at line 61 of file navigation_bar_destination.hpp.

◆ IndicatorWidth

float guillaume::components::NavigationBarDestination::IndicatorWidth = 64.0f
staticconstexpr

Width of the active indicator pill, in dp.

Definition at line 58 of file navigation_bar_destination.hpp.


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