summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/animation/easing/animation.h4
-rw-r--r--src/corelib/animation/qabstractanimation.cpp18
-rw-r--r--src/corelib/animation/qabstractanimation.h2
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp2
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h2
-rw-r--r--src/corelib/animation/qpauseanimation.cpp3
-rw-r--r--src/corelib/animation/qpauseanimation.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp16
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h2
-rw-r--r--src/corelib/animation/qvariantanimation.cpp3
-rw-r--r--src/corelib/animation/qvariantanimation.h2
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp6
-rw-r--r--tests/benchmarks/qanimation/rectanimation.cpp4
-rw-r--r--tests/benchmarks/qanimation/rectanimation.h2
15 files changed, 32 insertions, 38 deletions
diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h
index 45a7b17..78fdc14 100644
--- a/examples/animation/easing/animation.h
+++ b/examples/animation/easing/animation.h
@@ -68,7 +68,7 @@ public:
m_path = QPainterPath();
}
- void updateCurrentTime(int msecs)
+ void updateCurrentTime()
{
if (m_pathType == CirclePath) {
if (m_path.isEmpty()) {
@@ -90,7 +90,7 @@ public:
updateCurrentValue(pt);
emit valueChanged(pt);
} else {
- QPropertyAnimation::updateCurrentTime(msecs);
+ QPropertyAnimation::updateCurrentTime();
}
}
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 6306882..9027be0 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -81,12 +81,12 @@
QAbstractAnimation provides pure virtual functions used by
subclasses to track the progress of the animation: duration() and
updateCurrentTime(). The duration() function lets you report a
- duration for the animation (as discussed above). The current time
- is delivered by the animation framework through calls to
- updateCurrentTime(). By reimplementing this function, you can
- track the animation progress. Note that neither the interval
- between calls nor the number of calls to this function are
- defined; though, it will normally be 60 updates per second.
+ duration for the animation (as discussed above). The animation
+ framework calls updateCurrentTime() when current time has changed.
+ By reimplementing this function, you can track the animation
+ progress. Note that neither the interval between calls nor the
+ number of calls to this function are defined; though, it will
+ normally be 60 updates per second.
By reimplementing updateState(), you can track the animation's
state changes, which is particularly useful for animations that
@@ -604,7 +604,7 @@ void QAbstractAnimation::setCurrentTime(int msecs)
}
}
- updateCurrentTime(msecs);
+ updateCurrentTime();
if (d->currentLoop != oldLoop)
emit currentLoopChanged(d->currentLoop);
@@ -705,10 +705,10 @@ bool QAbstractAnimation::event(QEvent *event)
}
/*!
- \fn virtual void QAbstractAnimation::updateCurrentTime(int msecs) = 0;
+ \fn virtual void QAbstractAnimation::updateCurrentTime() = 0;
This pure virtual function is called every time the animation's current
- time changes. The \a msecs argument is the current time.
+ time changes.
\sa updateState()
*/
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index dc0af19..516f5e9 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(int msecs) = 0;
+ virtual void updateCurrentTime() = 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 349090b..82d5224 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(int)
+void QParallelAnimationGroup::updateCurrentTime()
{
Q_D(QParallelAnimationGroup);
if (d->animations.isEmpty())
diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h
index f013bc7..6afe4a7 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(int msecs);
+ void updateCurrentTime();
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 8bfed08..c382b19 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -141,9 +141,8 @@ bool QPauseAnimation::event(QEvent *e)
/*!
\reimp
*/
-void QPauseAnimation::updateCurrentTime(int msecs)
+void QPauseAnimation::updateCurrentTime()
{
- Q_UNUSED(msecs);
}
diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h
index 05eb3b3..caac9e9 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(int msecs);
+ void updateCurrentTime();
private:
Q_DISABLE_COPY(QPauseAnimation)
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 53fc4f3..9ad433f 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -112,17 +112,13 @@ int QSequentialAnimationGroupPrivate::animationActualTotalDuration(int index) co
return ret;
}
-QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivate::indexForTime(int msecs) const
+QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivate::indexForCurrentTime() const
{
- Q_Q(const QSequentialAnimationGroup);
Q_ASSERT(!animations.isEmpty());
AnimationIndex ret;
int duration = 0;
- // in case duration is -1, currentLoop will always be 0
- ret.timeOffset = currentLoop * q->duration();
-
for (int i = 0; i < animations.size(); ++i) {
duration = animationActualTotalDuration(i);
@@ -131,8 +127,8 @@ QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivat
// 2. it ends after msecs
// 3. it is the last animation (this can happen in case there is at least 1 uncontrolled animation)
// 4. it ends exactly in msecs and the direction is backwards
- if (duration == -1 || msecs < (ret.timeOffset + duration)
- || (msecs == (ret.timeOffset + duration) && direction == QAbstractAnimation::Backward)) {
+ if (duration == -1 || currentTime < (ret.timeOffset + duration)
+ || (currentTime == (ret.timeOffset + duration) && direction == QAbstractAnimation::Backward)) {
ret.index = i;
return ret;
}
@@ -338,13 +334,13 @@ int QSequentialAnimationGroup::duration() const
/*!
\reimp
*/
-void QSequentialAnimationGroup::updateCurrentTime(int msecs)
+void QSequentialAnimationGroup::updateCurrentTime()
{
Q_D(QSequentialAnimationGroup);
if (!d->currentAnimation)
return;
- const QSequentialAnimationGroupPrivate::AnimationIndex newAnimationIndex = d->indexForTime(msecs);
+ const QSequentialAnimationGroupPrivate::AnimationIndex newAnimationIndex = d->indexForCurrentTime();
// remove unneeded animations from actualDuration list
while (newAnimationIndex.index < d->actualDuration.size())
@@ -363,7 +359,7 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs)
d->setCurrentAnimation(newAnimationIndex.index);
- const int newCurrentTime = msecs - newAnimationIndex.timeOffset;
+ const int newCurrentTime = d->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 e17e103..1c9e4cc 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(int msecs);
+ void updateCurrentTime();
void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
void updateDirection(QAbstractAnimation::Direction direction);
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index 2e65cc0..ab41d35 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -79,7 +79,7 @@ public:
};
int animationActualTotalDuration(int index) const;
- AnimationIndex indexForTime(int msecs) const;
+ AnimationIndex indexForCurrentTime() const;
void setCurrentAnimation(int index, bool intermediate = false);
void activateCurrentAnimation(bool intermediate = false);
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index c831a34..ae8bf2f 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -656,9 +656,8 @@ QVariant QVariantAnimation::interpolated(const QVariant &from, const QVariant &t
/*!
\reimp
*/
-void QVariantAnimation::updateCurrentTime(int msecs)
+void QVariantAnimation::updateCurrentTime()
{
- Q_UNUSED(msecs);
d_func()->recalculateCurrentInterval();
}
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index c803150..98c1aec 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(int msecs);
+ void updateCurrentTime();
void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
virtual void updateCurrentValue(const QVariant &value) = 0;
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 209e68b..b14d6f8 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(int msecs)
+ void updateCurrentTime()
{
- QPropertyAnimation::updateCurrentTime(msecs);
- if (msecs >= QPropertyAnimation::duration())
+ QPropertyAnimation::updateCurrentTime();
+ if (currentTime() >= QPropertyAnimation::duration())
stop();
}
};
diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp
index e5f2f57..5522847 100644
--- a/tests/benchmarks/qanimation/rectanimation.cpp
+++ b/tests/benchmarks/qanimation/rectanimation.cpp
@@ -73,9 +73,9 @@ int RectAnimation::duration() const
}
-void RectAnimation::updateCurrentTime(int msecs)
+void RectAnimation::updateCurrentTime()
{
- qreal progress = m_easing.valueForProgress( qreal(msecs) / 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 84ec97d..995becb 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(int msecs);
+ virtual void updateCurrentTime();
virtual void updateState(QAbstractAnimation::State state);
private: