guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
loading_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/loading_indicator.hpp"
38
39#include "guillaume/entities/builder_base.hpp"
40#include "guillaume/entities/surface.hpp"
41
42namespace guillaume::entities
43{
44
90 class LoadingIndicator:
91 public SurfaceBase<components::Animation, components::Accessibility,
92 components::LoadingIndicator>
93 {
94 public:
98
103 class Builder: public EntityBuilderBase<LoadingIndicator>
104 {
105 private:
106 SurfaceConfig _config;
107 Variant _variant { Variant::Circular };
108 float _size { 48.0f };
109
110 public:
118 Builder(ecs::ComponentRegistry &componentRegistry,
119 ecs::EntityRegistry &entityRegistry);
120
127 std::shared_ptr<LoadingIndicator> buildEntity(void) override;
128
133 void reset(void) override;
134
141 Builder &withPose(const utility::graphic::PoseF &pose);
142
148 Builder &withVariant(Variant variant);
149
157 Builder &withSize(float size);
158
169 std::shared_ptr<LoadingIndicator>
170 makeLoadingIndicator(std::shared_ptr<ecs::Entity> parent,
171 Variant variant);
172 };
173
174 public:
188 template<typename... Arguments> static std::shared_ptr<LoadingIndicator>
189 create(Arguments &&...arguments)
190 {
191 std::shared_ptr<LoadingIndicator> entity(
192 new LoadingIndicator(std::forward<Arguments>(arguments)...));
193 entity->build();
194 return entity;
195 }
196
200 ~LoadingIndicator(void) override;
201
213
218 Variant getVariant(void) const;
219
227 LoadingIndicator &start(void);
228
237 LoadingIndicator &stop(void);
238
244 bool isRunning(void) const;
245
257
262 bool hidesWhenStopped(void) const;
263
269 float getOpacity(void) const;
270
278 setIndicatorColor(const utility::graphic::Color32Bit &color);
279
286 utility::graphic::Color32Bit getIndicatorColor(void) const;
287
298 LoadingIndicator &setSize(float size);
299
304 float getSize(void) const;
305
311 float getStrokeWidth(void) const;
312
313 private:
318 void buildChild(void);
319
320 private:
330 const SurfaceConfig &config, Variant variant);
331
338 void build(void);
339 };
340
341} // namespace guillaume::entities
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)
void reset(void) override
Restore the defaults: Circular variant, a 48 dp diameter and a default pose.
std::shared_ptr< LoadingIndicator > makeLoadingIndicator(std::shared_ptr< ecs::Entity > parent, Variant variant)
Build a loading indicator, register it under parent and reset the builder.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
Builder & withVariant(Variant variant)
Set the indicator variant.
Builder & withPose(const utility::graphic::PoseF &pose)
Set the pose the indicator is created with.
std::shared_ptr< LoadingIndicator > buildEntity(void) override
Build a loading indicator and its animated child from the current configuration, without registering ...
Builder & withSize(float size)
Set the diameter of the Circular variant.
An animation that loops for as long as work is in progress: a rotating arc or a sliding bar,...
float getSize(void) const
Get the diameter of the Circular variant.
float getStrokeWidth(void) const
Get the thickness of the arc of the Circular variant.
Variant getVariant(void) const
Get the indicator variant.
utility::graphic::Color32Bit getIndicatorColor(void) const
Get the color of the arc or bar.
float getOpacity(void) const
Get the opacity of the fade.
static std::shared_ptr< LoadingIndicator > create(Arguments &&...arguments)
Create a loading indicator and its animated child, without registering it in an entity registry.
LoadingIndicator & stop(void)
Stop the looping animation.
LoadingIndicator & start(void)
Start the looping animation and fade the indicator in over 200 ms.
components::LoadingIndicator::Variant Variant
LoadingIndicator & setIndicatorColor(const utility::graphic::Color32Bit &color)
Set the color of the arc or bar. Redraws at once.
LoadingIndicator & setSize(float size)
Set the diameter of the Circular variant (Paper size).
~LoadingIndicator(void) override
Default destructor.
bool hidesWhenStopped(void) const
Check whether a stopped indicator is hidden.
LoadingIndicator & setVariant(Variant variant)
Change the indicator variant.
bool isRunning(void) const
Check whether the looping animation is playing.
LoadingIndicator & setHidesWhenStopped(bool hides)
Choose whether a stopped indicator is hidden (Paper hidesWhenStopped).
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