3#include <animation/SAnimationSet.h>
5#include <helper/STime.h>
11 SAnimation::InitFromXml(pNode);
19 ani->InitFromXml(&xmlChild);
30 long iValue = _wtoi(value);
37 bool bValue = STRINGASBOOL(value);
44 bool bValue = STRINGASBOOL(value);
51 long iValue = _wtoi(value);
58 bool durationSet = (mFlags & PROPERTY_DURATION_MASK) == PROPERTY_DURATION_MASK;
59 bool fillAfterSet = (mFlags & PROPERTY_FILL_AFTER_MASK) == PROPERTY_FILL_AFTER_MASK;
60 bool fillBeforeSet = (mFlags & PROPERTY_FILL_BEFORE_MASK) == PROPERTY_FILL_BEFORE_MASK;
61 bool shareInterpolator = (mFlags & PROPERTY_SHARE_INTERPOLATOR_MASK) == PROPERTY_SHARE_INTERPOLATOR_MASK;
63 if (shareInterpolator)
75 for (UINT i = 0; i < mAnimations.GetCount(); i++)
77 IAnimation *a = mAnimations[i];
80 a->setDuration(duration);
84 a->setFillAfter(fillAfter);
88 a->setFillBefore(fillBefore);
90 if (shareInterpolator)
92 a->setInterpolator(interpolator);
94 a->initialize(width, height, parentWidth, parentHeight, nScale);
100 const SAnimationSet *src2 = sobj_cast<const SAnimationSet>(src);
105 mFlags = src2->mFlags;
106 mHasAlpha = src2->mHasAlpha;
107 mLastEnd = src2->mLastEnd;
108 for (UINT i = 0; i < src2->mAnimations.GetCount(); i++)
111 ani.
Attach(src2->mAnimations[i]->clone());
112 mAnimations.Add(ani);
118 int count = (int)mAnimations.GetCount();
119 for (
int i = 0; i < count; i++)
121 mAnimations[i]->scaleCurrentDuration(scale);
144 int count = (int)mAnimations.GetCount();
147 mChildStarted = TRUE;
148 for (
int i = count - 1; i >= 0; --i)
150 IAnimation *a = mAnimations[i];
158 for (
int i = count - 1; i >= 0; --i)
160 IAnimation *a = mAnimations[i];
163 more = a->getTransformation2(currentTime, &temp,
getScaleFactor()) || more;
166 ended = a->hasEnded() && ended;
169 if (ended || (currentTime - startOffset -
mStartTime) >= mLastEnd)
174 mChildStarted = FALSE;
188 mChildStarted = FALSE;
200 int count = (int)mAnimations.GetCount();
203 bool durationSet = (mFlags & PROPERTY_DURATION_MASK) == PROPERTY_DURATION_MASK;
210 for (
int i = 0; i < count; i++)
223 if ((mFlags & PROPERTY_DURATION_MASK) == PROPERTY_DURATION_MASK)
229 long duration = a->computeDurationHint();
230 if (mAnimations.GetCount() == 1)
246 mFlags |= PROPERTY_DURATION_MASK;
255 mDirty = mHasAlpha =
false;
257 int count = (int)mAnimations.GetCount();
258 for (
int i = 0; i < count; i++)
260 if (mAnimations.GetAt(i)->hasAlpha())
273 mFlags |= PROPERTY_FILL_BEFORE_MASK;
279 mFlags |= PROPERTY_FILL_AFTER_MASK;
283void SAnimationSet::init()
288 mChildStarted =
false;
291void SAnimationSet::setFlag(
int mask,
bool value)
305 setFlag(PROPERTY_SHARE_INTERPOLATOR_MASK, shareInterpolator);
312 for (UINT i = 0; i < mAnimations.GetCount(); i++)
314 mAnimations[i]->pause();
320 for (UINT i = 0; i < mAnimations.GetCount(); i++)
322 mAnimations[i]->resume();
bool mStarted
Set by getTransformation(long, STransformation) when the animation starts.
int mRepeated
Indicates how many times the animation was repeated.
BOOL mFillAfter
Indicates whether the animation transformation should be applied after the animation ends.
void setFillBefore(BOOL bFill) OVERRIDE
Sets whether the animation transformation should be applied before the animation starts.
void ensureInterpolator()
Ensures that this animation has an interpolator. Will use an AccelerateDecelerateInterpolator if noth...
void copy(const IAnimation *src) OVERRIDE
Copies the properties of another animation to this animation.
void fireAnimationStart()
Notifies the animation listener that the animation has started.
void setFillAfter(BOOL bFill) OVERRIDE
Sets whether the animation transformation should be applied after the animation ends.
BOOL mFillBefore
Indicates whether the animation transformation should be applied before the animation starts....
long getStartOffset() SCONST OVERRIDE
Gets the delay in milliseconds after which the animation must start.
long computeDurationHint() SCONST OVERRIDE
Computes the duration hint for the animation.
void setStartOffset(long offset) OVERRIDE
Sets the delay in milliseconds after which the animation must start.
long mDuration
The duration of one animation cycle in milliseconds.
void setDuration(long durationMillis) OVERRIDE
Sets the duration of one animation cycle in milliseconds.
float getScaleFactor()
Gets the scale factor that should be applied to pre-scaled values in an Animation....
void fireAnimationEnd()
Notifies the animation listener that the animation has ended.
int mRepeatCount
The number of times the animation must repeat. By default, an animation repeats indefinitely.
SAutoRefPtr< IInterpolator > mInterpolator
The interpolator used by the animation to smooth the movement.
void fireAnimationRepeat()
Notifies the animation listener that the animation has repeated.
bool mEnded
Set by getTransformation(long, STransformation) when the animation ends.
uint64_t mStartTime
The time in milliseconds at which the animation must start.
RepeatMode mRepeatMode
The behavior of the animation when it repeats. The repeat mode is either RESTART or REVERSE.
long mStartOffset
The delay in milliseconds after which the animation must start. When the start offset is > 0,...
bool isCanceled()
Checks whether the animation is canceled.
void setFillBefore(BOOL bFill) OVERRIDE
Sets whether the animation transformation should be applied before the animation starts.
long getDuration() SCONST OVERRIDE
Gets the duration of the AnimationSet. The duration of an AnimationSet is defined to be the duration ...
void setFillAfter(BOOL bFill) OVERRIDE
Sets whether the animation transformation should be applied after the animation ends.
void pause() OVERRIDE
Pauses the animation.
HRESULT OnAttrDuration(const SStringW &value, BOOL bLoading)
Custom attribute handler for duration.
void addAnimation(IAnimation *a)
Add a child animation to this animation set. The transforms of the child animations are applied in th...
void initialize(int width, int height, int parentWidth, int parentHeight, int nScale) OVERRIDE
Initializes the animation with the dimensions of the object and its parent.
void resume() OVERRIDE
Resumes the animation.
SAnimationSet(bool shareInterpolator=true)
Constructor to use when building an AnimationSet from code.
HRESULT OnAttrFillBefore(const SStringW &value, BOOL bLoading)
Custom attribute handler for fillBefore.
void setDuration(long durationMillis) OVERRIDE
Sets the duration of every child animation.
void scaleCurrentDuration(float scale) OVERRIDE
Scales the current duration of the animation.
BOOL getTransformation(uint64_t currentTime, ITransformation *outTransformation) OVERRIDE
Gets the transformation at a specific time. The transformation of an animation set is the concatenati...
bool hasAlpha()
Checks if any child animation affects the alpha property.
HRESULT OnAttrFillAfter(const SStringW &value, BOOL bLoading)
Custom attribute handler for fillAfter.
HRESULT OnAttrStartOffset(const SStringW &value, BOOL bLoading)
Custom attribute handler for startOffset.
void copy(const IAnimation *src) OVERRIDE
Copies the properties of another animation to this animation.
BOOL InitFromXml(IXmlNode *pNode) OVERRIDE
Initializes the animation set from an XML node.
virtual IAnimation * CreateAnimationByName(LPCWSTR pszName) const
Create an animation by name.
Smart pointer class for managing COM-style reference-counted objects.
void Attach(T *p2)
Attaches to an existing object without adding a reference.
static SApplication * getSingletonPtr(void)
A class representing an ASCII string.
Class representing an XML node.
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
SXmlNode first_child() const
Gets the first child node of the node.
const wchar_t * name() const
Gets the name of the node.