guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::components::LoadingIndicator Class Reference

State of a loading indicator: an arc that turns, or a bar that slides, in a loop while something is in progress. More...

#include <headers/guillaume/components/loading_indicator.hpp>

Inheritance diagram for guillaume::components::LoadingIndicator:
Collaboration diagram for guillaume::components::LoadingIndicator:

Public Types

enum class  Variant { Linear , Circular }
 Shape of the indicator. More...

Public Member Functions

 LoadingIndicator (void)=default
 Create the state of a circular indicator of the default size, with no child, that hides when stopped.
 ~LoadingIndicator (void)=default
 Default destructor.
Variant getVariant (void) const noexcept
 Get the shape of the indicator.
LoadingIndicator & setVariant (Variant variant)
 Set the shape of the indicator.
float getSize (void) const noexcept
 Get the diameter of the circular variant.
LoadingIndicator & setSize (float size)
 Set the diameter of the circular variant.
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.
bool isBuilt (void) const noexcept
 Tell whether the animated child matches the current variant.
LoadingIndicator & setBuilt (bool built)
 Record whether the animated child matches the current variant.
float getProgress (void) const noexcept
 Get how far the loop has advanced.
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.
LoadingIndicator & setHidesWhenStopped (bool hides)
 Choose whether the indicator fades out when it is stopped.
float getOpacity (void) const noexcept
 Get the opacity the indicator is drawn with.
LoadingIndicator & setOpacity (float opacity)
 Store the opacity the indicator is drawn with.
float getOpacityFrom (void) const noexcept
 Get the opacity the indicator had when the running fade began.
LoadingIndicator & setOpacityFrom (float opacity)
 Store the opacity at the start of a fade.
float getOpacityTarget (void) const noexcept
 Get the opacity the running fade ends at.
LoadingIndicator & setOpacityTarget (float opacity)
 Store the opacity a fade ends at.
const std::optional< utility::graphic::Color32Bit > & getIndicatorColor (void) const noexcept
 Get the color chosen for the indicator.
LoadingIndicator & setIndicatorColor (const std::optional< utility::graphic::Color32Bit > &color)
 Choose the color of the indicator.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Static Public Attributes

static constexpr float LinearWidth = 200.0f
 Length of the linear variant, in dp.
static constexpr float LinearHeight = 4.0f
 Thickness of the linear variant, in dp.
static constexpr float LinearSegment = 0.4f
static constexpr float DefaultSize = 48.0f
 Default diameter of the circular variant, in dp.
static constexpr float StrokeRatio = 4.0f / 48.0f

Detailed Description

State of a loading indicator: an arc that turns, or a bar that slides, in a loop while something is in progress.

It holds two kinds of state. The configuration (variant, diameter, color, whether it hides when stopped) and the identifier of the animated child are written by the entities::LoadingIndicator widget. The running state (loop progress, fade opacity) is written by systems::LoadingIndicator from the animations it installs. In the Layout phase, systems::LoadingIndicator turns all of it into the size of the widget and the geometry and color of the child.

Whether the indicator runs is not stored here: it is whether the looping components::Animation of the child plays. Use systems::LoadingIndicator::start and systems::LoadingIndicator::stop.

See also
systems::LoadingIndicator, components::ProgressIndicator, entities::LoadingIndicator

Definition at line 54 of file loading_indicator.hpp.

Member Enumeration Documentation

◆ Variant

Shape of the indicator.

Enumerator
Linear 

Bar that slides along a 200 dp line.

Circular 

Arc that turns around a circle.

Definition at line 60 of file loading_indicator.hpp.

Member Function Documentation

◆ getIndicator()

ecs::Entity::Identifier guillaume::components::LoadingIndicator::getIndicator ( void ) const
noexcept

Get the child that draws the turning arc or the sliding bar.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier when it has not been built.

Definition at line 55 of file loading_indicator.cpp.

◆ getIndicatorColor()

const std::optional< utility::graphic::Color32Bit > & guillaume::components::LoadingIndicator::getIndicatorColor ( void ) const
noexcept

Get the color chosen for the indicator.

Returns
The color, or std::nullopt when the indicator uses the theme's Primary color.

Definition at line 155 of file loading_indicator.cpp.

◆ getOpacity()

float guillaume::components::LoadingIndicator::getOpacity ( void ) const
noexcept

Get the opacity the indicator is drawn with.

Returns
The opacity, 0 (hidden) to 1 (fully visible).

Definition at line 112 of file loading_indicator.cpp.

◆ getOpacityFrom()

float guillaume::components::LoadingIndicator::getOpacityFrom ( void ) const
noexcept

Get the opacity the indicator had when the running fade began.

Returns
The starting opacity, 0 to 1.

Definition at line 126 of file loading_indicator.cpp.

◆ getOpacityTarget()

float guillaume::components::LoadingIndicator::getOpacityTarget ( void ) const
noexcept

Get the opacity the running fade ends at.

Returns
1 while the indicator runs or stays visible when stopped, 0 when it is stopped and hides.

Definition at line 140 of file loading_indicator.cpp.

◆ getProgress()

float guillaume::components::LoadingIndicator::getProgress ( void ) const
noexcept

Get how far the loop has advanced.

Returns
The eased progress of the current loop, 0 to 1.

Definition at line 84 of file loading_indicator.cpp.

◆ getSize()

float guillaume::components::LoadingIndicator::getSize ( void ) const
noexcept

Get the diameter of the circular variant.

Returns
The diameter, in dp.

Definition at line 41 of file loading_indicator.cpp.

◆ getVariant()

LoadingIndicator::Variant guillaume::components::LoadingIndicator::getVariant ( void ) const
noexcept

