summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-07 00:42:43 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-07 00:42:43 (GMT)
commit7825c0e89fffc1a41d71e5e7a791b10d3c182e32 (patch)
tree0a423272c0ecc883dd0de0455bc887e4fbd94f7a
parent15e78b8487ee223eb44acf3d34e1cb71f76234ca (diff)
downloadQt-7825c0e89fffc1a41d71e5e7a791b10d3c182e32.zip
Qt-7825c0e89fffc1a41d71e5e7a791b10d3c182e32.tar.gz
Qt-7825c0e89fffc1a41d71e5e7a791b10d3c182e32.tar.bz2
Use correct 'from' value for repeating animations.
Each loop, we need to check whether the user has set a from value, and if not get the current value.
-rw-r--r--doc/src/declarative/animation.qdoc17
-rw-r--r--src/declarative/util/qmlanimation.cpp3
-rw-r--r--src/declarative/util/qmlanimation_p.h14
3 files changed, 20 insertions, 14 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index f7e03ee..f17f5c9 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -25,7 +25,7 @@ Other Features:
\o Animation synchronization
\endlist
-The simplest form of animation is using \c NumericAnimation
+The simplest form of animation is using \l NumericAnimation
The following example creates a bouncing effect:
\code
@@ -34,20 +34,15 @@ Rect {
width: 120; height: 200; color: "white"
Image {
id: img
- source: "pics/qtlogo.png"
+ source: "qt-logo.png"
x: 60-img.width/2
- y: 200-img.height
+ y: 0
y: SequentialAnimation {
running: true
repeat: true
- NumericAnimation {
- to: 200-img.height
- easing: "easeOutBounce(amplitude:100)"
- duration: 2000
- }
- PauseAnimation {
- duration: 1000
- }
+ NumericAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 }
+ PauseAnimation { duration: 1000 }
+ NumericAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 }
}
}
}
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 08a7a28..dd4e1eb 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -791,6 +791,7 @@ void QmlColorAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->ca->setFromSourcedValue(&d->fromSourced);
}
QAbstractAnimation *QmlColorAnimation::qtAnimation()
@@ -1595,6 +1596,7 @@ void QmlNumericAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->na->setFromSourcedValue(&d->fromSourced);
}
QAbstractAnimation *QmlNumericAnimation::qtAnimation()
@@ -2152,6 +2154,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p)
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
+ d->va->setFromSourcedValue(&d->fromSourced);
}
void QmlVariantAnimation::transition(QmlStateActions &actions,
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 06b7c08..00937a6 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -116,8 +116,7 @@ private:
class QmlTimeLineValueAnimator : public QVariantAnimation
{
public:
- QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {}
- QmlTimeLineValueAnimator(QmlTimeLineValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {}
+ QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p)
{
if (state() == Running)
@@ -125,6 +124,10 @@ public:
animValue = value;
policy = p;
}
+ void setFromSourcedValue(bool *value)
+ {
+ fromSourced = value;
+ }
protected:
virtual void updateCurrentValue(const QVariant &value)
{
@@ -134,7 +137,11 @@ protected:
virtual void updateState(State oldState, State newState)
{
QVariantAnimation::updateState(oldState, newState);
- if (newState == Stopped && policy == DeleteWhenStopped) {
+ if (newState == Running) {
+ //check for new from every loop
+ if (fromSourced)
+ *fromSourced = false;
+ } else if (newState == Stopped && policy == DeleteWhenStopped) {
delete animValue;
animValue = 0;
}
@@ -142,6 +149,7 @@ protected:
private:
QmlTimeLineValue *animValue;
+ bool *fromSourced;
DeletionPolicy policy;
};