guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
overlay.cpp
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#include "guillaume/components/overlay.hpp"
24
26{
27 bool Overlay::isVisible(void) const
28 {
29 return _visible;
30 }
31
33 {
34 if (_visible == visible) {
35 return *this;
36 }
37 _visible = visible;
38 if (!_visible) {
39 _elapsed = 0.0f;
40 }
41 setHasChanged(true);
42 return *this;
43 }
44
45 bool Overlay::isModal(void) const
46 {
47 return _modal;
48 }
49
51 {
52 if (_modal == modal) {
53 return *this;
54 }
55 _modal = modal;
56 setHasChanged(true);
57 return *this;
58 }
59
61 {
62 return _dismissOnOutsideClick;
63 }
64
66 {
67 if (_dismissOnOutsideClick == dismiss) {
68 return *this;
69 }
70 _dismissOnOutsideClick = dismiss;
71 setHasChanged(true);
72 return *this;
73 }
74
76 {
77 return _dismissOnEscape;
78 }
79
81 {
82 if (_dismissOnEscape == dismiss) {
83 return *this;
84 }
85 _dismissOnEscape = dismiss;
86 setHasChanged(true);
87 return *this;
88 }
89
90 float Overlay::getAutoDismiss(void) const
91 {
92 return _autoDismiss;
93 }
94
96 {
97 if (_autoDismiss == delay) {
98 return *this;
99 }
100 _autoDismiss = delay;
101 setHasChanged(true);
102 return *this;
103 }
104
105 bool Overlay::hasAutoDismiss(void) const
106 {
107 return _autoDismiss > 0.0f;
108 }
109
110 float Overlay::getElapsed(void) const
111 {
112 return _elapsed;
113 }
114
116 {
117 _elapsed = elapsed;
118 return *this;
119 }
120
122 {
123 _onDismiss = handler;
124 return *this;
125 }
126
128 {
129 return _onDismiss;
130 }
131} // 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
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
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
Definition component.cpp:32
State. Every class here is plain data attached to an entity.