From 7626109da40a91cb38fbe3f23e08b50a04d2194a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 28 Sep 2009 15:52:32 +0200 Subject: Animations: updateCurrentTime now receives the currentTime as paramater Reviewed-by: Leo --- examples/animation/easing/animation.h | 6 +++--- src/corelib/animation/qabstractanimation.cpp | 4 ++-- src/corelib/animation/qabstractanimation.h | 2 +- src/corelib/animation/qparallelanimationgroup.cpp | 14 +++++++------- src/corelib/animation/qparallelanimationgroup.h | 2 +- src/corelib/animation/qpauseanimation.cpp | 2 +- src/corelib/animation/qpauseanimation.h | 2 +- src/corelib/animation/qsequentialanimationgroup.cpp | 4 ++-- src/corelib/animation/qsequentialanimationgroup.h | 2 +- src/corelib/animation/qvariantanimation.cpp | 2 +- src/corelib/animation/qvariantanimation.h | 2 +- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 6 +++--- .../tst_qsequentialanimationgroup.cpp | 6 +++--- tests/benchmarks/qanimation/rectanimation.cpp | 4 ++-- tests/benchmarks/qanimation/rectanimation.h | 2 +- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h index 78fdc14..bd58be0 100644 --- a/examples/animation/easing/animation.h +++ b/examples/animation/easing/animation.h @@ -68,7 +68,7 @@ public: m_path = QPainterPath(); } - void updateCurrentTime() + void updateCurrentTime(int currentTime) { if (m_pathType == CirclePath) { if (m_path.isEmpty()) { @@ -78,7 +78,7 @@ public: m_path.addEllipse(QRectF(from, to)); } int dura = duration(); - const qreal progress = ((dura == 0) ? 1 : ((((currentTime() - 1) % dura) + 1) / qreal(dura))); + const qreal progress = ((dura == 0) ? 1 : ((((currentTime - 1) % dura) + 1) / qreal(dura))); qreal easedProgress = easingCurve().valueForProgress(progress); if (easedProgress > 1.0) { @@ -90,7 +90,7 @@ public: updateCurrentValue(pt); emit valueChanged(pt); } else { - QPropertyAnimation::updateCurrentTime(); + QPropertyAnimation::updateCurrentTime(currentTime); } } diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 9027be0..6489cdc 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -604,7 +604,7 @@ void QAbstractAnimation::setCurrentTime(int msecs) } } - updateCurrentTime(); + updateCurrentTime(d->currentTime); if (d->currentLoop != oldLoop) emit currentLoopChanged(d->currentLoop); @@ -705,7 +705,7 @@ bool QAbstractAnimation::event(QEvent *event) } /*! - \fn virtual void QAbstractAnimation::updateCurrentTime() = 0; + \fn virtual void QAbstractAnimation::updateCurrentTime(int currentTime) = 0; This pure virtual function is called every time the animation's current time changes. diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index 516f5e9..50b07d7 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -119,7 +119,7 @@ protected: QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = 0); bool event(QEvent *event); - virtual void updateCurrentTime() = 0; + virtual void updateCurrentTime(int currentTime) = 0; virtual void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); virtual void updateDirection(QAbstractAnimation::Direction direction); diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index 82d5224..5b7fd22 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -125,7 +125,7 @@ int QParallelAnimationGroup::duration() const /*! \reimp */ -void QParallelAnimationGroup::updateCurrentTime() +void QParallelAnimationGroup::updateCurrentTime(int currentTime) { Q_D(QParallelAnimationGroup); if (d->animations.isEmpty()) @@ -148,7 +148,7 @@ void QParallelAnimationGroup::updateCurrentTime() } } - bool timeFwd = ((d->currentLoop == d->lastLoop && d->currentTime >= d->lastCurrentTime) + bool timeFwd = ((d->currentLoop == d->lastLoop && currentTime >= d->lastCurrentTime) || d->currentLoop > d->lastLoop); #ifdef QANIMATION_DEBUG qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d", @@ -160,7 +160,7 @@ void QParallelAnimationGroup::updateCurrentTime() const int dura = animation->totalDuration(); if (dura == -1 && d->isUncontrolledAnimationFinished(animation)) continue; - if (dura == -1 || (d->currentTime <= dura && dura != 0) + if (dura == -1 || (currentTime <= dura && dura != 0) || (dura == 0 && d->currentLoop != d->lastLoop)) { switch (state()) { case Running: @@ -177,18 +177,18 @@ void QParallelAnimationGroup::updateCurrentTime() if (dura <= 0) { if (dura == -1) - animation->setCurrentTime(d->currentTime); + animation->setCurrentTime(currentTime); continue; } if ((timeFwd && d->lastCurrentTime <= dura) || (!timeFwd && d->currentTime <= dura)) - animation->setCurrentTime(d->currentTime); - if (d->currentTime > dura) + animation->setCurrentTime(currentTime); + if (currentTime > dura) animation->stop(); } d->lastLoop = d->currentLoop; - d->lastCurrentTime = d->currentTime; + d->lastCurrentTime = currentTime; } /*! diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h index 6afe4a7..1cab91e 100644 --- a/src/corelib/animation/qparallelanimationgroup.h +++ b/src/corelib/animation/qparallelanimationgroup.h @@ -67,7 +67,7 @@ protected: QParallelAnimationGroup(QParallelAnimationGroupPrivate &dd, QObject *parent); bool event(QEvent *event); - void updateCurrentTime(); + void updateCurrentTime(int currentTime); void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); void updateDirection(QAbstractAnimation::Direction direction); diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp index c382b19..2fd12aa 100644 --- a/src/corelib/animation/qpauseanimation.cpp +++ b/src/corelib/animation/qpauseanimation.cpp @@ -141,7 +141,7 @@ bool QPauseAnimation::event(QEvent *e) /*! \reimp */ -void QPauseAnimation::updateCurrentTime() +void QPauseAnimation::updateCurrentTime(int) { } diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h index caac9e9..1b81472 100644 --- a/src/corelib/animation/qpauseanimation.h +++ b/src/corelib/animation/qpauseanimation.h @@ -68,7 +68,7 @@ public: protected: bool event(QEvent *e); - void updateCurrentTime(); + void updateCurrentTime(int); private: Q_DISABLE_COPY(QPauseAnimation) diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 9ad433f..5ca560a 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -334,7 +334,7 @@ int QSequentialAnimationGroup::duration() const /*! \reimp */ -void QSequentialAnimationGroup::updateCurrentTime() +void QSequentialAnimationGroup::updateCurrentTime(int currentTime) { Q_D(QSequentialAnimationGroup); if (!d->currentAnimation) @@ -359,7 +359,7 @@ void QSequentialAnimationGroup::updateCurrentTime() d->setCurrentAnimation(newAnimationIndex.index); - const int newCurrentTime = d->currentTime - newAnimationIndex.timeOffset; + const int newCurrentTime = currentTime - newAnimationIndex.timeOffset; if (d->currentAnimation) { d->currentAnimation->setCurrentTime(newCurrentTime); diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h index 1c9e4cc..f30f851 100644 --- a/src/corelib/animation/qsequentialanimationgroup.h +++ b/src/corelib/animation/qsequentialanimationgroup.h @@ -77,7 +77,7 @@ protected: QSequentialAnimationGroup(QSequentialAnimationGroupPrivate &dd, QObject *parent); bool event(QEvent *event); - void updateCurrentTime(); + void updateCurrentTime(int); void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); void updateDirection(QAbstractAnimation::Direction direction); diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index ae8bf2f..de8185b 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -656,7 +656,7 @@ QVariant QVariantAnimation::interpolated(const QVariant &from, const QVariant &t /*! \reimp */ -void QVariantAnimation::updateCurrentTime() +void QVariantAnimation::updateCurrentTime(int) { d_func()->recalculateCurrentInterval(); } diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h index 98c1aec..bc57b1c 100644 --- a/src/corelib/animation/qvariantanimation.h +++ b/src/corelib/animation/qvariantanimation.h @@ -102,7 +102,7 @@ protected: QVariantAnimation(QVariantAnimationPrivate &dd, QObject *parent = 0); bool event(QEvent *event); - void updateCurrentTime(); + void updateCurrentTime(int); void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); virtual void updateCurrentValue(const QVariant &value) = 0; diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index f86e81d..51ef2da 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -55,10 +55,10 @@ public: int duration() const { return -1; /* not time driven */ } protected: - void updateCurrentTime() + void updateCurrentTime(int currentTime) { - QPropertyAnimation::updateCurrentTime(); - if (currentTime() >= QPropertyAnimation::duration() || currentLoop() >= 1) + QPropertyAnimation::updateCurrentTime(currentTime); + if (currentTime >= QPropertyAnimation::duration() || currentLoop() >= 1) stop(); } }; diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index b14d6f8..aa6801a 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -169,10 +169,10 @@ public: int duration() const { return -1; /* not time driven */ } protected: - void updateCurrentTime() + void updateCurrentTime(int currentTime) { - QPropertyAnimation::updateCurrentTime(); - if (currentTime() >= QPropertyAnimation::duration()) + QPropertyAnimation::updateCurrentTime(currentTime); + if (currentTime >= QPropertyAnimation::duration()) stop(); } }; diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp index 5522847..ab381f4 100644 --- a/tests/benchmarks/qanimation/rectanimation.cpp +++ b/tests/benchmarks/qanimation/rectanimation.cpp @@ -73,9 +73,9 @@ int RectAnimation::duration() const } -void RectAnimation::updateCurrentTime() +void RectAnimation::updateCurrentTime(int currentTime) { - qreal progress = m_easing.valueForProgress( currentTime() / qreal(m_dura) ); + qreal progress = m_easing.valueForProgress( currentTime / qreal(m_dura) ); QRect now; now.setCoords(interpolateInteger(m_start.left(), m_end.left(), progress), interpolateInteger(m_start.top(), m_end.top(), progress), diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h index 995becb..ea1f804 100644 --- a/tests/benchmarks/qanimation/rectanimation.h +++ b/tests/benchmarks/qanimation/rectanimation.h @@ -58,7 +58,7 @@ public: void setDuration(int d); int duration() const; - virtual void updateCurrentTime(); + virtual void updateCurrentTime(int currentTime); virtual void updateState(QAbstractAnimation::State state); private: -- cgit v0.12