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 <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_drawer_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/navigation_drawer.hpp"
44
45namespace guillaume::entities::detail
46{
72 class DrawerDestination:
73 public std::enable_shared_from_this<DrawerDestination>,
75 components::Layout, components::Transform, components::Bound,
76 components::Color, components::Borders, components::Selectable,
77 components::NavigationDrawerDestination>
78 {
79 public:
93 template<typename... Arguments>
94 static std::shared_ptr<DrawerDestination>
95 create(Arguments &&...arguments)
96 {
97 std::shared_ptr<DrawerDestination> entity(
98 new DrawerDestination(std::forward<Arguments>(arguments)...));
99 entity->build();
100 return entity;
101 }
102
106 ~DrawerDestination(void) override = default;
107
116 void setOnPress(std::function<void(void)> onPress);
117
123 void setDisabled(bool disabled);
124
129 bool isDisabled(void) const;
130
141 const components::Selectable::Handler &handler);
142
147 bool isSelected(void) const;
148
156
157 private:
170 DrawerDestination(ecs::ComponentRegistry &registry,
171 const NavigationDrawer::Entry &entry, bool collapsed,
172 float width);
173
181 void build(void);
182 };
183} // 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::NavigationDrawer::Entry Entry
static std::shared_ptr< DrawerDestination > create(Arguments &&...arguments)
Create a destination and its children, without registering it in an entity registry or setting its pa...
~DrawerDestination(void) override=default
Default destructor.
void setDisabled(bool disabled)
Enable or disable the destination. Restyles at once.
bool isSelected(void) const
Whether the destination is the selected one of its drawer.
void setOnPress(std::function< void(void)> onPress)
Set the handler called when the user presses the destination while it is enabled.
ecs::Entity::Identifier getRightIdentifier(void) const
Get the trailing text entity.
void setOnSelectionChanged(const components::Selectable::Handler &handler)
Set the handler of the destination's components::Selectable.
bool isDisabled(void) const
Whether the destination ignores presses.