A class that can own Animation
objects and execute them at a regular interval.
More...
#include <animator.h>
|
| Animator (std::unique_ptr< Controller > controller_=nullptr) |
| Construct a new Animator object. If not configured otherwise, will create an animator that is controlled by a timer that updates around 30 Hz.
|
|
void | setController (std::unique_ptr< Controller > controller) |
| Set a new controller object, replacing (and destryoying) the current one.
|
|
Controller * | getController () const |
| return a pointer to the active controller object.
|
|
bool | setFrameRate (int rateInHz) |
| Attempt to set the controller's frame rate.
|
|
float | getFrameRate () const |
| get the (reported) frame rate of the controller. This may be the rate that was requested or a rate that's measured; the actual value returned is dependent on the controller object in use
|
|
void | gotoTime (juce::int64 timeInMs) |
| Update all active animations with a new time.
|
|
bool | addAnimation (std::unique_ptr< AnimationType > animation) |
|
bool | cancelAnimation (int id, bool moveToEndPosition) |
|
bool | cancelAllAnimations (bool moveToEndPosition) |
|
AnimationType * | getAnimation (int id) |
|
int | getAnimations (int id, std::vector< AnimationType * > &animations) |
|
bool | updateTarget (int id, int valIndex, float newTarget) |
| Pass a new ending value to the animation at id , if it is still in progress. Not all animated value classes support this operation, so it may silently fail.
|
|
A class that can own Animation
objects and execute them at a regular interval.
Since the timer that drives the animations only executes if there is currently an animation happening, there's no overhead when the animator is idle.
◆ Animator()
friz::Animator::Animator |
( |
std::unique_ptr< Controller > |
controller_ = nullptr | ) |
|
Construct a new Animator object. If not configured otherwise, will create an animator that is controlled by a timer that updates around 30 Hz.
- Parameters
-
◆ addAnimation()
bool friz::Animator::addAnimation |
( |
std::unique_ptr< AnimationType > |
animation | ) |
|
Add a new animation to our list, which will start it going!
- Parameters
-
animation | The animation sequence to play. |
- Returns
- true if added okay.
◆ cancelAllAnimations()
bool friz::Animator::cancelAllAnimations |
( |
bool |
moveToEndPosition | ) |
|
Cancel all active animations.
- Parameters
-
moveToEndPosition | True to force all values to their end positions first. |
- Returns
- True if we canceled anything.
◆ cancelAnimation()
bool friz::Animator::cancelAnimation |
( |
int |
id, |
|
|
bool |
moveToEndPosition |
|
) |
| |
Cancel any animations with the specified ID, optionally sending one last update call with all values set to their end positions. ID values aren't required to be unique, so this will check all active animations for a matching value.
- Parameters
-
id | ID of the animation(s) to cancel. |
moveToEndPosition | true to force all values to their end position before canceling. |
- Returns
- True if at least one animation was canceled.
◆ cleanup()
void friz::Animator::cleanup |
( |
| ) |
|
|
private |
Remove any animations that are complete or canceled from the list. If we end with the list empty, stop the timer
◆ getAnimation()
Attempt to get a running animation object by passing in its ID value.
- Parameters
-
id | ID of the animation you want. If more than one animation use the same ID, this will only return the first one found. |
- Returns
- non-owning pointer (or nullptr if not present). Don't store this pointer as it may be deleted from beneath you.
- See also
- getAnimations()
◆ getAnimations()
int friz::Animator::getAnimations |
( |
int |
id, |
|
|
std::vector< AnimationType * > & |
animations |
|
) |
| |
Attempt to get all animations that use a specific ID.
- Parameters
-
id | ID to look for. |
animations | Vector to fill with non-owning pointers. |
- Returns
- number of effects found.
◆ getController()
Controller * friz::Animator::getController |
( |
| ) |
const |
return a pointer to the active controller object.
- Returns
- Controller*
◆ getFrameRate()
float friz::Animator::getFrameRate |
( |
| ) |
const |
get the (reported) frame rate of the controller. This may be the rate that was requested or a rate that's measured; the actual value returned is dependent on the controller object in use
- Returns
- float, < 0 on error.
◆ gotoTime()
void friz::Animator::gotoTime |
( |
juce::int64 |
timeInMs | ) |
|
Update all active animations with a new time.
- Parameters
-
◆ setController()
void friz::Animator::setController |
( |
std::unique_ptr< Controller > |
controller | ) |
|
Set a new controller object, replacing (and destryoying) the current one.
- Parameters
-
◆ setFrameRate()
bool friz::Animator::setFrameRate |
( |
int |
rateInHz | ) |
|
Attempt to set the controller's frame rate.
- Parameters
-
- Returns
- true if the controller's framerate can be changed, and the requested rate is valid.
◆ updateTarget()
bool friz::Animator::updateTarget |
( |
int |
id, |
|
|
int |
valIndex, |
|
|
float |
newTarget |
|
) |
| |
Pass a new ending value to the animation at id
, if it is still in progress. Not all animated value classes support this operation, so it may silently fail.
- Parameters
-
id | |
valIndex | index of the value within the animation. |
newTarget | |
- Returns
- true If the animation exists; this doesn't indicate that we actually succeeded.
◆ mutex
juce::CriticalSection friz::Animator::mutex |
|
private |
protect code that might contain data races if updates come from a different thread.
The documentation for this class was generated from the following files:
- Source/friz/control/animator.h
- Source/friz/control/animator.cpp