guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
progress_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/progress_indicator.hpp"
24
26{
28 ProgressIndicator::getVariant(void) const noexcept
29 {
30 return _variant;
31 }
32
34 {
35 if (_variant != variant) {
36 _variant = variant;
37 setHasChanged(true);
38 }
39 return *this;
40 }
41
42 bool ProgressIndicator::isCircular(void) const noexcept
43 {
44 return _variant == Variant::CircularDeterminate
45 || _variant == Variant::CircularIndeterminate;
46 }
47
48 bool ProgressIndicator::isIndeterminate(void) const noexcept
49 {
50 return _variant == Variant::LinearIndeterminate
51 || _variant == Variant::CircularIndeterminate;
52 }
53
54 float ProgressIndicator::getTrackLength(void) const noexcept
55 {
56 return _trackLength;
57 }
58
60 {
61 if (_trackLength != length) {
62 _trackLength = length;
63 setHasChanged(true);
64 }
65 return *this;
66 }
67
68 float ProgressIndicator::getDiameter(void) const noexcept
69 {
70 return _diameter;
71 }
72
74 {
75 if (_diameter != diameter) {
76 _diameter = diameter;
77 setHasChanged(true);
78 }
79 return *this;
80 }
81
83 {
84 return _track;
85 }
86
89 {
90 if (_track != identifier) {
91 _track = identifier;
92 setHasChanged(true);
93 }
94 return *this;
95 }
96
98 {
99 return _fill;
100 }
101
104 {
105 if (_fill != identifier) {
106 _fill = identifier;
107 setHasChanged(true);
108 }
109 return *this;
110 }
111
112 bool ProgressIndicator::isBuilt(void) const noexcept
113 {
114 return _built;
115 }
116
118 {
119 if (_built != built) {
120 _built = built;
121 setHasChanged(true);
122 }
123 return *this;
124 }
125
126 float ProgressIndicator::getDisplayed(void) const noexcept
127 {
128 return _displayed;
129 }
130
132 {
133 if (_displayed != displayed) {
134 _displayed = displayed;
135 setHasChanged(true);
136 }
137 return *this;
138 }
139
140 float ProgressIndicator::getValueFrom(void) const noexcept
141 {
142 return _valueFrom;
143 }
144
146 {
147 if (_valueFrom != value) {
148 _valueFrom = value;
149 setHasChanged(true);
150 }
151 return *this;
152 }
153
154 bool ProgressIndicator::isVisible(void) const noexcept
155 {
156 return _visible;
157 }
158
160 {
161 if (_visible != visible) {
162 _visible = visible;
163 setHasChanged(true);
164 }
165 return *this;
166 }
167
168 float ProgressIndicator::getOpacity(void) const noexcept
169 {
170 return _opacity;
171 }
172
174 {
175 if (_opacity != opacity) {
176 _opacity = opacity;
177 setHasChanged(true);
178 }
179 return *this;
180 }
181
182 float ProgressIndicator::getOpacityFrom(void) const noexcept
183 {
184 return _opacityFrom;
185 }
186
188 {
189 if (_opacityFrom != opacity) {
190 _opacityFrom = opacity;
191 setHasChanged(true);
192 }
193 return *this;
194 }
195
196 float ProgressIndicator::getCycle(void) const noexcept
197 {
198 return _cycle;
199 }
200
202 {
203 if (_cycle != cycle) {
204 _cycle = cycle;
205 setHasChanged(true);
206 }
207 return *this;
208 }
209
210 const std::optional<utility::graphic::Color32Bit> &
212 {
213 return _indicatorColor;
214 }
215
217 const std::optional<utility::graphic::Color32Bit> &color)
218 {
219 if (_indicatorColor != color) {
220 _indicatorColor = color;
221 setHasChanged(true);
222 }
223 return *this;
224 }
225} // namespace guillaume::components
State of a progress indicator: a bar or a ring that fills up with a value from 0 to 1,...
float getDiameter(void) const noexcept
Get the diameter of the circular variants.
ProgressIndicator & setIndicatorColor(const std::optional< utility::graphic::Color32Bit > &color)
Choose the color of the fill.
ProgressIndicator & setDisplayed(float displayed)
Store the value currently drawn.
bool isCircular(void) const noexcept
Tell whether the indicator is a ring.
float getValueFrom(void) const noexcept
Get the value that was drawn when the running transition began.
bool isVisible(void) const noexcept
Tell whether the indicator is meant to be visible.
float getOpacity(void) const noexcept
Get the opacity the indicator is drawn with.
ProgressIndicator & setOpacity(float opacity)
Store the opacity the indicator is drawn with.
ProgressIndicator & setTrackLength(float length)
Set the length of the track of the linear variants.
ProgressIndicator & setDiameter(float diameter)
Set the diameter of the circular variants.
ProgressIndicator(void)=default
Create the state of a visible linear determinate indicator with the default sizes and no child.
const std::optional< utility::graphic::Color32Bit > & getIndicatorColor(void) const noexcept
Get the color chosen for the fill.
ProgressIndicator & setVariant(Variant variant)
Set the shape of the indicator and whether it shows a value.
ProgressIndicator & setOpacityFrom(float opacity)
Store the opacity at the start of a fade.
ProgressIndicator & setCycle(float cycle)
Store how far the loop of an indeterminate variant has advanced.
ProgressIndicator & setBuilt(bool built)
Record whether the track and fill children match the current variant.
Variant
Shape of the indicator and whether it shows a value.
Variant getVariant(void) const noexcept
Get the shape of the indicator and whether it shows a value.
float getTrackLength(void) const noexcept
Get the length of the track of the linear variants.
float getCycle(void) const noexcept
Get how far the loop of an indeterminate variant has advanced.
ecs::Entity::Identifier getTrack(void) const noexcept
Get the child that draws the track: the full bar or ring behind the fill.
bool isIndeterminate(void) const noexcept
Tell whether the indicator loops instead of showing a value.
ProgressIndicator & setVisible(bool visible)
Record whether the indicator is meant to be visible.
ProgressIndicator & setFill(ecs::Entity::Identifier identifier)
Record the child that draws the fill.
ProgressIndicator & setTrack(ecs::Entity::Identifier identifier)
Record the child that draws the track.
float getOpacityFrom(void) const noexcept
Get the opacity the indicator had when the running fade began.
float getDisplayed(void) const noexcept
Get the value currently drawn.
bool isBuilt(void) const noexcept
Tell whether the track and fill children match the current variant.
ProgressIndicator & setValueFrom(float value)
Store the value drawn at the start of a transition.
ecs::Entity::Identifier getFill(void) const noexcept
Get the child that draws the fill: the part of the bar or ring that shows the progress.
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.