guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
interaction_helpers.hpp
Go to the documentation of this file.
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
27#include <utility/graphic/color.hpp>
28
29#include "guillaume/components/accessibility.hpp"
30#include "guillaume/ecs/component_registry.hpp"
31#include "guillaume/ecs/entity.hpp"
32
33namespace guillaume::systems::interaction
34{
35
54
92 void makeInteractive(ecs::ComponentRegistry &registry,
93 const ecs::Entity::Identifier &entityIdentifier,
95 std::function<void(void)> onPress,
96 std::function<void(void)> onStateChange = {});
97
111 void setEnabled(ecs::ComponentRegistry &registry,
112 const ecs::Entity::Identifier &entityIdentifier,
113 bool enabled);
114
122 bool isEnabled(const ecs::ComponentRegistry &registry,
123 const ecs::Entity::Identifier &entityIdentifier);
124
135 bool isHovered(const ecs::ComponentRegistry &registry,
136 const ecs::Entity::Identifier &entityIdentifier);
137
149 bool isPressed(const ecs::ComponentRegistry &registry,
150 const ecs::Entity::Identifier &entityIdentifier);
151
181 utility::graphic::Color32Bit
182 stateLayerColor(const ecs::ComponentRegistry &registry,
183 const ecs::Entity::Identifier &entityIdentifier,
184 const utility::graphic::Color32Bit &base,
185 const utility::graphic::Color32Bit &content);
186
187} // namespace guillaume::systems::interaction
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
AccessibilityRole
What an entity is for a screen reader or another assistive technology. The values mirror react-native...
bool isPressed(const ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier)
Whether an entity is being pressed.
bool isHovered(const ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier)
Whether the mouse pointer or a hand is over an entity.
bool isEnabled(const ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier)
Whether an entity accepts input.
void makeInteractive(ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier, components::AccessibilityRole role, std::function< void(void)> onPress, std::function< void(void)> onStateChange={})
Make an entity hoverable, pressable and focusable.
void setEnabled(ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier, bool enabled)
Enable or disable an entity.
utility::graphic::Color32Bit stateLayerColor(const ecs::ComponentRegistry &registry, const ecs::Entity::Identifier &entityIdentifier, const utility::graphic::Color32Bit &base, const utility::graphic::Color32Bit &content)
Container color of a widget in its current input state.