ImFusion SDK 4.3
Animation Class Reference

#include <ImFusion/GUI/Animations.h>

Helper class to define an animation, that is an interpolated transition between two states. More...

+ Inheritance diagram for Animation:

Detailed Description

Helper class to define an animation, that is an interpolated transition between two states.

Animations are managed by the AnimationBackend, which takes care of calling the update() function at a regular time interval with the progress value t interpolated between 0.0 and 1.0 according to the duration and time passed since start. Regular (non-looped) animations are guaranteed to always be called with the value 1.0 at the end to ensure that the final state is reached. The frequency and granularity of intermediate update calls (and looped animations) are subject to the system load as well as the concrete implementation of the underlying backend.

An Animation provides two different means to notify the receiver about updates:

  • You can pass a callback to the constructor. In this case you have to manually ensure that the lifetime of the animation does not exceed the captured objects in the callback.
  • You can subscribe to signalUpdated which enables you to utilize the lifetime management of the SignalReceiver interface in case the caller implements it.
See also
The runAnimation() and runLoopedAnimation() convenience functions that will execute the animation on the currently installed global backend.

Public Types

enum class  State { Created , Running , Cancelled , Finished }
 Enumeration of possible animation states. More...
 

Public Member Functions

 Animation (std::function< void(double t)> &&updateFunc=nullptr)
 Create a new Animation instance with an EasingCurve::InOutCubic by default.
 
std::chrono::milliseconds duration () const
 Returns the duration of a single iteration of the animation.
 
void setDuration (std::chrono::milliseconds duration)
 Sets the duration of a single iteration of the animation; must not be changed after starting the animation.
 
bool isLooped () const
 Returns whether this animation is looped endlessly or not.
 
void setLooped (bool value)
 Sets whether this animation is looped endlessly or not; must not be changed after starting the animation.
 
void setEasingCurve (EasingCurve curve)
 Sets the easing curve to one of the built-in ones.
 
void setEasingCurve (std::function< double(double t)> &&easingCurveFunc)
 Sets a custom easing curve.
 
State state () const
 Returns the current state of the animation.
 
void cancel ()
 Cancels the animation without.
 
void update (double t) const
 To be called by the backend; applies the easing curve and calls the m_updateFunc as well as signalUpdated with the result.
 

Public Attributes

ProtectedSignal< double > signalUpdated
 Signal emitted at regular time intervals while the animation is running.
 
ProtectedSignal< StatesignalStateChanged
 Signal emitted whenever the state of the animation has changed.
 
ProtectedSignal signalConfigChanged
 Signal emitted whenever the duration, or isLooped state has changed.
 

Member Enumeration Documentation

◆ State

enum class State
strong

Enumeration of possible animation states.

Enumerator
Created 

Created but not started.

Running 

Started and still running.

Cancelled 

Cancelled before the final state was reached.

Finished 

Completed after the final state was reached.

Constructor & Destructor Documentation

◆ Animation()

Animation ( std::function< void(double t)> && updateFunc = nullptr)
explicit

Create a new Animation instance with an EasingCurve::InOutCubic by default.

Parameters
updateFuncOptional callback function that is called by the backend at regular time intervals with t having values interpolated between 0.0 and 1.0 according to the duration and time passed since start.

Member Function Documentation

◆ setEasingCurve()

void setEasingCurve ( std::function< double(double t)> && easingCurveFunc)

Sets a custom easing curve.

Parameters
easingCurveFuncInterpolation function receiving a value t between 0.0 and 1.0. The function must return a value between 0.0 and 1.0 for all input.

Member Data Documentation

◆ signalUpdated

ProtectedSignal<double> signalUpdated

Signal emitted at regular time intervals while the animation is running.

The values are interpolated between 0.0 and 1.0 according to the duration and time passed since start.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close