summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-02-17 02:13:29 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-02-18 05:17:15 (GMT)
commit9fb06ea43e807f2bbb40de89e9af5f2cca02212f (patch)
treed1cdc70f837be31188ab5c23fb7675a5216f3053 /src/declarative
parent2ea6cf7976fc9a2d8a67b32ba4854c9eeb583c81 (diff)
downloadQt-9fb06ea43e807f2bbb40de89e9af5f2cca02212f.zip
Qt-9fb06ea43e807f2bbb40de89e9af5f2cca02212f.tar.gz
Qt-9fb06ea43e807f2bbb40de89e9af5f2cca02212f.tar.bz2
Transitions and Behaviors should exclusively control their animations.
Don't allow manual control (starting, stopping, etc) of animations in a Behavior or Transition.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/util/qmlanimation.cpp23
-rw-r--r--src/declarative/util/qmlanimation_p.h1
-rw-r--r--src/declarative/util/qmlanimation_p_p.h4
-rw-r--r--src/declarative/util/qmlbehavior.cpp4
-rw-r--r--src/declarative/util/qmltransition.cpp1
5 files changed, 25 insertions, 8 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index cdd5e9a..dd783ca 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -249,7 +249,7 @@ void QmlAbstractAnimation::setRunning(bool r)
if (d->running == r)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
return;
}
@@ -308,7 +308,7 @@ void QmlAbstractAnimation::setPaused(bool p)
if (d->paused == p)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
return;
}
@@ -544,15 +544,28 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p)
setRunning(true);
}
-//we rely on setTarget only being called when used as a value source
-//so this function allows us to do the same thing as setTarget without
-//that assumption
+/*
+ we rely on setTarget only being called when used as a value source
+ so this function allows us to do the same thing as setTarget without
+ that assumption
+*/
void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p)
{
Q_D(QmlAbstractAnimation);
d->defaultProperty = p;
}
+/*
+ don't allow start/stop/pause/resume to be manually invoked,
+ because something else (like a Behavior) already has control
+ over the animation.
+*/
+void QmlAbstractAnimation::setDisableUserControl()
+{
+ Q_D(QmlAbstractAnimation);
+ d->disableUserControl = true;
+}
+
void QmlAbstractAnimation::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 74330da..791a127 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -95,6 +95,7 @@ public:
void setGroup(QmlAnimationGroup *);
void setDefaultTarget(const QmlMetaProperty &);
+ void setDisableUserControl();
void classBegin();
void componentComplete();
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 91f9f88..288aaa8 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -210,17 +210,17 @@ public:
QmlAbstractAnimationPrivate()
: running(false), paused(false), alwaysRunToEnd(false), repeat(false),
connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
- avoidPropertyValueSourceStart(false), group(0) {}
+ avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
bool running:1;
bool paused:1;
bool alwaysRunToEnd:1;
bool repeat:1;
bool connectedTimeLine:1;
-
bool componentComplete:1;
bool startOnCompletion:1;
bool avoidPropertyValueSourceStart:1;
+ bool disableUserControl:1;
void commence();
diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp
index 5e11dea..276e2d0 100644
--- a/src/declarative/util/qmlbehavior.cpp
+++ b/src/declarative/util/qmlbehavior.cpp
@@ -124,8 +124,10 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation)
}
d->animation = animation;
- if (d->animation)
+ if (d->animation) {
d->animation->setDefaultTarget(d->property);
+ d->animation->setDisableUserControl();
+ }
}
/*!
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index f077982..d9e4bed 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -117,6 +117,7 @@ void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
{
QmlConcreteList<QmlAbstractAnimation *>::append(a);
parent->group.addAnimation(a->qtAnimation());
+ a->setDisableUserControl();
}
void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)