FadeAnimator
touchgfx/mixins/FadeAnimator.hpp
A FadeAnimator makes the template class T able to animate the alpha value from its current value to a specified end value. It is possible to use a fade in effect as well as fade out effect using FadeAnimator. The alpha progression can be described by supplying an EasingEquation. The FadeAnimator performs a callback when the animation has finished.
This mixin can be used on any Drawable that has a 'void setAlpha(uint8_t)' and a 'uint8_t getAlpha()' method.
Template Parameters:
- T specifies the type to extend with the FadeAnimator behavior.
Inherits from: T
Public Functions
void | cancelFadeAnimation() |
Cancel fade animation. | |
void | clearFadeAnimationEndedAction() |
Clears the fade animation ended action previously set by setFadeAnimationEndedAction. | |
FadeAnimator() | |
virtual uint16_t | getFadeAnimationDelay() const |
Gets the current animation delay. | |
virtual void | handleTickEvent() |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks. | |
bool | isFadeAnimationRunning() const |
Gets whether or not the fade animation is running. | |
virtual void | setFadeAnimationDelay(uint16_t delay) |
Sets a delay before the actual animation starts for the animation done by the FadeAnimator. | |
void | setFadeAnimationEndedAction(GenericCallback< const FadeAnimator< T > & > & callback) |
Associates an action to be performed when the animation ends. | |
void | startFadeAnimation(uint8_t endAlpha, uint16_t duration, EasingEquation alphaProgressionEquation =&EasingEquations::linearEaseNone) |
Starts the fade animation from the current alpha value to the specified end alpha value. | |
Protected Functions
void | nextFadeAnimationStep() |
Execute next step in fade animation and stop the timer if necessary. | |
Protected Attributes
EasingEquation | fadeAnimationAlphaEquation |
EasingEquation expressing the progression of the alpha value during the animation. | |
uint16_t | fadeAnimationCounter |
To the current step in the animation. | |
uint16_t | fadeAnimationDelay |
A delay that is applied before animation start. Expressed in ticks. | |
uint16_t | fadeAnimationDuration |
The complete duration of the animation. Expressed in ticks. | |
int16_t | fadeAnimationEndAlpha |
The alpha value at the end of the animation. | |
GenericCallback< const FadeAnimator< T > & > * | fadeAnimationEndedCallback |
Animation ended Callback. | |
bool | fadeAnimationRunning |
True if the animation is running. | |
int16_t | fadeAnimationStartAlpha |
The alpha value at the beginning of the animation. | |
Public Functions Documentation
cancelFadeAnimation
void cancelFadeAnimation | ( | ) |
Cancel fade animation.
The animation is stopped and the alpha value is left where it currently is.
clearFadeAnimationEndedAction
Clears the fade animation ended action previously set by setFadeAnimationEndedAction.
Clears the fade animation ended action previously set by setFadeAnimationEndedAction.
FadeAnimator
getFadeAnimationDelay
virtual uint16_t getFadeAnimationDelay | ( | ) | const |
Gets the current animation delay.
The current animation delay.
handleTickEvent
virtual void handleTickEvent | ( | ) |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
isFadeAnimationRunning
bool isFadeAnimationRunning | ( | ) | const |
Gets whether or not the fade animation is running.
true if the fade animation is running.
setFadeAnimationDelay
virtual void setFadeAnimationDelay | ( | uint16_t | delay | ) | |
Sets a delay before the actual animation starts for the animation done by the FadeAnimator.
delay | The delay in ticks. |
setFadeAnimationEndedAction
void setFadeAnimationEndedAction | ( | GenericCallback< const FadeAnimator< T > & > & | callback | ) | |
Associates an action to be performed when the animation ends.
callback | The callback to be executed. The callback will be given a reference to the FadeAnimator. |
startFadeAnimation
void startFadeAnimation | ( | uint8_t | endAlpha , | ||
uint16_t | duration , | ||||
EasingEquation | alphaProgressionEquation =&EasingEquations::linearEaseNone | ||||
) |
Starts the fade animation from the current alpha value to the specified end alpha value.
The progression of the alpha value during the animation is described by the supplied EasingEquation.
endAlpha | The alpha value of T at animation end. |
duration | The duration of the animation measured in ticks. |
alphaProgressionEquation | (Optional) The equation that describes the development of the alpha value during the animation. Default is EasingEquations::linearEaseNone. |
Protected Functions Documentation
nextFadeAnimationStep
void nextFadeAnimationStep | ( | ) |
Execute next step in fade animation and stop the timer if necessary.
Protected Attributes Documentation
fadeAnimationAlphaEquation
EasingEquation fadeAnimationAlphaEquation
EasingEquation expressing the progression of the alpha value during the animation.
fadeAnimationCounter
uint16_t fadeAnimationCounter
To the current step in the animation.
fadeAnimationDelay
uint16_t fadeAnimationDelay
A delay that is applied before animation start. Expressed in ticks.
fadeAnimationDuration
uint16_t fadeAnimationDuration
The complete duration of the animation. Expressed in ticks.
fadeAnimationEndAlpha
int16_t fadeAnimationEndAlpha
The alpha value at the end of the animation.
fadeAnimationEndedCallback
GenericCallback< const FadeAnimator< T > & > * fadeAnimationEndedCallback
Animation ended Callback.
fadeAnimationRunning
bool fadeAnimationRunning
True if the animation is running.
fadeAnimationStartAlpha
int16_t fadeAnimationStartAlpha
The alpha value at the beginning of the animation.