3#include <animation/SAnimation.h>
4#include <helper/STime.h>
13 d.
type = ABSOLUTE_VALUE;
16 else if (
value.EndsWith(L
"%",
true))
18 d.
type = RELATIVE_TO_SELF;
21 else if (
value.EndsWith(L
"%p",
true))
23 d.
type = RELATIVE_TO_PARENT;
28 d.
type = ABSOLUTE_VALUE;
43 if (value.
value.unit == SLayoutSize::px)
44 fValue = value.
value.fSize;
46 fValue = value.
value.fSize * nScale / 100;
50 case RELATIVE_TO_SELF:
51 return (
int)(size * fValue);
52 case RELATIVE_TO_PARENT:
53 return (
int)(parentSize * fValue);
112 float normalizedTime;
115 normalizedTime = ((float)(currentTime - (
mStartTime + startOffset))) / (
float)duration;
120 normalizedTime = currentTime <
mStartTime ? 0.0f : 1.0f;
123 BOOL expired = normalizedTime >= 1.0f ||
isCanceled();
124 BOOL bMore = !expired;
127 normalizedTime = smax(smin(normalizedTime, 1.0f), 0.0f);
138 normalizedTime = smax(smin(normalizedTime, 1.0f), 0.0f);
142 normalizedTime = 1.0f - normalizedTime;
145 float interpolatedTime =
mInterpolator->getInterpolation(normalizedTime);
146 outTransformation->Clear();
263 repeatCount = INFINITE;
436 mListener->OnAnimationPauseChange(
this, TRUE);
451 mListener->OnAnimationPauseChange(
this, FALSE);
An interpolator where the rate of change starts and ends slowly, accelerating in the middle.
BOOL getTransformation(uint64_t currentTime, ITransformation *outTransformation) OVERRIDE
Gets the transformation at a specific time.
int resolveSize(const SValueDescription &value, int size, int parentSize, int nScale)
Converts the information in the description of a size to an actual dimension.
bool mStarted
Set by getTransformation(long, STransformation) when the animation starts.
int64_t getStartTime() SCONST OVERRIDE
Gets the start time of the animation.
BOOL mFillEnabled
Indicates whether fillBefore should be taken into account.
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 pause() OVERRIDE
Pauses the animation.
void scaleCurrentDuration(float scale) OVERRIDE
Scales the current duration of the animation.
void setFillBefore(BOOL bFill) OVERRIDE
Sets whether the animation transformation should be applied before the animation starts.
BOOL getFillAfter() SCONST OVERRIDE
Gets whether the animation transformation should be applied after the animation ends.
void reset() OVERRIDE
Resets the animation to its initial state.
~SAnimation()
Destructor for SAnimation.
void ensureInterpolator()
Ensures that this animation has an interpolator. Will use an AccelerateDecelerateInterpolator if noth...
float mScaleFactor
Scale factor to apply to pivot points, etc. during animation. Subclasses retrieve the value via getSc...
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 copy(const IAnimation *src) OVERRIDE
Copies the properties of another animation to this animation.
BOOL hasStarted() SCONST OVERRIDE
Checks whether the animation has started.
void cancel() OVERRIDE
Cancels the animation.
bool mPaused
Indicates whether the animation is paused.
void setUserData(ULONG_PTR data) OVERRIDE
Sets user data associated with the animation.
uint64_t mPauseTime
The time at which the animation was paused.
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.
IAnimation * clone() SCONST OVERRIDE
Creates a new animation with a duration of 0ms, the default interpolator, with fillBefore set to true...
void applyTransformation(float interpolatedTime, ITransformation *t) OVERRIDE
Applies the transformation at a specific interpolated time.
ULONG_PTR getUserData() SCONST OVERRIDE
Gets user data associated with the animation.
IAnimationListener * mListener
The animation listener to be notified when the animation starts, ends, or repeats.
ZAdjustment mZAdjustment
Desired Z order mode during animation.
BOOL hasAlpha() SCONST OVERRIDE
Checks whether the animation affects the alpha property.
BOOL isFillEnabled() SCONST OVERRIDE
Checks whether fillBefore should be taken into account.
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.
SAnimation()
Default constructor for SAnimation.
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.
BOOL getTransformation2(uint64_t currentTime, ITransformation *outTransformation, float scale) OVERRIDE
Gets the transformation at a specific time.
void setAnimationListener(IAnimationListener *listener) OVERRIDE
Sets the animation listener to be notified when the animation starts, ends, or repeats.
void startNow() OVERRIDE
Starts the animation immediately.
ZAdjustment getZAdjustment() SCONST OVERRIDE
Gets the desired Z order mode during animation.
long mDuration
The duration of one animation cycle in milliseconds.
int getRepeatCount() SCONST OVERRIDE
Gets the number of times the animation must repeat.
BOOL hasEnded() SCONST OVERRIDE
Checks whether the animation has ended.
void setDuration(long durationMillis) OVERRIDE
Sets the duration of one animation cycle in milliseconds.
void setStartTime(int64_t startTimeMillis) OVERRIDE
Sets the start time of the animation.
float getScaleFactor()
Gets the scale factor that should be applied to pre-scaled values in an Animation....
void setInterpolator(IInterpolator *i) OVERRIDE
Sets the interpolator used by the animation to smooth the movement.
void start() OVERRIDE
Starts the animation.
void setFillEnabled(BOOL fillEnabled) OVERRIDE
Sets whether fillBefore should be taken into account.
void setZAdjustment(ZAdjustment zAdjustment) OVERRIDE
Sets the desired Z order mode during 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.
ULONG_PTR mUserData
User data associated with the animation.
bool mCycleFlip
Set by getTransformation(long, STransformation) when the animation repeats in REVERSE mode.
SAutoRefPtr< IInterpolator > mInterpolator
The interpolator used by the animation to smooth the movement.
void resume() OVERRIDE
Resumes the animation.
void setRepeatCount(int repeatCount) OVERRIDE
Sets the number of times the animation must repeat.
void setRepeatMode(RepeatMode repeatMode) OVERRIDE
Sets the repeat mode of the animation.
void fireAnimationRepeat()
Notifies the animation listener that the animation has repeated.
bool mEnded
Set by getTransformation(long, STransformation) when the animation ends.
IInterpolator * getInterpolator() SCONST OVERRIDE
Gets the interpolator used by the animation.
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.
BOOL getFillBefore() SCONST OVERRIDE
Gets whether the animation transformation should be applied before the animation starts.
RepeatMode getRepeatMode() SCONST OVERRIDE
Gets the repeat mode of the animation.
long mStartOffset
The delay in milliseconds after which the animation must start. When the start offset is > 0,...
long getDuration() SCONST OVERRIDE
Gets the duration of one animation cycle.
bool isCanceled()
Checks whether the animation is canceled.
virtual IAnimation * CreateAnimationByName(LPCWSTR pszName) const
Create an animation by name.
void parseString(const SStringW &strSize)
从字符串解析大小
LPCWSTR GetObjectClass() SCONST OVERRIDE
static SApplication * getSingletonPtr(void)
A class representing an ASCII string.
static uint64_t GetCurrentTimeMs()
获取当前时间的毫秒数
Utility class to parse a string description of a size.
static SValueDescription parseValue(const SStringW &value)
Parses a string description of a size. Size descriptions can appear in three forms:
SLayoutSize value
The absolute or relative dimension for this Description.
AniValueType type
One of Animation.ABSOLUTE_VALUE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
SValueDescription(AniValueType _type=ABSOLUTE_VALUE, float _value=0.0f)
Constructor for SValueDescription.