Loading...
Searching...
No Matches
Animator Class Reference

Wrapper class for managing the lifetime of all the different animator kinds created through the builder classes. More...

#include <juce_Animator.h>

Classes

struct  Compare
 Comparison function used by the implementation to store Animators in ordered collections. More...
 
class  Weak
 

Public Types

enum class  Status { idle , inProgress , finished }
 The state of an Animator that determines how AnimatorUpdaters and other Animators will interact with it. More...
 

Public Member Functions

 Animator (std::shared_ptr< Impl >)
 
double getDurationMs () const
 Returns the total animation duration in milliseconds.
 
void start () const
 Marks the Animator ready for starting.
 
void complete () const
 Marks the Animator ready to be completed.
 
Status update (double timestampMs) const
 Called periodically for active Animators by the AnimatorUpdater classes.
 
bool isComplete () const
 Returns true if the Animator has reached the point of completion either because complete() has been called on it, or in case of the ValueAnimator, if it reached a progress of >= 1.0.
 
Weak makeWeak () const
 

Detailed Description

Wrapper class for managing the lifetime of all the different animator kinds created through the builder classes.

It uses reference counting. If you copy an Animator the resulting object will refer to the same underlying instance, and the underlying instance is guaranteed to remain valid for as long as you have an Animator object referencing it.

An Animator object can be registered with the AnimatorUpdater, which only stores a weak reference to the underlying instance. If an AnimatorUpdater references the underlying instance and it becomes deleted due to all Animator objects being deleted, the updater will automatically remove it from its queue, so manually removing it is not required.

See also
ValueAnimatorBuilder, AnimatorSetBuilder, AnimatorUpdater, VBlankAnimatorUpdater

Member Enumeration Documentation

◆ Status

enum class Animator::Status
strong

The state of an Animator that determines how AnimatorUpdaters and other Animators will interact with it.

Enumerator
idle 

The Animator is idle and its state is not progressing even if it is attached to an AnimatorUpdater.

inProgress 

The Animator is active and its state is progressing whenever its update function is called.

finished 

The Animator finished its run and its onCompletion callback may be called.

It requires no further calls to its update function.

Constructor & Destructor Documentation

◆ Animator()

Animator::Animator ( std::shared_ptr< Impl > )
explicit

Member Function Documentation

◆ getDurationMs()

double Animator::getDurationMs ( ) const

Returns the total animation duration in milliseconds.

◆ start()

void Animator::start ( ) const

Marks the Animator ready for starting.

You must call this function to allow the Animator to move out of the idle state.

After calling this function the Animator's on start callback will be executed at the next update immediately followed by the first call to it's update function.

You can call this function before or after adding the Animator to an AnimatorUpdater. Until start() is called the Animator will just sit idly in the updater's queue.

◆ complete()

void Animator::complete ( ) const

Marks the Animator ready to be completed.

ValueAnimators will be completed automatically when they reach a progress >= 1.0 unless they are infinitely running. AnimatorSets will also complete on their own when all of their constituent Animators complete.

Using this function you can fast track the completion of an Animator. After calling this function isComplete will return true, and it's guaranteed that you will receive an update callback with a progress value of 1.0. After this the onComplete callback will be executed.

◆ update()

Status Animator::update ( double timestampMs) const

Called periodically for active Animators by the AnimatorUpdater classes.

The passed in timestamp must be monotonically increasing. This allows the underlying Animator to follow its progression towards completion.

While you can call this function in special circumstances, you will generally want an AnimatorUpdater to do it. Using the VBlankAnimatorUpdater ensures that update is called in sync with the monitor's vertical refresh resulting in smooth animations.

See also
AnimatorUpdater, VBlankAnimatorUpdater

◆ isComplete()

bool Animator::isComplete ( ) const

Returns true if the Animator has reached the point of completion either because complete() has been called on it, or in case of the ValueAnimator, if it reached a progress of >= 1.0.

You typically don't need to call this function, because in any case a completed Animator will receive an update callback with a progress value of 1.0 and following that the on complete callback will be called.

◆ makeWeak()

Weak Animator::makeWeak ( ) const

The documentation for this class was generated from the following file:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram