guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
navigation_drawer_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
55 {
56 public:
58 using PressHandler = std::function<void(void)>;
59
61 static constexpr float Height = 56.0f;
62
64 static constexpr float CollapsedIndicatorWidth = 56.0f;
65
67 static constexpr float CollapsedIndicatorHeight = 32.0f;
68
70 static constexpr float IconSize = 24.0f;
71
72 private:
73 std::string _icon {};
74 std::string _label {};
75 std::string _right {};
76 bool _disabled { false };
77 bool _collapsed { false };
80 };
81
82 ecs::Entity::Identifier _iconEntity {
84 };
85
86 ecs::Entity::Identifier _labelEntity {
88 };
89
90 ecs::Entity::Identifier _rightEntity {
92 };
93
94 PressHandler _onPress {};
95
96 public:
102
107
112 const std::string &getIcon(void) const noexcept;
113
121 NavigationDrawerDestination &setIcon(const std::string &icon);
122
127 const std::string &getLabel(void) const noexcept;
128
136 NavigationDrawerDestination &setLabel(const std::string &label);
137
142 const std::string &getRight(void) const noexcept;
143
154 NavigationDrawerDestination &setRight(const std::string &right);
155
160 bool isDisabled(void) const noexcept;
161
174
179 bool isCollapsed(void) const noexcept;
180
190
197 ecs::Entity::Identifier getLead(void) const noexcept;
198
209
215 ecs::Entity::Identifier getIconEntity(void) const noexcept;
216
226
232 ecs::Entity::Identifier getLabelEntity(void) const noexcept;
233
243
249 ecs::Entity::Identifier getRightEntity(void) const noexcept;
250
260
266 const PressHandler &getOnPress(void) const noexcept;
267
279 };
280
281} // namespace guillaume::components
ecs::Entity::Identifier getLead(void) const noexcept
Get the leading child of the destination.
static constexpr float Height
Height of a regular destination, in dp.
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.
const PressHandler & getOnPress(void) const noexcept
Get the callback run when the user presses the destination.
NavigationDrawerDestination & setIcon(const std::string &icon)
Set the icon of the destination.
~NavigationDrawerDestination(void)=default
Default destructor.
NavigationDrawerDestination & setDisabled(bool disabled)
Disable or enable the destination.
static constexpr float IconSize
Size of the icon, in dp.
NavigationDrawerDestination(void)=default
Create the configuration of an enabled, regular destination with no icon and no text.
const std::string & getLabel(void) const noexcept
Get the label of the destination.
static constexpr float CollapsedIndicatorHeight
Height of the active indicator pill of a collapsed item, in dp.
const std::string & getRight(void) const noexcept
Get the text shown at the trailing edge of a regular item.
NavigationDrawerDestination & setOnPress(PressHandler handler)
Set the callback run when the user presses the destination while it is enabled.
NavigationDrawerDestination & setRightEntity(ecs::Entity::Identifier identifier)
Record the child that draws the trailing text.
NavigationDrawerDestination & setLabel(const std::string &label)
Set the label of the destination.
static constexpr float CollapsedIndicatorWidth
Width of the active indicator pill of a collapsed item, in dp.
NavigationDrawerDestination & setCollapsed(bool collapsed)
Choose between the regular row and the collapsed (rail) rendering.
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.
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.
NavigationDrawerDestination & setLead(ecs::Entity::Identifier identifier)
Record the leading child of the destination.
bool isDisabled(void) const noexcept
Tell whether the destination ignores presses.
const std::string & getIcon(void) const noexcept
Get the icon of the destination.
bool isCollapsed(void) const noexcept
Tell which rendering the destination uses.
NavigationDrawerDestination & setRight(const std::string &right)
Set the text shown at the trailing edge of a regular item, such as an unread count.
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.