guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
navigation_bar_destination.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <functional>
26#include <string>
27
28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
30
32{
33
52 {
53 public:
55 using PressHandler = std::function<void(void)>;
56
58 static constexpr float IndicatorWidth = 64.0f;
59
61 static constexpr float IndicatorHeight = 32.0f;
62
64 static constexpr float IconSize = 24.0f;
65
68 static constexpr float BadgeOffsetX = 36.0f;
69
71 static constexpr float BadgeOffsetY = 2.0f;
72
73 private:
74 std::string _icon {};
75 std::string _focusedIcon {};
76 std::string _label {};
77 std::string _badge {};
78 bool _showLabel { true };
79 ecs::Entity::Identifier _indicator {
81 };
82
83 ecs::Entity::Identifier _iconEntity {
85 };
86
87 ecs::Entity::Identifier _labelEntity {
89 };
90
91 ecs::Entity::Identifier _badgeEntity {
93 };
94
95 PressHandler _onPress {};
96
97 public:
103
108
113 const std::string &getIcon(void) const noexcept;
114
123 NavigationBarDestination &setIcon(const std::string &icon);
124
130 const std::string &getFocusedIcon(void) const noexcept;
131
140 NavigationBarDestination &setFocusedIcon(const std::string &icon);
141
146 const std::string &getLabel(void) const noexcept;
147
155 NavigationBarDestination &setLabel(const std::string &label);
156
162 const std::string &getBadge(void) const noexcept;
163
174 NavigationBarDestination &setBadge(const std::string &badge);
175
181 bool isLabelShown(void) const noexcept;
182
194
201 ecs::Entity::Identifier getIndicator(void) const noexcept;
202
212
218 ecs::Entity::Identifier getIconEntity(void) const noexcept;
219
229
235 ecs::Entity::Identifier getLabelEntity(void) const noexcept;
236
246
252 ecs::Entity::Identifier getBadgeEntity(void) const noexcept;
253
264
270 const PressHandler &getOnPress(void) const noexcept;
271
283 };
284
285} // namespace guillaume::components
NavigationBarDestination & setLabelEntity(ecs::Entity::Identifier identifier)
Record the child that draws the label.
NavigationBarDestination & setBadge(const std::string &badge)
Set the text of the badge.
ecs::Entity::Identifier getIndicator(void) const noexcept
Get the pill drawn behind the icon of the selected destination.
NavigationBarDestination & setOnPress(PressHandler handler)
Set the callback run when the user presses the destination.
const PressHandler & getOnPress(void) const noexcept
Get the callback run when the user presses the destination.
NavigationBarDestination & setLabel(const std::string &label)
Set the text shown under the icon.
NavigationBarDestination(void)=default
Create the configuration of a destination with no icon, no text and a visible label.
~NavigationBarDestination(void)=default
Default destructor.
std::function< void(void)> PressHandler
Callback run when the user presses the destination.
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.
static constexpr float IndicatorHeight
Height of the active indicator pill, in dp.
NavigationBarDestination & setIcon(const std::string &icon)
Set the icon shown while the destination is not selected.
static constexpr float IconSize
Size of the icon, in dp.
static constexpr float BadgeOffsetY
Vertical offset of the badge from the indicator origin, in dp.
const std::string & getLabel(void) const noexcept
Get the text shown under the icon.
NavigationBarDestination & setBadgeEntity(ecs::Entity::Identifier identifier)
Record the child that draws the badge.
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 ...
ecs::Entity::Identifier getBadgeEntity(void) const noexcept
Get the child that draws the badge.
NavigationBarDestination & setShowLabel(bool show)
Show or hide the label.
static constexpr float IndicatorWidth
Width of the active indicator pill, in dp.
NavigationBarDestination & setIndicator(ecs::Entity::Identifier identifier)
Record the active indicator pill child.
const std::string & getIcon(void) const noexcept
Get the icon shown while the destination is not selected.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child that draws the label.
const std::string & getBadge(void) const noexcept
Get the text of the badge.
bool isLabelShown(void) const noexcept
Tell whether the label is visible.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Definition entity.hpp:86
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
Definition entity.hpp:93
State. Every class here is plain data attached to an entity.