friz
An animation control system for JUCE
Loading...
Searching...
No Matches
friz::Animation< ValueCount > Class Template Reference

This class owns a number of AnimatedValue objects. On each animation frame it gets the next calculated value from each of the value objects and passes those values to its OnUpdate handler. When all of the values in the animation have reached their end states, calls the OnCompletion handler. More...

#include <animation.h>

Inheritance diagram for friz::Animation< ValueCount >:

Public Types

using SourceList = std::array< std::unique_ptr< AnimatedValue >, ValueCount >
 
using ValueList = typename UpdateSource< ValueCount >::ValueList
 
- Public Types inherited from friz::AnimationType
enum class  Status { processing , finished }
 
using CompletionFn = std::function< void(int, bool)>
 callback on completion of this effect
 
- Public Types inherited from friz::UpdateSource< ValueCount >
using ValueList = std::array< float, ValueCount >
 
using UpdateFn = std::function< void(int, const ValueList &)>
 

Public Member Functions

 Animation (int id=0)
 
 Animation (SourceList &&sources, int id=0)
 Construct a new Animation object, given a list of value sources.
 
bool setValue (size_t index, std::unique_ptr< AnimatedValue > value) override
 
AnimatedValuegetValue (size_t index) override
 Retrieve a pointer to one of this animation's value sources. This should probably not be used very much, if ever.
 
Status gotoTime (juce::int64 timeInMs) override
 Advance to the specified time, sending value updates to the code that's waiting for them.
 
void cancel (bool moveToEndPosition) override
 Cancel an in-progress animation, optionally moving directly to its end value.
 
bool isFinished () override
 
bool isReady () const override
 
- Public Member Functions inherited from friz::AnimationType
 AnimationType (int id)
 
int getId () const
 
void setDelay (int delay)
 
virtual bool setValue (size_t, std::unique_ptr< AnimatedValue >)
 
virtual Status gotoTime (juce::int64 timeInMs)=0
 Advance all active animations to this point in time.
 
virtual void cancel (bool moveToEndPosition)=0
 Cancel an in-progress animation, optionally moving directly to its end value.
 
virtual bool isFinished ()=0
 
virtual bool isReady () const =0
 
virtual AnimatedValuegetValue (size_t index)=0
 Retrieve a pointer to one of this animation's value objects.
 
void onCompletion (CompletionFn complete)
 
- Public Member Functions inherited from friz::UpdateSource< ValueCount >
void onUpdate (UpdateFn update)
 

Private Attributes

juce::int64 startTime { -1 }
 Timestamp of first update.
 
juce::int64 lastTime { -1 }
 timestamp of most recent update.
 
bool finished { false }
 is this animation complete?
 
SourceList sources
 The array of animated value objects.
 

Additional Inherited Members

- Public Attributes inherited from friz::AnimationType
CompletionFn completionFn
 function to call when the animation is completed or canceled.
 
- Public Attributes inherited from friz::UpdateSource< ValueCount >
UpdateFn updateFn
 
- Protected Attributes inherited from friz::AnimationType
int animationId { 0 }
 optional ID value for this animation.
 
int preDelay { 0 }
 an optional pre-delay before beginning to execute the effect.
 

Detailed Description

template<std::size_t ValueCount>
class friz::Animation< ValueCount >

This class owns a number of AnimatedValue objects. On each animation frame it gets the next calculated value from each of the value objects and passes those values to its OnUpdate handler. When all of the values in the animation have reached their end states, calls the OnCompletion handler.

Once this animation is complete, the Animator object that owns it will garbage collect it.

Constructor & Destructor Documentation

◆ Animation() [1/2]

template<std::size_t ValueCount>
friz::Animation< ValueCount >::Animation ( int  id = 0)
inline

Create an animation object that can be populated with changing values and functions to call at important points (each frame of animation, sequence completion)

Parameters
idOptional identifier, use as you wish. We don't enforce uniqueness, for example. Must be >= 0.

◆ Animation() [2/2]

template<std::size_t ValueCount>
friz::Animation< ValueCount >::Animation ( SourceList &&  sources,
int  id = 0 
)
inline

Construct a new Animation object, given a list of value sources.

Parameters
sourcesList of animated value objects.
id

Member Function Documentation

◆ cancel()

template<std::size_t ValueCount>
void friz::Animation< ValueCount >::cancel ( bool  moveToEndPosition)
inlineoverridevirtual

Cancel an in-progress animation, optionally moving directly to its end value.

Parameters
moveToEndPositionif true, go immediately to the end value.

Implements friz::AnimationType.

◆ getValue()

template<std::size_t ValueCount>
AnimatedValue * friz::Animation< ValueCount >::getValue ( size_t  index)
inlineoverridevirtual

Retrieve a pointer to one of this animation's value sources. This should probably not be used very much, if ever.

Parameters
index
Returns
AnimatedValue*

Implements friz::AnimationType.

◆ gotoTime()

template<std::size_t ValueCount>
Status friz::Animation< ValueCount >::gotoTime ( juce::int64  timeInMs)
inlineoverridevirtual

Advance to the specified time, sending value updates to the code that's waiting for them.

Parameters
timeInMsnumber of milliseconds since some fixed event in the past.
Returns
Status, either processing or finished

Implements friz::AnimationType.

◆ isFinished()

template<std::size_t ValueCount>
bool friz::Animation< ValueCount >::isFinished ( )
inlineoverridevirtual
Returns
true if the effect has completed.

Implements friz::AnimationType.

◆ isReady()

template<std::size_t ValueCount>
bool friz::Animation< ValueCount >::isReady ( ) const
inlineoverridevirtual
Returns
true if the animation is ready to be executed (e.g. has all its values set to valid AnimatedValue objects.)

Implements friz::AnimationType.

◆ setValue()

template<std::size_t ValueCount>
bool friz::Animation< ValueCount >::setValue ( size_t  index,
std::unique_ptr< AnimatedValue value 
)
inlineoverridevirtual

Set the AnimatedValue object to use for one of this animation's slots.

Parameters
indexValue index, 0..ValueCount-1
valueAnimatedValue object to generate data.
Returns
true on success.

Reimplemented from friz::AnimationType.


The documentation for this class was generated from the following file: