17#ifndef __SVALUEANIMATOR__H__
18#define __SVALUEANIMATOR__H__
30#include <interface/SValueAnimator-i.h>
32#include <sobject/Sobject.hpp>
170 SArray<IAnimatorListener *> mListeners;
195 STDMETHOD_(
void,
setDuration)(THIS_
long duration) OVERRIDE;
202 long getScaledDuration();
209 STDMETHOD_(
long,
getDuration)(THIS) SCONST OVERRIDE;
236 int getCurrentIteration(
float fraction);
244 float getCurrentIterationFraction(
float fraction,
bool inReverse);
251 float clampFraction(
float fraction);
259 bool shouldPlayBackward(
int iteration,
bool inReverse);
278 STDMETHOD_(
void,
setStartDelay)(THIS_
long startDelay) OVERRIDE;
297 STDMETHOD_(
void,
setRepeatMode)(THIS_ RepeatMode value) OVERRIDE;
309 STDMETHOD_(
void,
addUpdateListener)(THIS_ IAnimatorUpdateListener *listener) OVERRIDE;
326 STDMETHOD_(
void,
setInterpolator)(THIS_ IInterpolator *value) OVERRIDE;
338 STDMETHOD_(
void,
addListener)(THIS_ IAnimatorListener *p) OVERRIDE;
344 STDMETHOD_(
void,
removeListener)(THIS_ IAnimatorListener *p) OVERRIDE;
350 void notifyStartListeners();
356 void start(
bool playBackwards);
363 STDMETHOD_(
void, start)(THIS_ ITimelineHandlersMgr *pContainer) OVERRIDE;
368 STDMETHOD_(
void,
end)(THIS) OVERRIDE;
374 STDMETHOD_(BOOL,
isRunning)(THIS) SCONST OVERRIDE;
380 STDMETHOD_(BOOL,
isStarted)(THIS) SCONST OVERRIDE;
388 STDMETHOD_(
void,
reverse)(THIS) OVERRIDE;
394 STDMETHOD_(IValueAnimator *,
clone)(THIS) SCONST OVERRIDE;
400 STDMETHOD_(
void,
copy)(THIS_
const IValueAnimator *pSrc) OVERRIDE;
419 void startAnimation();
427 bool isPulsingInternal();
442 bool animateBasedOnTime(uint64_t currentTime);
450 void animateBasedOnPlayTime(
long currentPlayTime,
long lastPlayTime,
bool inReverse);
456 void skipToEndValue(
bool inReverse);
462 bool isInitialized();
469 bool doAnimationFrame(uint64_t frameTime);
491 void animateValue(
float fraction);
496 void removeAnimationCallback();
501 void addAnimationCallback();
556 STDMETHOD_(
void,
copy)(THIS_
const IValueAnimator *pSrc) OVERRIDE
581 ATTR_ENUM_BEGIN(L
"repeatMode", RepeatMode, FALSE)
582 ATTR_ENUM_VALUE(L
"reverse", REVERSE)
583 ATTR_ENUM_VALUE(L
"restart", RESTART)
743 HRESULT OnAttrFrom(
const SStringW &strValue, BOOL bLoading);
751 HRESULT OnAttrTo(
const SStringW &strValue, BOOL bLoading);
769 , public IAnimatorListener {
797 STDMETHOD_(BOOL, AddAnimator)(THIS_ IValueAnimator *ani) OVERRIDE;
804 STDMETHOD_(BOOL, RemoveAnimator)(THIS_ IValueAnimator *ani) OVERRIDE;
810 STDMETHOD_(
void, SetListener)(THIS_ IAnimatorGroupListerer *listener) OVERRIDE;
817 STDMETHOD_(
void, onAnimationStart)(THIS_ IValueAnimator *pAnimator);
831 STDMETHOD_(
void, onAnimationEnd)(THIS_ IValueAnimator *pAnimator);
Interface for use with the ValueAnimator::setEvaluator(TypeEvaluator) function.
Manages a group of animations.
AniState
Enumeration of animation states.
AnimatorStateMap m_lstAnimator
Map of animators and their states.
SAnimatorGroup()
Constructor.
SMap< IValueAnimator *, AniState > AnimatorStateMap
Map of animators and their states.
IAnimatorGroupListerer * m_listener
Listener for the animator group.
void onAnimationRepeat(IValueAnimator *pAnimator)
Called when an animation repeats.
Smart pointer class for managing COM-style reference-counted objects.
HRESULT OnAttrTo(const SStringW &strValue, BOOL bLoading)
Handles the "valueTo" attribute.
SColorAnimator()
Constructor.
HRESULT OnAttrFrom(const SStringW &strValue, BOOL bLoading)
Handles the "valueFrom" attribute.
SFloatAnimator()
Constructor.
SIntAnimator()
Constructor.
SPointAnimator()
Constructor.
SRectAnimator()
Constructor.
SSizeAnimator()
Constructor.
A class representing an ASCII string.
int getRepeatCount() SCONST OVERRIDE
Defines how many times the animation should repeat.
SAutoRefPtr< IInterpolator > mInterpolator
The time interpolator to be used.
ITimelineHandlersMgr * mContainer
The container managing the timeline handlers.
void setRepeatCount(int value) OVERRIDE
Sets how many times the animation should be repeated.
void addUpdateListener(IAnimatorUpdateListener *listener) OVERRIDE
Adds a listener to the set of listeners that are sent update events through the life of an animation.
float mCurrentFraction
Tracks current elapsed/eased fraction, for querying in getAnimatedFraction().
void commitAnimationFrame(long frameTime) OVERRIDE
Applies an adjustment to the animation to compensate for jank between when the animation first ran an...
BOOL isStarted() SCONST OVERRIDE
Checks if the animation has been started.
bool mStarted
Additional playing state to indicate whether an animator has been start()'d, whether or not there is ...
void setInterpolator(IInterpolator *value) OVERRIDE
Sets the time interpolator used in calculating the elapsed fraction of this animation.
void setStartDelay(long startDelay) OVERRIDE
Sets the amount of time, in milliseconds, to delay starting the animation after start() is called.
void setRepeatMode(RepeatMode value) OVERRIDE
Defines what this animation should do when it reaches the end.
bool mStartListenersCalled
Tracks whether we've notified listeners of the onAnimationStart() event.
uint64_t mLastFrameTime
Tracks the time (in milliseconds) when the last frame arrived.
long getTotalDuration() SCONST OVERRIDE
Gets the total duration of the animation, including any repetitions.
bool mAnimationEndRequested
Flag that tracks whether animation has been requested to end.
float mSeekFraction
Set when setCurrentPlayTime() is called.
void setDuration(long duration) OVERRIDE
Sets the length of the animation.
void setCurrentPlayTime(long playTime) OVERRIDE
Sets the position of the animation to the specified point in time.
void reverse() OVERRIDE
Plays the SValueAnimator in reverse.
void setCurrentFraction(float fraction) OVERRIDE
Sets the position of the animation to the specified fraction.
bool mReversing
Flag to indicate whether this animator is playing in reverse mode.
IInterpolator * getInterpolator() SCONST OVERRIDE
Returns the timing interpolator that this SValueAnimator uses.
float getAnimatedFraction() SCONST OVERRIDE
Returns the current animation fraction.
uint64_t mStartTime
The first time that the animation's animateFrame() method is called.
void end() OVERRIDE
Ends the animation.
uint64_t mFirstFrameTime
Tracks the time (in milliseconds) when the first frame arrived.
BOOL isRunning() SCONST OVERRIDE
Checks if the animation is running.
bool mRunning
Additional playing state to indicate whether an animator has been start()'d.
long mStartDelay
The amount of time in milliseconds to delay starting the animation after start() is called.
RepeatMode getRepeatMode() SCONST OVERRIDE
Defines what this animation should do when it reaches the end.
SValueAnimator()
Creates a new SValueAnimator object.
IValueAnimator * clone() SCONST OVERRIDE
Creates a clone of the current animation.
void addListener(IAnimatorListener *p) OVERRIDE
Adds an animator listener.
void copy(const IValueAnimator *pSrc) OVERRIDE
Copies the properties of another animation to this animation.
SArray< IAnimatorUpdateListener * > mUpdateListeners
The set of listeners to be sent update events through the life of an animation.
float mOverallFraction
Tracks the overall fraction of the animation, ranging from 0 to mRepeatCount + 1.
void removeListener(IAnimatorListener *p) OVERRIDE
Removes an animator listener.
long getStartDelay() SCONST OVERRIDE
Gets the amount of time, in milliseconds, to delay starting the animation after start() is called.
float sDurationScale
Scaling factor for the duration.
long getCurrentPlayTime() OVERRIDE
Gets the current position of the animation in time.
int mRepeatCount
The number of times the animation will repeat.
RepeatMode mRepeatMode
The type of repetition that will occur when repeatMode is nonzero.
long mDuration
How long the animation should last in milliseconds.
void removeUpdateListener(IAnimatorUpdateListener *listener) OVERRIDE
Removes a listener from the set listening to frame updates for this animation.
void removeAllUpdateListeners() OVERRIDE
Removes all listeners from the set listening to frame updates for this animation.
void OnNextFrame() OVERRIDE
Handles the next frame of the animation.
bool mInitialized
Flag that denotes whether the animation is set up and ready to go.
long getDuration() SCONST OVERRIDE
Gets the length of the animation.
bool mStartTimeCommitted
Flag indicating whether the start time has been firmly committed.
void onEvaluateValue(float fraction) OVERRIDE
Evaluates the animated value based on the given fraction.
void setRange(T from, T to)
Sets the range of the animation.
TypeEvaluator< T > mValueEvaluator
Type evaluator for the animated value.
T getValue() const
Gets the current animated value.
TValueAnimator(T from, T to)
Constructor.
void copy(const IValueAnimator *pSrc) OVERRIDE
Copies the properties of another animation to this animation.
T mValue
Current animated value.
Template class for evaluating interpolated values between a start and end value.