Skip to content

AAnimator#

Base class for view animations.

Header:#include <AUI/Animator/AAnimator.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

An animator changes how a view is painted over time: it moves, rotates or resizes it. Create an animator, configure and assign it to a view with AView::setAnimator. The animation starts immediately, the view is repainted continuously until the animation ends.

auto animator = _new<ATranslationAnimator>(glm::vec2 { -100, 0 });   // from (-100, 0) to the actual position
animator->setDuration(0.3f);                                         // seconds
view->setAnimator(animator);

Ready-to-use animators:

  • ATranslationAnimator moves the view from one offset to another;
  • ARotationAnimator rotates the view between two angles (AAngleRadians, i.e., 90_deg);
  • ASizeAnimator changes the size of the view;
  • AFocusAnimator is used by AUI itself for the focus highlight.

setRepeating(true) makes an animation loop endlessly, which fits a progress indicator. setCurve replaces the default easing function with a custom float(float), i.e., aui::animation_curves::Linear or aui::animation_curves::CubicBezier.

Several animators can be merged with AAnimator::combine({ a, b }).

To implement your own animator, derive from AAnimator and override doAnimation, which receives the animation progress theta (from 0 to 1) and the renderer to apply a transform to.

Public Methods#

doAnimation#


virtual void AAnimator::doAnimation(AView* view, float theta, IRenderer& render)

Does the animation (sets matrix, colors, etc...)

Arguments
view
target view to perform animation for.
theta
animation time value from 0 to 1 where 0 - start of the animation, 1 - end of the animation.
render
renderer.