guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
navigation_drawer.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 <cstddef>
26
27#include "guillaume/ecs/system_filler.hpp"
28
29#include "guillaume/components/navigation_drawer.hpp"
30#include "guillaume/theme.hpp"
31
32namespace guillaume::systems
33{
79 public ecs::SystemFiller<components::NavigationDrawer>
80 {
81 public:
83 static constexpr float Padding = theme::SpacingScale::get(3);
84
86 static constexpr float Spacing = theme::SpacingScale::get(1);
87
91 NavigationDrawer(void);
92
96 ~NavigationDrawer(void) override = default;
97
117 static void install(ecs::ComponentRegistry &componentRegistry,
118 const ecs::Entity::Identifier &entityIdentifier);
119
140 static void apply(ecs::ComponentRegistry &componentRegistry,
141 const ecs::Entity::Identifier &entityIdentifier);
142
151
164 static void select(ecs::ComponentRegistry &componentRegistry,
165 const ecs::Entity::Identifier &entityIdentifier,
166 std::size_t index);
167
178 static void
180 const ecs::Entity::Identifier &entityIdentifier);
181
194 static void press(ecs::ComponentRegistry &componentRegistry,
195 const ecs::Entity::Identifier &entityIdentifier,
196 std::size_t index);
197
213 static void
215 const ecs::Entity::Identifier &entityIdentifier,
216 std::size_t index);
217
231 static void setDestinationDisabled(
232 ecs::ComponentRegistry &componentRegistry,
233 const ecs::Entity::Identifier &entityIdentifier, std::size_t index,
234 bool disabled);
235
244 static void show(ecs::ComponentRegistry &componentRegistry,
245 const ecs::Entity::Identifier &entityIdentifier);
246
255 static void hide(ecs::ComponentRegistry &componentRegistry,
256 const ecs::Entity::Identifier &entityIdentifier);
257
267 static std::size_t
268 selectedIndex(const ecs::ComponentRegistry &componentRegistry,
269 const ecs::Entity::Identifier &entityIdentifier);
270
279 void update(const ecs::Entity::Identifier &entityIdentifier) override;
280 };
281
282} // namespace guillaume::systems
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 to derive a system from: a System whose signature is the list of component types given...
static float widthOf(components::NavigationDrawer::Variant variant)
Get the drawer width of a variant, in dp.
static void destinationSelected(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
React to a destination that became selected without going through the drawer.
static constexpr float Spacing
Gap between two stacked entries: 4 dp.
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Shape and color the drawer, style its destinations, stack its entries and place its backdrop.
static void select(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
Select a destination from code.
~NavigationDrawer(void) override=default
Default destructor.
NavigationDrawer(void)
Create the system in the Layout phase.
static void hide(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Hide the drawer and its backdrop.
static void press(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
Activate a destination as a press on it would.
static void setDestinationDisabled(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index, bool disabled)
Enable or disable one destination and restyle it.
void update(const ecs::Entity::Identifier &entityIdentifier) override
Run apply() on one navigation drawer; called by the frame loop.
static void show(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Show the drawer, and its backdrop when it is modal.
static void selectFirstEnabled(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Select the first destination that is not disabled, then restyle.
static void install(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Connect a navigation drawer to its destinations and section headers.
static constexpr float Padding
Space between the edge of the drawer and its entries: 12 dp.
static std::size_t selectedIndex(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Get the index of the selected destination.
static constexpr float get(unsigned int steps)
Get a spacing as a number of grid units.
Definition tokens.hpp:441
Rules. Every class here runs each frame on the entities that have the components it declares.