guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
overlay.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 <functional>
26
27#include "guillaume/ecs/component.hpp"
28
30{
31
54 class Overlay: public ecs::Component
55 {
56 public:
58 std::function<void(void)>;
59
60 private:
61 bool _visible { false };
62 bool _modal { true };
63 bool _dismissOnOutsideClick {
64 true
65 };
66
67 bool _dismissOnEscape { true };
68 float _autoDismiss { 0.0f };
69 float _elapsed { 0.0f };
70 DismissHandler _onDismiss {};
71
72 public:
77 Overlay(void) = default;
78
82 ~Overlay(void) = default;
83
88 bool isVisible(void) const;
89
100 Overlay &setVisible(bool visible);
101
106 bool isModal(void) const;
107
118 Overlay &setModal(bool modal);
119
124 bool dismissesOnOutsideClick(void) const;
125
135 Overlay &setDismissOnOutsideClick(bool dismiss);
136
141 bool dismissesOnEscape(void) const;
142
151 Overlay &setDismissOnEscape(bool dismiss);
152
158 float getAutoDismiss(void) const;
159
170 Overlay &setAutoDismiss(float delay);
171
177 bool hasAutoDismiss(void) const;
178
185 float getElapsed(void) const;
186
195 Overlay &setElapsed(float elapsed);
196
208
214 };
215
216} // namespace guillaume::components
Overlay & setModal(bool modal)
Declare the overlay modal (it must be answered before the rest of the interface is used) or not.
Definition overlay.cpp:50
Overlay & setDismissOnOutsideClick(bool dismiss)
Choose whether a click outside the overlay dismisses it.
Definition overlay.cpp:65
bool dismissesOnEscape(void) const
Tell whether the Escape key dismisses the overlay.
Definition overlay.cpp:75
Overlay & setDismissOnEscape(bool dismiss)
Choose whether the Escape key dismisses the overlay.
Definition overlay.cpp:80
std::function< void(void)> DismissHandler
Callback run on dismissal.
Definition overlay.hpp:57
Overlay & setVisible(bool visible)
Show or hide the overlay.
Definition overlay.cpp:32
Overlay(void)=default
Create a hidden, modal overlay that is dismissed on Escape and on an outside click,...
Overlay & setElapsed(float elapsed)
Store the time counted towards auto-dismissal.
Definition overlay.cpp:115
Overlay & setOnDismissHandler(const DismissHandler &handler)
Set the callback run when systems::Overlay dismisses the overlay.
Definition overlay.cpp:121
bool dismissesOnOutsideClick(void) const
Tell whether a click outside the overlay dismisses it.
Definition overlay.cpp:60
bool hasAutoDismiss(void) const
Tell whether the overlay is dismissed by itself after a delay.
Definition overlay.cpp:105
bool isModal(void) const
Tell whether the overlay is modal.
Definition overlay.cpp:45
DismissHandler getOnDismissHandler(void) const
Get the callback run when the overlay is dismissed.
Definition overlay.cpp:127
float getElapsed(void) const
Get how long the overlay has been counting towards its auto-dismissal.
Definition overlay.cpp:110
Overlay & setAutoDismiss(float delay)
Set how long the overlay stays shown before it is dismissed by itself.
Definition overlay.cpp:95
~Overlay(void)=default
Default destructor.
bool isVisible(void) const
Tell whether the overlay is shown.
Definition overlay.cpp:27
float getAutoDismiss(void) const
Get how long the overlay stays shown before it is dismissed by itself.
Definition overlay.cpp:90
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.