27#include "guillaume/ecs/component.hpp"
59 using Handler = std::function<void(
float)>;
64 float _value { 0.0f };
190 float sanitize(
float value)
const;
float getStep(void) const
Get the snapping step.
~Value(void)=default
Default destructor for the Value component.
float getNormalizedValue(void) const
Get where the value sits in its range.
std::function< void(float)> Handler
Callback receiving the new value, already clamped and snapped.
Value & setMin(float min)
Set the lower bound of the range.
Value(void)=default
Create a value of 0 in the range 0 to 1, without snapping.
Handler getOnChangedHandler(void) const
Get the callback run when the value changes.
Value & setOnChangedHandler(const Handler &handler)
Set the callback run when the value changes.
float getValue(void) const
Get the current value.
float getMin(void) const
Get the lower bound of the range.
Value & setNormalizedValue(float normalized)
Set the value from its position in the range.
float getMax(void) const
Get the upper bound of the range.
Value & setValue(float value)
Set the current value.
Value & setMax(float max)
Set the upper bound of the range.
Value & setStep(float step)
Set the snapping step.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
State. Every class here is plain data attached to an entity.