guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
loading_indicator.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/loading_indicator.hpp"
24
26{
28 {
29 return _variant;
30 }
31
33 {
34 if (_variant != variant) {
35 _variant = variant;
36 setHasChanged(true);
37 }
38 return *this;
39 }
40
41 float LoadingIndicator::getSize(void) const noexcept
42 {
43 return _size;
44 }
45
47 {
48 if (_size != size) {
49 _size = size;
50 setHasChanged(true);
51 }
52 return *this;
53 }
54
56 {
57 return _indicator;
58 }
59
62 {
63 if (_indicator != identifier) {
64 _indicator = identifier;
65 setHasChanged(true);
66 }
67 return *this;
68 }
69
70 bool LoadingIndicator::isBuilt(void) const noexcept
71 {
72 return _built;
73 }
74
76 {
77 if (_built != built) {
78 _built = built;
79 setHasChanged(true);
80 }
81 return *this;
82 }
83
84 float LoadingIndicator::getProgress(void) const noexcept
85 {
86 return _progress;
87 }
88
90 {
91 if (_progress != progress) {
92 _progress = progress;
93 setHasChanged(true);
94 }
95 return *this;
96 }
97
98 bool LoadingIndicator::hidesWhenStopped(void) const noexcept
99 {
100 return _hidesWhenStopped;
101 }
102
104 {
105 if (_hidesWhenStopped != hides) {
106 _hidesWhenStopped = hides;
107 setHasChanged(true);
108 }
109 return *this;
110 }
111
112 float LoadingIndicator::getOpacity(void) const noexcept
113 {
114 return _opacity;
115 }
116
118 {
119 if (_opacity != opacity) {
120 _opacity = opacity;
121 setHasChanged(true);
122 }
123 return *this;
124 }
125
126 float LoadingIndicator::getOpacityFrom(void) const noexcept
127 {
128 return _opacityFrom;
129 }
130
132 {
133 if (_opacityFrom != opacity) {
134 _opacityFrom = opacity;
135 setHasChanged(true);
136 }
137 return *this;
138 }
139
140 float LoadingIndicator::getOpacityTarget(void) const noexcept
141 {
142 return _opacityTarget;
143 }
144
146 {
147 if (_opacityTarget != opacity) {
148 _opacityTarget = opacity;
149 setHasChanged(true);
150 }
151 return *this;
152 }
153
154 const std::optional<utility::graphic::Color32Bit> &
156 {
157 return _indicatorColor;
158 }
159
161 const std::optional<utility::graphic::Color32Bit> &color)
162 {
163 if (_indicatorColor != color) {
164 _indicatorColor = color;
165 setHasChanged(true);
166 }
167 return *this;
168 }
169} // namespace guillaume::components
State of a loading indicator: an arc that turns, or a bar that slides, in a loop while something is i...
LoadingIndicator & setOpacity(float opacity)
Store the opacity the indicator is drawn with.
LoadingIndicator & setHidesWhenStopped(bool hides)
Choose whether the indicator fades out when it is stopped.
LoadingIndicator & setVariant(Variant variant)
Set the shape of the indicator.
float getOpacityFrom(void) const noexcept
Get the opacity the indicator had when the running fade began.
float getSize(void) const noexcept
Get the diameter of the circular variant.
LoadingIndicator & setOpacityTarget(float opacity)
Store the opacity a fade ends at.
float getOpacity(void) const noexcept
Get the opacity the indicator is drawn with.
LoadingIndicator & setOpacityFrom(float opacity)
Store the opacity at the start of a fade.
LoadingIndicator & setBuilt(bool built)
Record whether the animated child matches the current variant.
const std::optional< utility::graphic::Color32Bit > & getIndicatorColor(void) const noexcept
Get the color chosen for the indicator.
float getOpacityTarget(void) const noexcept
Get the opacity the running fade ends at.
LoadingIndicator & setProgress(float progress)
Store how far the loop has advanced.
bool hidesWhenStopped(void) const noexcept
Tell whether the indicator fades out when it is stopped.
bool isBuilt(void) const noexcept
Tell whether the animated child matches the current variant.
float getProgress(void) const noexcept
Get how far the loop has advanced.
LoadingIndicator & setIndicatorColor(const std::optional< utility::graphic::Color32Bit > &color)
Choose the color of the indicator.
ecs::Entity::Identifier getIndicator(void) const noexcept
Get the child that draws the turning arc or the sliding bar.
LoadingIndicator & setIndicator(ecs::Entity::Identifier identifier)
Record the child that draws the turning arc or the sliding bar.
LoadingIndicator(void)=default
Create the state of a circular indicator of the default size, with no child, that hides when stopped.
LoadingIndicator & setSize(float size)
Set the diameter of the circular variant.
Variant getVariant(void) const noexcept
Get the shape of the indicator.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
Definition component.cpp:32
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
State. Every class here is plain data attached to an entity.