diff options
Diffstat (limited to 'src/corelib/animation')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 94 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation.h | 12 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 8 | ||||
-rw-r--r-- | src/corelib/animation/qparallelanimationgroup.cpp | 24 | ||||
-rw-r--r-- | src/corelib/animation/qparallelanimationgroup_p.h | 4 | ||||
-rw-r--r-- | src/corelib/animation/qsequentialanimationgroup.cpp | 28 | ||||
-rw-r--r-- | src/corelib/animation/qsequentialanimationgroup_p.h | 4 | ||||
-rw-r--r-- | src/corelib/animation/qvariantanimation.cpp | 2 | ||||
-rw-r--r-- | src/corelib/animation/qvariantanimation_p.h | 2 |
9 files changed, 89 insertions, 89 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 2b9e77d..71ef45c 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -55,15 +55,15 @@ QVariantAnimation and QAnimationGroup, instead. QAbstractAnimation provides an interface for the current time and - duration, the iteration count, and the state of an animation. These properties + duration, the loop count, and the state of an animation. These properties define the base functionality common to all animations in Qt. The virtual duration() function returns the local duration of the animation; i.e., for how long the animation should update the current time before looping. Subclasses can implement this function differently; for example, QVariantAnimation returns the duration of a simple animated property, whereas QAnimationGroup returns the duration of a set or sequence of - animations. You can also set a loop count by calling setIterationCount(); a - iteration count of 2 will let the animation run twice (the default value is + animations. You can also set a loop count by calling setLoopCount(); a + loop count of 2 will let the animation run twice (the default value is 1). Like QTimeLine, QAbstractAnimation also provides an interface for starting @@ -119,12 +119,12 @@ */ /*! - \fn QAbstractAnimation::currentIterationChanged(int currentIteration) + \fn QAbstractAnimation::currentLoopChanged(int currentLoop) - QAbstractAnimation emits this signal whenever the current iteration - changes. \a currentIteration is the current iteration. + QAbstractAnimation emits this signal whenever the current loop + changes. \a currentLoop is the current loop. - \sa currentIteration(), iterationCount() + \sa currentLoop(), loopCount() */ /*! @@ -245,7 +245,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) QAbstractAnimation::State oldState = state; int oldCurrentTime = currentTime; - int oldCurrentIteration = currentIteration; + int oldCurrentLoop = currentLoop; QAbstractAnimation::Direction oldDirection = direction; state = newState; @@ -274,7 +274,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) if (direction == QAbstractAnimation::Forward) q->setCurrentTime(0); else - q->setCurrentTime(iterationCount == -1 ? q->duration() : q->totalDuration()); + q->setCurrentTime(loopCount == -1 ? q->duration() : q->totalDuration()); } // Check if the setCurrentTime() function called stop(). @@ -302,8 +302,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) QUnifiedTimer::instance()->unregisterAnimation(q); - if (dura == -1 || iterationCount < 0 - || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentIteration + 1)) == (dura * iterationCount)) + if (dura == -1 || loopCount < 0 + || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)) || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) { if (guard) emit q->finished(); @@ -459,10 +459,10 @@ void QAbstractAnimation::setDirection(Direction direction) if (state() == Stopped) { if (direction == Backward) { d->currentTime = duration(); - d->currentIteration = d->iterationCount - 1; + d->currentLoop = d->loopCount - 1; } else { d->currentTime = 0; - d->currentIteration = 0; + d->currentLoop = 0; } } updateDirection(direction); @@ -474,14 +474,14 @@ void QAbstractAnimation::setDirection(Direction direction) \brief the duration of the animation. If the duration is -1, it means that the duration is undefined. - In this case, iterationCount is ignored. + In this case, loopCount is ignored. */ /*! - \property QAbstractAnimation::iterationCount - \brief the iteration count of the animation + \property QAbstractAnimation::loopCount + \brief the loop count of the animation - This property describes the iteration count of the animation as an integer. + This property describes the loop count of the animation as an integer. By default this value is 1, indicating that the animation should run once only, and then stop. By changing it you can let the animation loop several times. With a value of 0, the animation will not @@ -490,34 +490,34 @@ void QAbstractAnimation::setDirection(Direction direction) It is not supported to have loop on an animation that has an undefined duration. It will only run once. */ -int QAbstractAnimation::iterationCount() const +int QAbstractAnimation::loopCount() const { Q_D(const QAbstractAnimation); - return d->iterationCount; + return d->loopCount; } -void QAbstractAnimation::setIterationCount(int iterationCount) +void QAbstractAnimation::setLoopCount(int loopCount) { Q_D(QAbstractAnimation); - d->iterationCount = iterationCount; + d->loopCount = loopCount; } /*! - \property QAbstractAnimation::currentIteration - \brief the current iteration of the animation + \property QAbstractAnimation::currentLoop + \brief the current loop of the animation - This property describes the current iteration of the animation. By default, - the animation's iteration count is 1, and so the current iteration will - always be 0. If the iteration count is 2 and the animation runs past its + This property describes the current loop of the animation. By default, + the animation's loop count is 1, and so the current loop will + always be 0. If the loop count is 2 and the animation runs past its duration, it will automatically rewind and restart at current time 0, and - current iteration 1, and so on. + current loop 1, and so on. - When the current iteration changes, QAbstractAnimation emits the - currentIterationChanged() signal. + When the current loop changes, QAbstractAnimation emits the + currentLoopChanged() signal. */ -int QAbstractAnimation::currentIteration() const +int QAbstractAnimation::currentLoop() const { Q_D(const QAbstractAnimation); - return d->currentIteration; + return d->currentLoop; } /*! @@ -525,7 +525,7 @@ int QAbstractAnimation::currentIteration() const This pure virtual function returns the duration of the animation, and defines for how long QAbstractAnimation should update the current - time. This duration is local, and does not include the iteration count. + time. This duration is local, and does not include the loop count. A return value of -1 indicates that the animation has no defined duration; the animation should run forever until stopped. This is useful for @@ -535,24 +535,24 @@ int QAbstractAnimation::currentIteration() const If the animation is a parallel QAnimationGroup, the duration will be the longest duration of all its animations. If the animation is a sequential QAnimationGroup, the duration will be the sum of the duration of all its animations. - \sa iterationCount + \sa loopCount */ /*! Returns the total and effective duration of the animation, including the - iteration count. + loop count. \sa duration(), currentTime */ int QAbstractAnimation::totalDuration() const { Q_D(const QAbstractAnimation); - if (d->iterationCount < 0) + if (d->loopCount < 0) return -1; int dura = duration(); if (dura == -1) return -1; - return dura * d->iterationCount; + return dura * d->loopCount; } /*! @@ -565,11 +565,11 @@ int QAbstractAnimation::totalDuration() const progresses. The animation's current time starts at 0, and ends at duration(). If the - animation's iterationCount is larger than 1, the current time will rewind and + animation's loopCount is larger than 1, the current time will rewind and start at 0 again for the consecutive loops. If the animation has a pause. currentTime will also include the duration of the pause. - \sa iterationCount + \sa loopCount */ int QAbstractAnimation::currentTime() const { @@ -583,31 +583,31 @@ void QAbstractAnimation::setCurrentTime(int msecs) // Calculate new time and loop. int dura = duration(); - int totalDura = (d->iterationCount < 0 || dura == -1) ? -1 : dura * d->iterationCount; + int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount; if (totalDura != -1) msecs = qMin(totalDura, msecs); d->totalCurrentTime = msecs; // Update new values. - int oldLoop = d->currentIteration; - d->currentIteration = ((dura <= 0) ? 0 : (msecs / dura)); - if (d->currentIteration == d->iterationCount) { + int oldLoop = d->currentLoop; + d->currentLoop = ((dura <= 0) ? 0 : (msecs / dura)); + if (d->currentLoop == d->loopCount) { //we're at the end d->currentTime = qMax(0, dura); - d->currentIteration = qMax(0, d->iterationCount - 1); + d->currentLoop = qMax(0, d->loopCount - 1); } else { if (d->direction == Forward) { d->currentTime = (dura <= 0) ? msecs : (msecs % dura); } else { d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1; if (d->currentTime == dura) - --d->currentIteration; + --d->currentLoop; } } updateCurrentTime(msecs); - if (d->currentIteration != oldLoop) - emit currentIterationChanged(d->currentIteration); + if (d->currentLoop != oldLoop) + emit currentLoopChanged(d->currentLoop); // All animations are responsible for stopping the animation when their // own end state is reached; in this case the animation is time driven, @@ -648,7 +648,7 @@ void QAbstractAnimation::start(DeletionPolicy policy) signal, and state() returns Stopped. The current time is not changed. If the animation stops by itself after reaching the end (i.e., - currentTime() == duration() and currentIteration() > iterationCount() - 1), the + currentTime() == duration() and currentLoop() > loopCount() - 1), the finished() signal is emitted. \sa start(), state() diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index d6260cd..a7f0082 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -60,9 +60,9 @@ class Q_CORE_EXPORT QAbstractAnimation : public QObject { Q_OBJECT Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(int iterationCount READ iterationCount WRITE setIterationCount) + Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount) Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime) - Q_PROPERTY(int currentIteration READ currentIteration NOTIFY currentIterationChanged) + Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged) Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged) Q_PROPERTY(int duration READ duration) @@ -93,9 +93,9 @@ public: Direction direction() const; void setDirection(Direction direction); - int iterationCount() const; - void setIterationCount(int iterationCount); - int currentIteration() const; + int loopCount() const; + void setLoopCount(int loopCount); + int currentLoop() const; virtual int duration() const = 0; int totalDuration() const; @@ -105,7 +105,7 @@ public: Q_SIGNALS: void finished(); void stateChanged(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); - void currentIterationChanged(int currentIteration); + void currentLoopChanged(int currentLoop); void directionChanged(QAbstractAnimation::Direction); public Q_SLOTS: diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 28d7d71..666e6a7 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -77,8 +77,8 @@ public: deleteWhenStopped(false), totalCurrentTime(0), currentTime(0), - iterationCount(1), - currentIteration(0), + loopCount(1), + currentLoop(0), group(0) { } @@ -97,8 +97,8 @@ public: int totalCurrentTime; int currentTime; - int iterationCount; - int currentIteration; + int loopCount; + int currentLoop; QAnimationGroup *group; #ifdef QT_EXPERIMENTAL_SOLUTION diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index 993c577..407ffde 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -111,7 +111,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (d->animations.isEmpty()) return; - if (d->currentIteration > d->lastIteration) { + if (d->currentLoop > d->lastLoop) { // simulate completion of the loop int dura = duration(); if (dura > 0) { @@ -119,7 +119,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) animation->setCurrentTime(dura); // will stop } } - } else if (d->currentIteration < d->lastIteration) { + } else if (d->currentLoop < d->lastLoop) { // simulate completion of the loop seeking backwards foreach (QAbstractAnimation *animation, d->animations) { animation->setCurrentTime(0); @@ -127,11 +127,11 @@ void QParallelAnimationGroup::updateCurrentTime(int) } } - bool timeFwd = ((d->currentIteration == d->lastIteration && d->currentTime >= d->lastCurrentTime) - || d->currentIteration > d->lastIteration); + bool timeFwd = ((d->currentLoop == d->lastLoop && d->currentTime >= d->lastCurrentTime) + || d->currentLoop > d->lastLoop); #ifdef QANIMATION_DEBUG qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d", - __LINE__, d->currentTime, d->currentIteration, d->lastIteration, timeFwd, d->lastCurrentTime, state()); + __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state()); #endif // finally move into the actual time of the current loop foreach (QAbstractAnimation *animation, d->animations) { @@ -139,7 +139,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (dura == -1 && d->isUncontrolledAnimationFinished(animation)) continue; if (dura == -1 || (d->currentTime <= dura && dura != 0) - || (dura == 0 && d->currentIteration != d->lastIteration)) { + || (dura == 0 && d->currentLoop != d->lastLoop)) { switch (state()) { case Running: animation->start(); @@ -165,7 +165,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (d->currentTime > dura) animation->stop(); } - d->lastIteration = d->currentIteration; + d->lastLoop = d->currentLoop; d->lastCurrentTime = d->currentTime; } @@ -207,7 +207,7 @@ void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() Q_ASSERT(animation); int uncontrolledRunningCount = 0; - if (animation->duration() == -1 || animation->iterationCount() < 0) { + if (animation->duration() == -1 || animation->loopCount() < 0) { QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); while (it != uncontrolledFinishTime.end()) { if (it.key() == animation) { @@ -248,7 +248,7 @@ void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() Q_Q(QParallelAnimationGroup); foreach (QAbstractAnimation *animation, animations) { - if (animation->duration() == -1 || animation->iterationCount() < 0) { + if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); } @@ -273,11 +273,11 @@ void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction dire } } else { if (direction == Forward) { - d->lastIteration = 0; + d->lastLoop = 0; d->lastCurrentTime = 0; } else { - // Looping backwards with iterationCount == -1 does not really work well... - d->lastIteration = (d->iterationCount == -1 ? 0 : d->iterationCount - 1); + // Looping backwards with loopCount == -1 does not really work well... + d->lastLoop = (d->loopCount == -1 ? 0 : d->loopCount - 1); d->lastCurrentTime = duration(); } } diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index 8a4dc1b..f36d972 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -64,12 +64,12 @@ class QParallelAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QParallelAnimationGroup) public: QParallelAnimationGroupPrivate() - : lastIteration(0), lastCurrentTime(0) + : lastLoop(0), lastCurrentTime(0) { } QHash<QAbstractAnimation*, int> uncontrolledFinishTime; - int lastIteration; + int lastLoop; int lastCurrentTime; bool isUncontrolledAnimationFinished(QAbstractAnimation *anim) const; diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 879532c..61ff98d 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -77,7 +77,7 @@ bool QSequentialAnimationGroupPrivate::atEnd() const // 3. the current animation is the last one // 4. the current animation has reached its end const int animTotalCurrentTime = QAbstractAnimationPrivate::get(currentAnimation)->totalCurrentTime; - return (currentIteration == iterationCount - 1 + return (currentLoop == loopCount - 1 && direction == QAbstractAnimation::Forward && currentAnimation == animations.last() && animTotalCurrentTime == animationActualTotalDuration(currentAnimationIndex)); @@ -101,7 +101,7 @@ QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivat int duration = 0; // in case duration is -1, currentLoop will always be 0 - ret.timeOffset = currentIteration * q->duration(); + ret.timeOffset = currentLoop * q->duration(); for (int i = 0; i < animations.size(); ++i) { duration = animationActualTotalDuration(i); @@ -133,13 +133,13 @@ void QSequentialAnimationGroupPrivate::restart() { // restarting the group by making the first/last animation the current one if (direction == QAbstractAnimation::Forward) { - lastIteration = 0; + lastLoop = 0; if (currentAnimationIndex == 0) activateCurrentAnimation(); else setCurrentAnimation(0); } else { // direction == QAbstractAnimation::Backward - lastIteration = iterationCount - 1; + lastLoop = loopCount - 1; int index = animations.size() - 1; if (currentAnimationIndex == index) activateCurrentAnimation(); @@ -156,7 +156,7 @@ void QSequentialAnimationGroupPrivate::restart() */ void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &newAnimationIndex) { - if (lastIteration < currentIteration) { + if (lastLoop < currentLoop) { // we need to fast forward to the end for (int i = currentAnimationIndex; i < animations.size(); ++i) { QAbstractAnimation *anim = animations.at(i); @@ -188,7 +188,7 @@ void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &new */ void QSequentialAnimationGroupPrivate::rewindForwards(const AnimationIndex &newAnimationIndex) { - if (lastIteration > currentIteration) { + if (lastLoop > currentLoop) { // we need to fast rewind to the beginning for (int i = currentAnimationIndex; i >= 0 ; --i) { QAbstractAnimation *anim = animations.at(i); @@ -329,12 +329,12 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs) d->actualDuration.removeLast(); // newAnimationIndex.index is the new current animation - if (d->lastIteration < d->currentIteration - || (d->lastIteration == d->currentIteration && d->currentAnimationIndex < newAnimationIndex.index)) { + if (d->lastLoop < d->currentLoop + || (d->lastLoop == d->currentLoop && d->currentAnimationIndex < newAnimationIndex.index)) { // advancing with forward direction is the same as rewinding with backwards direction d->advanceForwards(newAnimationIndex); - } else if (d->lastIteration > d->currentIteration - || (d->lastIteration == d->currentIteration && d->currentAnimationIndex > newAnimationIndex.index)) { + } else if (d->lastLoop > d->currentLoop + || (d->lastLoop == d->currentLoop && d->currentAnimationIndex > newAnimationIndex.index)) { // rewinding with forward direction is the same as advancing with backwards direction d->rewindForwards(newAnimationIndex); } @@ -358,7 +358,7 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs) stop(); } - d->lastIteration = d->currentIteration; + d->lastLoop = d->currentLoop; } /*! @@ -505,7 +505,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) setCurrentAnimation(0); // initialize the current animation if (currentAnimationIndex == index - && currentAnimation->currentTime() == 0 && currentAnimation->currentIteration() == 0) { + && currentAnimation->currentTime() == 0 && currentAnimation->currentLoop() == 0) { //in this case we simply insert an animation before the current one has actually started setCurrentAnimation(index); } @@ -513,7 +513,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) //we update currentAnimationIndex in case it has changed (the animation pointer is still valid) currentAnimationIndex = animations.indexOf(currentAnimation); - if (index < currentAnimationIndex || currentIteration != 0) { + if (index < currentAnimationIndex || currentLoop != 0) { qWarning("QSequentialGroup::insertAnimationAt only supports to add animations after the current one."); return; //we're not affected because it is added after the current one } @@ -562,7 +562,7 @@ void QSequentialAnimationGroupPrivate::animationRemovedAt(int index) } //let's also update the total current time - totalCurrentTime = currentTime + iterationCount * q->duration(); + totalCurrentTime = currentTime + loopCount * q->duration(); } QT_END_NAMESPACE diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 05d2a40..3ac90f8 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -64,7 +64,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QSequentialAnimationGroup) public: QSequentialAnimationGroupPrivate() - : currentAnimation(0), currentAnimationIndex(-1), lastIteration(0) + : currentAnimation(0), currentAnimationIndex(-1), lastLoop(0) { } @@ -96,7 +96,7 @@ public: QList<int> actualDuration; void restart(); - int lastIteration; + int lastLoop; // handle time changes void rewindForwards(const AnimationIndex &newAnimationIndex); diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 6b162ae..52e2901 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -279,7 +279,7 @@ QVariantAnimation::~QVariantAnimation() of the interpolated property. The easing curve is used with the interpolator, the interpolated() virtual - function, the animation's duration, and iterationCount, to control how the + function, the animation's duration, and loopCount, to control how the current value changes as the animation progresses. */ QEasingCurve QVariantAnimation::easingCurve() const diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index e468ac9..c51b471 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -97,7 +97,7 @@ public: bool atEnd() const { - return currentTime == duration && currentIteration == (iterationCount - 1); + return currentTime == duration && currentLoop == (loopCount - 1); } void setDefaultStartValue(const QVariant &value); |