|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
A number kept inside a range, with a callback run when it changes. More...
#include <headers/guillaume/components/value.hpp>


Public Types | |
| using | Handler = std::function<void(float)> |
| Callback receiving the new value, already clamped and snapped. | |
Public Member Functions | |
| Value (void)=default | |
| Create a value of 0 in the range 0 to 1, without snapping. | |
| ~Value (void)=default | |
| Default destructor for the Value component. | |
| float | getMin (void) const |
| Get the lower bound of the range. | |
| Value & | setMin (float min) |
| Set the lower bound of the range. | |
| float | getMax (void) const |
| Get the upper bound of the range. | |
| Value & | setMax (float max) |
| Set the upper bound of the range. | |
| float | getValue (void) const |
| Get the current value. | |
| Value & | setValue (float value) |
| Set the current value. | |
| float | getStep (void) const |
| Get the snapping step. | |
| Value & | setStep (float step) |
| Set the snapping step. | |
| float | getNormalizedValue (void) const |
| Get where the value sits in its range. | |
| Value & | setNormalizedValue (float normalized) |
| Set the value from its position in the range. | |
| Value & | setOnChangedHandler (const Handler &handler) |
| Set the callback run when the value changes. | |
| Handler | getOnChangedHandler (void) const |
| Get the callback run when the value changes. | |
| 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. | |
A number kept inside a range, with a callback run when it changes.
The value always lies within [min, max] (0 to 1 by default) and is snapped to a multiple of step above min when step is strictly positive. The widget systems use it as the value of their widget: the fraction of a progress indicator (systems::ProgressIndicator), the on/off state of a switch (systems::Switch, 0 or 1 with a step of 1).
Watch out:
| using guillaume::components::Value::Handler = std::function<void(float)> |
| float guillaume::components::Value::getMax | ( | void | ) | const |
| float guillaume::components::Value::getMin | ( | void | ) | const |
| float guillaume::components::Value::getNormalizedValue | ( | void | ) | const |
| Value::Handler guillaume::components::Value::getOnChangedHandler | ( | void | ) | const |
| float guillaume::components::Value::getStep | ( | void | ) | const |
| float guillaume::components::Value::getValue | ( | void | ) | const |
| Value & guillaume::components::Value::setMax | ( | float | max | ) |
Set the upper bound of the range.
When the bound differs, marks the component changed, then clamps and snaps the current value again, which runs the handler if the value moves.
| max | The new maximum; it must not be below the minimum. |
Definition at line 51 of file value.cpp.


| Value & guillaume::components::Value::setMin | ( | float | min | ) |
Set the lower bound of the range.
When the bound differs, marks the component changed, then clamps and snaps the current value again, which runs the handler if the value moves.
| min | The new minimum; it must not exceed the maximum. |
Definition at line 35 of file value.cpp.


| Value & guillaume::components::Value::setNormalizedValue | ( | float | normalized | ) |
Set the value from its position in the range.
Same as setValue() with min + normalized * (max - min).
| normalized | The position, 0 to 1; values outside are clamped. |
Definition at line 105 of file value.cpp.

Set the callback run when the value changes.
Replaces the previous handler. Does not mark the component changed. The widget systems install their own handler here to restyle the widget.
| handler | The callback, or an empty one to remove it. |
Definition at line 111 of file value.cpp.


| Value & guillaume::components::Value::setStep | ( | float | step | ) |
Set the snapping step.
Marks the component changed when the step differs. The current value is not snapped again until the next setValue() or bound change.
| step | The distance between two allowed values, counted from the minimum; 0 or less disables snapping. |
Definition at line 86 of file value.cpp.


| Value & guillaume::components::Value::setValue | ( | float | value | ) |
Set the current value.
The value is clamped to [min, max] and snapped to the step first. When the result differs from the stored value, stores it, marks the component changed and calls the handler with it.
| value | The requested value, in the unit of the range. |
Definition at line 67 of file value.cpp.