Get the shape of the indicator.

Returns
The variant, Variant::Circular by default.

Definition at line 27 of file loading_indicator.cpp.

◆ hidesWhenStopped()

bool guillaume::components::LoadingIndicator::hidesWhenStopped ( void ) const
noexcept

Tell whether the indicator fades out when it is stopped.

Returns
True when a stopped indicator is hidden, which is the default; false when it stays visible, frozen in place.

Definition at line 98 of file loading_indicator.cpp.

◆ isBuilt()

bool guillaume::components::LoadingIndicator::isBuilt ( void ) const
noexcept

Tell whether the animated child matches the current variant.

Returns
True once the widget has built it; false for a new component and after the widget changes the variant.

Definition at line 70 of file loading_indicator.cpp.

◆ setBuilt()

LoadingIndicator & guillaume::components::LoadingIndicator::setBuilt ( bool built)

Record whether the animated child matches the current variant.

The widget lowers the flag when it changes the variant and raises it once it has rebuilt the child. Marks the component changed only when the flag differs.

Parameters
builtTrue when the child is up to date.
Returns
This component, for chaining.

Definition at line 75 of file loading_indicator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHidesWhenStopped()

LoadingIndicator & guillaume::components::LoadingIndicator::setHidesWhenStopped ( bool hides)

Choose whether the indicator fades out when it is stopped.

The choice is applied the next time the indicator starts or stops. Marks the component changed only when the flag differs.

Parameters
hidesTrue to hide a stopped indicator.
Returns
This component, for chaining.

Definition at line 103 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setIndicator()

LoadingIndicator & guillaume::components::LoadingIndicator::setIndicator ( ecs::Entity::Identifier identifier)

Record the child that draws the turning arc or the sliding bar.

Marks the component changed only when the identifier differs.

Parameters
identifierThe child's identifier.
Returns
This component, for chaining.

Definition at line 61 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setIndicatorColor()

LoadingIndicator & guillaume::components::LoadingIndicator::setIndicatorColor ( const std::optional< utility::graphic::Color32Bit > & color)

Choose the color of the indicator.

Marks the component changed only when the value differs.

Parameters
colorThe color, or std::nullopt to use the theme's Primary color.
Returns
This component, for chaining.

Definition at line 160 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setOpacity()

LoadingIndicator & guillaume::components::LoadingIndicator::setOpacity ( float opacity)

Store the opacity the indicator is drawn with.

Running state written by systems::LoadingIndicator on every sample of the fade. Marks the component changed only when the value differs.

Parameters
opacityThe opacity, 0 to 1.
Returns
This component, for chaining.

Definition at line 117 of file loading_indicator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setOpacityFrom()

LoadingIndicator & guillaume::components::LoadingIndicator::setOpacityFrom ( float opacity)

Store the opacity at the start of a fade.

Marks the component changed only when the value differs.

Parameters
opacityThe starting opacity, 0 to 1.
Returns
This component, for chaining.

Definition at line 131 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setOpacityTarget()

LoadingIndicator & guillaume::components::LoadingIndicator::setOpacityTarget ( float opacity)

Store the opacity a fade ends at.

Written by systems::LoadingIndicator when the indicator starts or stops. Marks the component changed only when the value differs.

Parameters
opacityThe final opacity, 0 to 1.
Returns
This component, for chaining.

Definition at line 145 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setProgress()

LoadingIndicator & guillaume::components::LoadingIndicator::setProgress ( float progress)

Store how far the loop has advanced.

Running state written by the looping animation of the child. It sets the start angle of the arc or the position of the bar. Marks the component changed only when the value differs.

Parameters
progressThe eased progress of the current loop, 0 to 1.
Returns
This component, for chaining.

Definition at line 89 of file loading_indicator.cpp.

Here is the call graph for this function:

◆ setSize()

LoadingIndicator & guillaume::components::LoadingIndicator::setSize ( float size)

Set the diameter of the circular variant.

The stroke width follows it (StrokeRatio). The linear variant ignores it. Marks the component changed only when the value differs.

Parameters
sizeThe new diameter, in dp.
Returns
This component, for chaining.

Definition at line 46 of file loading_indicator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVariant()

LoadingIndicator & guillaume::components::LoadingIndicator::setVariant ( Variant variant)

Set the shape of the indicator.

The child depends on the variant; this setter does not rebuild it, the widget does. Marks the component changed only when the variant differs.

Parameters
variantThe new variant.
Returns
This component, for chaining.

Definition at line 32 of file loading_indicator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ DefaultSize

float guillaume::components::LoadingIndicator::DefaultSize = 48.0f
staticconstexpr

Default diameter of the circular variant, in dp.

Definition at line 76 of file loading_indicator.hpp.

◆ LinearHeight

float guillaume::components::LoadingIndicator::LinearHeight = 4.0f
staticconstexpr

Thickness of the linear variant, in dp.

Definition at line 69 of file loading_indicator.hpp.

◆ LinearSegment

float guillaume::components::LoadingIndicator::LinearSegment = 0.4f
staticconstexpr

Length of the sliding bar, as a fraction of the linear length (0 to 1).

Definition at line 73 of file loading_indicator.hpp.

◆ LinearWidth

float guillaume::components::LoadingIndicator::LinearWidth = 200.0f
staticconstexpr

Length of the linear variant, in dp.

Definition at line 66 of file loading_indicator.hpp.

◆ StrokeRatio

float guillaume::components::LoadingIndicator::StrokeRatio = 4.0f / 48.0f
staticconstexpr

Stroke width of the arc, as a fraction of the diameter: 4 dp for a 48 dp indicator.

Definition at line 80 of file loading_indicator.hpp.


The documentation for this class was generated from the following files: