guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
progress_indicator.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 <utility>
26#include <memory>
27#include <optional>
28
29#include <utility/graphic/color.hpp>
30#include <utility/graphic/pose.hpp>
31
32#include "guillaume/ecs/component_registry.hpp"
33#include "guillaume/ecs/entity_builder.hpp"
34
35#include "guillaume/components/accessibility.hpp"
36#include "guillaume/components/animation.hpp"
37#include "guillaume/components/progress_indicator.hpp"
38#include "guillaume/components/value.hpp"
39
40#include "guillaume/entities/builder_base.hpp"
41#include "guillaume/entities/surface.hpp"
42
43namespace guillaume::entities
44{
45
104 class ProgressIndicator:
105 public SurfaceBase<components::Value, components::Animation,
106 components::Accessibility,
107 components::ProgressIndicator>
108 {
109 public:
113
118 class Builder: public EntityBuilderBase<ProgressIndicator>
119 {
120 private:
121 SurfaceConfig _config;
122 Variant _variant { Variant::LinearDeterminate };
123 float _value { 0.0f };
124 float _width { 200.0f };
125 float _size { 48.0f };
126
127 public:
135 Builder(ecs::ComponentRegistry &componentRegistry,
136 ecs::EntityRegistry &entityRegistry);
137
144 std::shared_ptr<ProgressIndicator> buildEntity(void) override;
145
150 void reset(void) override;
151
158 Builder &withPose(const utility::graphic::PoseF &pose);
159
166 Builder &withVariant(Variant variant);
167
174 Builder &withValue(float value);
175
182 Builder &withWidth(float width);
183
190 Builder &withSize(float size);
191
204 std::shared_ptr<ProgressIndicator>
205 makeProgressIndicator(std::shared_ptr<ecs::Entity> parent,
206 Variant variant, float value);
207 };
208
209 public:
224 template<typename... Arguments>
225 static std::shared_ptr<ProgressIndicator>
226 create(Arguments &&...arguments)
227 {
228 std::shared_ptr<ProgressIndicator> entity(
229 new ProgressIndicator(std::forward<Arguments>(arguments)...));
230 entity->build();
231 return entity;
232 }
233
237 ~ProgressIndicator(void) override;
238
250
255 Variant getVariant(void) const;
256
267 ProgressIndicator &setValue(float value);
268
274 float getValue(void) const;
275
281 float getDisplayedValue(void) const;
282
291 ProgressIndicator &setVisible(bool visible);
292
298 bool isVisible(void) const;
299
305 float getOpacity(void) const;
306
314 setIndicatorColor(const utility::graphic::Color32Bit &color);
315
322 utility::graphic::Color32Bit getIndicatorColor(void) const;
323
328 static constexpr float IndeterminateSegment =
330
331 private:
336 void buildChildren(void);
337
338 private:
350 ProgressIndicator(ecs::ComponentRegistry &registry,
351 const SurfaceConfig &config, Variant variant,
352 float value);
353
360 void build(void);
361 };
362
363} // namespace guillaume::entities
Variant
Shape of the indicator and whether it shows a value.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
std::shared_ptr< ProgressIndicator > makeProgressIndicator(std::shared_ptr< ecs::Entity > parent, Variant variant, float value)
Build a progress indicator, register it under parent and reset the builder.
Builder & withValue(float value)
Set the progress the indicator starts with.
Builder & withWidth(float width)
Set the length of the bar of the linear variants.
Builder & withSize(float size)
Set the diameter of the ring of the circular variants.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
Builder & withPose(const utility::graphic::PoseF &pose)
Set the pose the indicator is created with.
Builder & withVariant(Variant variant)
Set the indicator variant.
std::shared_ptr< ProgressIndicator > buildEntity(void) override
Build a progress indicator and its track and fill children from the current configuration,...
void reset(void) override
Restore the defaults: LinearDeterminate variant, value 0, a 200 dp long bar, a 48 dp wide ring and a ...
A bar or a ring that fills up to show how far a task has progressed, or that loops when the progress ...
Variant getVariant(void) const
Get the indicator variant.
ProgressIndicator & setVariant(Variant variant)
Change the indicator variant.
ProgressIndicator & setVisible(bool visible)
Show or hide the indicator with a 200 ms fade (Paper visible).
bool isVisible(void) const
Check whether the indicator is meant to be visible.
ProgressIndicator & setValue(float value)
Set the progress.
float getOpacity(void) const
Get the opacity of the fade.
float getValue(void) const
Get the progress last set.
static constexpr float IndeterminateSegment
Length of the sliding segment of the LinearIndeterminate variant, as a fraction of the bar length: 0....
components::ProgressIndicator::Variant Variant
static std::shared_ptr< ProgressIndicator > create(Arguments &&...arguments)
Create a progress indicator and its track and fill children, without registering it in an entity regi...
ProgressIndicator & setIndicatorColor(const utility::graphic::Color32Bit &color)
Set the color of the fill. Redraws at once.
utility::graphic::Color32Bit getIndicatorColor(void) const
Get the color of the fill.
float getDisplayedValue(void) const
Get the progress drawn at the moment.
~ProgressIndicator(void) override
Default destructor.
Widgets: the classes used to create entities with the right components and children.
Definition app_bar.hpp:46
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...
Definition surface.hpp:71