27#include "guillaume/ecs/component.hpp"
28#include "guillaume/motion/easing.hpp"
64 std::function<void(
float)>;
66 std::function<void(
void)>;
69 float _duration { 0.0f };
70 float _elapsed { 0.0f };
71 bool _playing {
false };
72 bool _looping {
false };
73 motion::Easing _easing {
74 motion::Easing::Standard
float getProgress(void) const
Get how far the current run is, before easing.
void advance(float deltaTime)
Move the animation forward in time and call the handlers.
float getElapsed(void) const
Get the time spent in the current run.
bool isLooping(void) const
Check whether the animation starts again when it completes.
CompleteHandler getOnCompleteHandler(void) const
Get the callback run when the animation reaches its duration.
motion::Easing getEasing(void) const
Get the curve that turns the linear progress into the value passed to the sample handler.
Animation & setEasing(motion::Easing easing)
Set the curve that turns the linear progress into the value passed to the sample handler.
std::function< void(void)> CompleteHandler
Called on completion.
Animation & setDuration(float duration)
Set how long one run of the animation lasts.
Animation & setElapsed(float elapsed)
Move the animation to a point in time, without calling any handler.
SampleHandler getOnSampleHandler(void) const
Get the callback that applies the animation.
Animation(void)
Construct a stopped animation lasting the Material 3 Medium2 motion duration of the theme.
Animation & setOnSampleHandler(const SampleHandler &handler)
Store the callback that applies the animation.
Animation & play(void)
Start the animation from the beginning, even when it is already running.
float getDuration(void) const
Get how long one run of the animation lasts.
Animation & setLooping(bool looping)
Set whether the animation starts again when it completes.
Animation & setOnCompleteHandler(const CompleteHandler &handler)
Store the callback run when the animation reaches its duration.
~Animation(void)=default
Default destructor.
Animation & stop(void)
Stop the animation and bring the elapsed time back to 0.
bool isPlaying(void) const
Check whether the animation is running.
std::function< void(float)> SampleHandler
Receives the eased progress.
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.