42 #include "private/qdeclarativesmoothedanimation_p.h" 43 #include "private/qdeclarativesmoothedanimation_p_p.h" 45 #include "private/qdeclarativeanimation_p_p.h" 48 #include "private/qdeclarativeproperty_p.h" 50 #include "private/qdeclarativeglobal_p.h" 52 #include <QtCore/qdebug.h> 54 #include <QtCore/qmath.h> 56 #define DELAY_STOP_TIMER_INTERVAL 32 61 :
QAbstractAnimation(parent), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1),
63 trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0)
132 qreal vp1 = (-c2 +
qSqrt(c2 * c2 - 4 * c1 * c3)) / (
qreal(2.) * c1);
142 qreal c2 =
qreal(0.5) *
vi * tf -
s;
145 qreal a1 = (-c2 +
qSqrt(c2 * c2 - 4 * c1 * c3)) / (
qreal(2.) * c1);
147 qreal tp1 =
qreal(0.5) * tf -
qreal(0.5) * vi / a1;
148 qreal vp1 = a1 * tp1 +
vi;
150 qreal sp1 =
qreal(0.5) * a1 * tp1 * tp1 + vi * tp1;
166 if (time_seconds <
tp) {
168 value =
qreal(0.5) * a * time_seconds * time_seconds +
vi * time_seconds;
169 }
else if (time_seconds <
td) {
172 value =
sp + time_seconds *
vp;
173 }
else if (time_seconds <
tf) {
176 value =
sd -
qreal(0.5) *
d * time_seconds * time_seconds +
vp * time_seconds;
332 return d->wrapperGroup;
346 for (
int i = 0; i <
d->actions->size(); i++) {
349 if (!
d->activeAnimations.contains((*
d->actions)[i].property)) {
351 d->wrapperGroup->addAnimation(ease);
352 d->activeAnimations.insert((*
d->actions)[i].property, ease);
353 needsRestart =
false;
355 ease =
d->activeAnimations.value((*
d->actions)[i].property);
359 ease->
to = (*
d->actions)[i].toValue.toReal();
374 for (
int i =
d->wrapperGroup->animationCount() - 1; i >= 0 ; --i) {
375 if (!anims.
contains(
d->wrapperGroup->animationAt(i))) {
377 d->activeAnimations.remove(ease->
target);
378 d->wrapperGroup->takeAnimation(i);
409 if (
d->anim->reversingMode == m)
412 d->anim->reversingMode = m;
413 emit reversingModeChanged();
414 d->updateRunningAnimations();
433 return d->anim->userDuration;
441 if(duration ==
d->anim->userDuration)
443 d->anim->userDuration = duration;
444 d->updateRunningAnimations();
450 return d->anim->velocity;
471 if (
d->anim->velocity == v)
474 d->anim->velocity = v;
475 emit velocityChanged();
476 d->updateRunningAnimations();
495 return d->anim->maximumEasingTime;
501 if(v ==
d->anim->maximumEasingTime)
503 d->anim->maximumEasingTime = v;
504 emit maximumEasingTimeChanged();
505 d->updateRunningAnimations();
void setSingleShot(bool singleShot)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
QDeclarativeProperty target
virtual void updateCurrentTime(int)
This pure virtual function is called every time the animation's currentTime changes.
QDeclarativeStateActions * actions
QDeclarativeSmoothedAnimation(QObject *parent=0)
#define QT_END_NAMESPACE
This macro expands to.
State
This enum describes the state of the animation.
ReversingMode reversingMode() const
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
QParallelAnimationGroup * wrapperGroup
virtual void setDuration(int)
The QObject class is the base class of all Qt objects.
void stop()
Stops the animation.
QDeclarativeSmoothedAnimationPrivate()
virtual void setDuration(int)
QDeclarativeSmoothedAnimation::ReversingMode reversingMode
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool contains(const T &value) const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QSmoothedAnimation(QObject *parent=0)
const_iterator insert(const T &value)
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
The QAbstractAnimation class is the base of all animations.
void setMaximumEasingTime(int)
void setInterval(int msec)
virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State)
This virtual function is called by QAbstractAnimation when the state of the animation is changed from...
The QParallelAnimationGroup class provides a parallel group of animations.
void updateRunningAnimations()
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
QObject * parent() const
Returns a pointer to the parent object.
int maximumEasingTime() const
QHash< QDeclarativeProperty, QSmoothedAnimation * > activeAnimations
#define DELAY_STOP_TIMER_INTERVAL
QSmoothedAnimation * anim
void setReversingMode(ReversingMode)
void stop()
Stops the timer.
~QDeclarativeSmoothedAnimation()
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
QAbstractAnimation * qtAnimation()
virtual int duration() const
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
QVariant read() const
Returns the property value.
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
Qt::LayoutDirection direction