aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/animations
diff options
context:
space:
mode:
authorCharles Yin <yinyunqiao@gmail.com>2012-03-08 00:12:58 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-13 23:50:52 +0100
commitc67ed6887a8ee2fac935d81630b4b77926486c9b (patch)
tree1b9dff98f2fe8e83927400b3743923db93fa9a42 /src/qml/animations
parentc291efff26c13963cf98c127bfa759f89f103e48 (diff)
More refactoring on animation controller
Add a flag and helper functions for disabling user control in QAbstractAnimationJob class and make it synchronized with QDeclarativeAnimation class's disableUserControl flag. Change-Id: Ifa84ab0c78291941469c33f2cafe5f61ee718b2c Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/animations')
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp36
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h13
2 files changed, 40 insertions, 9 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index a540382847..fecd8fbc5d 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -161,6 +161,9 @@ void QQmlAnimationTimer::stopTimer()
void QQmlAnimationTimer::registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel)
{
+ if (animation->userControlDisabled())
+ return;
+
QQmlAnimationTimer *inst = instance(true); //we create the instance if needed
inst->registerRunningAnimation(animation);
if (isTopLevel) {
@@ -206,6 +209,8 @@ void QQmlAnimationTimer::unregisterAnimation(QAbstractAnimationJob *animation)
void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animation)
{
+ Q_ASSERT(!animation->userControlDisabled());
+
if (animation->m_isGroup)
return;
@@ -217,6 +222,9 @@ void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animati
void QQmlAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation)
{
+ if (animation->userControlDisabled())
+ return;
+
if (animation->m_isGroup)
return;
@@ -248,20 +256,21 @@ int QQmlAnimationTimer::closestPauseAnimationTimeToFinish()
/////////////////////////////////////////////////////////////////////////////////////////////////////////
QAbstractAnimationJob::QAbstractAnimationJob()
- : m_isPause(false)
- , m_isGroup(false)
- , m_loopCount(1)
+ : m_loopCount(1)
, m_group(0)
, m_direction(QAbstractAnimationJob::Forward)
, m_state(QAbstractAnimationJob::Stopped)
, m_totalCurrentTime(0)
, m_currentTime(0)
, m_currentLoop(0)
- , m_hasRegisteredTimer(false)
, m_uncontrolledFinishTime(-1)
- , m_wasDeleted(0)
, m_nextSibling(0)
, m_previousSibling(0)
+ , m_wasDeleted(0)
+ , m_hasRegisteredTimer(false)
+ , m_isPause(false)
+ , m_isGroup(false)
+ , m_disableUserControl(false)
{
}
@@ -482,6 +491,23 @@ void QAbstractAnimationJob::resume()
setState(Running);
}
+void QAbstractAnimationJob::setEnableUserControl()
+{
+ m_disableUserControl = false;
+}
+
+bool QAbstractAnimationJob::userControlDisabled() const
+{
+ return m_disableUserControl;
+}
+
+void QAbstractAnimationJob::setDisableUserControl()
+{
+ m_disableUserControl = true;
+ start();
+ pause();
+}
+
void QAbstractAnimationJob::updateState(QAbstractAnimationJob::State newState,
QAbstractAnimationJob::State oldState)
{
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index f00090cb30..e7d96ddfce 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -93,6 +93,9 @@ public:
inline bool isRunning() { return m_state == Running; }
inline bool isStopped() { return m_state == Stopped; }
inline bool isPaused() { return m_state == Paused; }
+ void setDisableUserControl();
+ void setEnableUserControl();
+ bool userControlDisabled() const;
void setCurrentTime(int msecs);
@@ -128,8 +131,6 @@ protected:
void directionChanged(QAbstractAnimationJob::Direction);
//definition
- bool m_isPause;
- bool m_isGroup;
int m_loopCount;
QAnimationGroupJob *m_group;
QAbstractAnimationJob::Direction m_direction;
@@ -139,10 +140,8 @@ protected:
int m_totalCurrentTime;
int m_currentTime;
int m_currentLoop;
- bool m_hasRegisteredTimer;
//records the finish time for an uncontrolled animation (used by animation groups)
int m_uncontrolledFinishTime;
- bool *m_wasDeleted;
struct ChangeListener {
ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {}
@@ -155,6 +154,12 @@ protected:
QAbstractAnimationJob *m_nextSibling;
QAbstractAnimationJob *m_previousSibling;
+ bool *m_wasDeleted;
+ bool m_hasRegisteredTimer:1;
+ bool m_isPause:1;
+ bool m_isGroup:1;
+ bool m_disableUserControl:1;
+
friend class QQmlAnimationTimer;
friend class QAnimationGroupJob;
};