跳轉到主要內容

FadeAnimator

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

voidcancelFadeAnimation()
Cancel fade animation.
voidclearFadeAnimationEndedAction()
Clears the fade animation ended action previously set by setFadeAnimationEndedAction.
FadeAnimator()
virtual uint16_tgetFadeAnimationDelay() const
Gets the current animation delay.
virtual voidhandleTickEvent()
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
boolisFadeAnimationRunning() const
Gets whether or not the fade animation is running.
virtual voidsetFadeAnimationDelay(uint16_t delay)
Sets a delay before the actual animation starts for the animation done by the FadeAnimator.
voidsetFadeAnimationEndedAction(GenericCallback< const FadeAnimator< T > & > & callback)
Associates an action to be performed when the animation ends.
voidstartFadeAnimation(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

voidnextFadeAnimationStep()
Execute next step in fade animation and stop the timer if necessary.

Protected Attributes

EasingEquationfadeAnimationAlphaEquation
EasingEquation expressing the progression of the alpha value during the animation.
uint16_tfadeAnimationCounter
To the current step in the animation.
uint16_tfadeAnimationDelay
A delay that is applied before animation start. Expressed in ticks.
uint16_tfadeAnimationDuration
The complete duration of the animation. Expressed in ticks.
int16_tfadeAnimationEndAlpha
The alpha value at the end of the animation.
GenericCallback< const FadeAnimator< T > & > *fadeAnimationEndedCallback
Animation ended Callback.
boolfadeAnimationRunning
True if the animation is running.
int16_tfadeAnimationStartAlpha
The alpha value at the beginning of the animation.

Public Functions Documentation

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.

See also:

FadeAnimator

getFadeAnimationDelay

virtual uint16_t getFadeAnimationDelay()const

Gets the current animation delay.

Returns:

The current animation delay.

See also:

handleTickEvent

virtual void handleTickEvent()

Called periodically by the framework if the Drawable instance has subscribed to timer ticks.

See also:

isFadeAnimationRunning

Gets whether or not the fade animation is running.

Returns:

true if the fade animation is running.

setFadeAnimationDelay

virtual void setFadeAnimationDelay(uint16_tdelay)

Sets a delay before the actual animation starts for the animation done by the FadeAnimator.

Parameters:
delayThe delay in ticks.
See also:

setFadeAnimationEndedAction

Associates an action to be performed when the animation ends.

Parameters:
callbackThe callback to be executed. The callback will be given a reference to the FadeAnimator.

startFadeAnimation

void startFadeAnimation(uint8_tendAlpha ,
uint16_tduration ,
EasingEquationalphaProgressionEquation =&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.

Parameters:
endAlphaThe alpha value of T at animation end.
durationThe 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

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.