guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
menu.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/menu.hpp"
30
31namespace guillaume::systems
32{
72 class Menu: public ecs::SystemFiller<components::Menu>
73 {
74 public:
78 Menu(void);
79
83 ~Menu(void) override = default;
84
101 static void install(ecs::ComponentRegistry &componentRegistry,
102 const ecs::Entity::Identifier &entityIdentifier);
103
119 static void installRow(ecs::ComponentRegistry &componentRegistry,
120 const ecs::Entity::Identifier &entityIdentifier,
121 std::size_t index);
122
143 static void apply(ecs::ComponentRegistry &componentRegistry,
144 const ecs::Entity::Identifier &entityIdentifier);
145
153 static bool isOpen(const ecs::ComponentRegistry &componentRegistry,
154 const ecs::Entity::Identifier &entityIdentifier);
155
168 static void styleRow(ecs::ComponentRegistry &componentRegistry,
169 const ecs::Entity::Identifier &entityIdentifier,
170 std::size_t index);
171
183 static void pressItem(ecs::ComponentRegistry &componentRegistry,
184 const ecs::Entity::Identifier &entityIdentifier,
185 std::size_t index);
186
198 static void
199 setItemDisabled(ecs::ComponentRegistry &componentRegistry,
200 const ecs::Entity::Identifier &entityIdentifier,
201 std::size_t index, bool disabled);
202
212 static void show(ecs::ComponentRegistry &componentRegistry,
213 const ecs::Entity::Identifier &entityIdentifier);
214
224 static void hide(ecs::ComponentRegistry &componentRegistry,
225 const ecs::Entity::Identifier &entityIdentifier);
226
237 static void dismiss(ecs::ComponentRegistry &componentRegistry,
238 const ecs::Entity::Identifier &entityIdentifier);
239
247 void update(const ecs::Entity::Identifier &entityIdentifier) override;
248 };
249
250} // 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 void styleRow(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
Recolor one row without sizing the menu again.
Definition menu.cpp:228
static void install(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Give a menu its accessibility semantics and make its rows pressable.
Definition menu.cpp:171
static void setItemDisabled(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index, bool disabled)
Enable or disable an item and restyle the menu.
Definition menu.cpp:289
static void hide(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Hide the menu without telling anyone.
Definition menu.cpp:306
void update(const ecs::Entity::Identifier &entityIdentifier) override
Run apply() on one menu; called by the frame loop.
Definition menu.cpp:420
static void installRow(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
Make one row pressable.
Definition menu.cpp:188
static void pressItem(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, std::size_t index)
Activate an item as a press on its row would.
Definition menu.cpp:269
Menu(void)
Create the system in the Layout phase.
Definition menu.cpp:166
static bool isOpen(const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Whether a menu is open.
Definition menu.cpp:218
static void dismiss(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Close the menu as the user would with Escape or a click outside.
Definition menu.cpp:314
static void show(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Place the menu next to its anchor, then show it.
Definition menu.cpp:298
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Style one menu, size its rows and move it next to its anchor.
Definition menu.cpp:332
~Menu(void) override=default
Default destructor.
Rules. Every class here runs each frame on the entities that have the components it declares.