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 <utility>
26#include <functional>
27#include <memory>
28#include <string>
29
30#include "guillaume/ecs/parent_entity_filler.hpp"
31
32#include "guillaume/components/borders.hpp"
33#include "guillaume/components/bound.hpp"
34#include "guillaume/components/color.hpp"
35#include "guillaume/components/layout.hpp"
36#include "guillaume/components/navigation_bar_destination.hpp"
37#include "guillaume/components/selection.hpp"
38#include "guillaume/components/transform.hpp"
39
40#include "guillaume/entities/icon.hpp"
41#include "guillaume/entities/text.hpp"
42#include "guillaume/entities/view.hpp"
43#include "guillaume/entities/badge.hpp"
44#include "guillaume/entities/navigation_bar.hpp"
45
46namespace guillaume::entities::detail
47{
70 class BarDestination:
71 public std::enable_shared_from_this<BarDestination>,
73 components::Layout, components::Transform, components::Bound,
74 components::Color, components::Borders, components::Selectable,
75 components::NavigationBarDestination>
76 {
77 public:
91 template<typename... Arguments>
92 static std::shared_ptr<BarDestination> create(Arguments &&...arguments)
93 {
94 std::shared_ptr<BarDestination> entity(
95 new BarDestination(std::forward<Arguments>(arguments)...));
96 entity->build();
97 return entity;
98 }
99
103 ~BarDestination(void) override = default;
104
113 void setOnPress(std::function<void(void)> onPress);
114
123 void setBadge(const std::string &badge);
124
131 void setShowLabel(bool show);
132
143 const components::Selectable::Handler &handler);
144
149 bool isSelected(void) const;
150
158
166
173
181
182 private:
190 void buildBadge(void);
191
192 private:
202 BarDestination(ecs::ComponentRegistry &registry,
203 const NavigationBar::Destination &spec);
204
212 void build(void);
213 };
214} // namespace guillaume::entities::detail
std::function< void(bool)> Handler
Callback receiving the new state: true when just selected.
Definition selection.hpp:60
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
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
The base class of a widget with children: an EntityFiller that is also a ParentEntity.
components::NavigationBar::Destination Destination
void setOnPress(std::function< void(void)> onPress)
Set the handler called when the user presses the destination.
~BarDestination(void) override=default
Default destructor.
void setOnSelectionChanged(const components::Selectable::Handler &handler)
Set the handler of the destination's components::Selectable.
ecs::Entity::Identifier getLabelIdentifier(void) const
Get the label entity.
bool isSelected(void) const
Whether the destination is the selected one of its bar.
ecs::Entity::Identifier getIconIdentifier(void) const
Get the icon entity.
ecs::Entity::Identifier getIndicatorIdentifier(void) const
Get the active-indicator pill: the rounded shape behind the icon.
static std::shared_ptr< BarDestination > create(Arguments &&...arguments)
Create a destination and its children, without registering it in an entity registry or setting its pa...
void setShowLabel(bool show)
Show or hide the label. Restyles at once.
ecs::Entity::Identifier getBadgeIdentifier(void) const
Get the badge entity.
void setBadge(const std::string &badge)
Change the badge label.