summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-09-23 13:30:24 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-09-23 13:48:51 (GMT)
commit9d552fbf54a25b4bab7fff8a150ab0d03d524983 (patch)
tree350b11394c542050c2de08e8663d8cf0c19717a7 /src/corelib/animation
parentb9fd3e2836553dbe9c48c5d8784155b02a5699a2 (diff)
downloadQt-9d552fbf54a25b4bab7fff8a150ab0d03d524983.zip
Qt-9d552fbf54a25b4bab7fff8a150ab0d03d524983.tar.gz
Qt-9d552fbf54a25b4bab7fff8a150ab0d03d524983.tar.bz2
Small change in the API of animations
We're not taking a parameter in updateCurrentTime any more because that parameter was the total currenttime. So it was taking into account the currenttime and the currentloop at once. This was inconsistent Reviewed-by: Leo
Diffstat (limited to 'src/corelib/animation')
-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
11 files changed, 24 insertions, 30 deletions
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;