summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativesmoothedanimation.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-04-08 07:37:06 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-04-08 07:37:06 (GMT)
commit28605b56271cd3efb78c5f2f51855d2bca56ee6f (patch)
tree3bc0988400d8d8f4dd251c94d20443ecd3f6b150 /src/declarative/util/qdeclarativesmoothedanimation.cpp
parent3ceffd7287a269ec5ea9dab712ee9120a539e0e1 (diff)
parentbe8a7153d613586d69ac528153a6b8ccbe931aa6 (diff)
downloadQt-28605b56271cd3efb78c5f2f51855d2bca56ee6f.zip
Qt-28605b56271cd3efb78c5f2f51855d2bca56ee6f.tar.gz
Qt-28605b56271cd3efb78c5f2f51855d2bca56ee6f.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts: examples/declarative/tutorials/samegame/samegame4/content/samegame.js
Diffstat (limited to 'src/declarative/util/qdeclarativesmoothedanimation.cpp')
-rw-r--r--src/declarative/util/qdeclarativesmoothedanimation.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp
index 3411642..48a7583 100644
--- a/src/declarative/util/qdeclarativesmoothedanimation.cpp
+++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp
@@ -69,6 +69,7 @@ QSmoothedAnimation::QSmoothedAnimation(QObject *parent)
void QSmoothedAnimation::restart()
{
+ initialVelocity = trackVelocity;
if (state() != QAbstractAnimation::Running)
start();
else
@@ -224,6 +225,7 @@ void QSmoothedAnimation::init()
QDeclarativePropertyPrivate::write(target, to,
QDeclarativePropertyPrivate::BypassInterceptor
| QDeclarativePropertyPrivate::DontRemoveBinding);
+ stop();
return;
case QDeclarativeSmoothedAnimation::Immediate:
initialVelocity = 0;
@@ -248,13 +250,14 @@ void QSmoothedAnimation::init()
/*!
\qmlclass SmoothedAnimation QDeclarativeSmoothedAnimation
\since 4.7
+ \inherits NumberAnimation
\brief The SmoothedAnimation element allows a property to smoothly track a value.
- The SmoothedAnimation smoothly animates a property's value to a set target value
+ The SmoothedAnimation animates a property's value to a set target value
using an ease in/out quad easing curve. If the animation is restarted
with a different target value, the easing curves used to animate to the old
- and the new target values are spliced together to avoid any obvious visual
- glitches.
+ and the new target values are smoothly spliced together to avoid any obvious
+ visual glitches by maintaining the current velocity.
The property animation is configured by setting the velocity at which the
animation should occur, or the duration that the animation should take.
@@ -270,7 +273,7 @@ void QSmoothedAnimation::init()
The follow example shows one rectangle tracking the position of another.
\code
-import Qt 4.6
+import Qt 4.7
Rectangle {
width: 800; height: 600; color: "blue"
@@ -343,17 +346,14 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions
QSet<QAbstractAnimation*> anims;
for (int i = 0; i < d->actions->size(); i++) {
QSmoothedAnimation *ease;
- qreal trackVelocity;
bool needsRestart;
if (!d->activeAnimations.contains((*d->actions)[i].property)) {
ease = new QSmoothedAnimation();
d->wrapperGroup->addAnimation(ease);
d->activeAnimations.insert((*d->actions)[i].property, ease);
- trackVelocity = 0.0;
needsRestart = false;
} else {
ease = d->activeAnimations.value((*d->actions)[i].property);
- trackVelocity = ease->trackVelocity;
needsRestart = true;
}
@@ -366,8 +366,7 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions
ease->velocity = d->anim->velocity;
ease->userDuration = d->anim->userDuration;
- ease->trackVelocity = trackVelocity;
- ease->initialVelocity = trackVelocity;
+ ease->initialVelocity = ease->trackVelocity;
if (needsRestart)
ease->init();
@@ -458,14 +457,14 @@ void QDeclarativeSmoothedAnimation::setVelocity(qreal v)
}
/*!
-\qmlproperty qreal SmoothedAnimation::maximumEasingTime
+ \qmlproperty qreal SmoothedAnimation::maximumEasingTime
-This property specifies the maximum time, in msecs, an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
-duration.
+ This property specifies the maximum time, in msecs, an "eases" during the follow should take.
+ Setting this property causes the velocity to "level out" after at a time. Setting
+ a negative value reverts to the normal mode of easing over the entire animation
+ duration.
-The default value is -1.
+ The default value is -1.
*/
int QDeclarativeSmoothedAnimation::maximumEasingTime() const
{