summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/samegame/SamegameCore/BoomBlock.qml11
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js7
-rw-r--r--doc/src/declarative/advtutorial.qdoc11
-rw-r--r--doc/src/declarative/elements.qdoc3
-rw-r--r--doc/src/examples/qml-examples.qdoc6
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml6
-rw-r--r--doc/src/snippets/declarative/listview/listview.qml10
-rw-r--r--examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml16
-rw-r--r--examples/declarative/modelviews/listview/highlight.qml5
-rw-r--r--examples/declarative/toys/clocks/content/Clock.qml35
-rw-r--r--examples/declarative/toys/corkboards/Day.qml6
-rw-r--r--examples/declarative/toys/tvtennis/tvtennis.qml24
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml11
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js7
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/util/qdeclarativesmoothedfollow.cpp299
-rw-r--r--src/declarative/util/qdeclarativesmoothedfollow_p.h113
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp464
-rw-r--r--src/declarative/util/qdeclarativespringfollow_p.h120
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp4
-rw-r--r--src/declarative/util/util.pri4
-rw-r--r--tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml4
-rw-r--r--tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml (renamed from tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml)5
-rw-r--r--tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml (renamed from tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml)4
-rw-r--r--tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro (renamed from tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro)2
-rw-r--r--tests/auto/declarative/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp (renamed from tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp)44
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml4
28 files changed, 113 insertions, 1116 deletions
diff --git a/demos/declarative/samegame/SamegameCore/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
index 3f4357915a..43050af25d 100644
--- a/demos/declarative/samegame/SamegameCore/BoomBlock.qml
+++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -47,11 +47,14 @@ Item {
property bool dying: false
property bool spawned: false
property int type: 0
- property int targetX: 0
- property int targetY: 0
- SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
- SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
Image {
id: img
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index 5c008a2a46..6e1b24dd80 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -110,7 +110,7 @@ function shuffleDown()
}else{
if(fallDist > 0){
var obj = board[index(column,row)];
- obj.targetY += fallDist * gameCanvas.blockSize;
+ obj.y += fallDist * gameCanvas.blockSize;
board[index(column,row+fallDist)] = obj;
board[index(column,row)] = null;
}
@@ -128,7 +128,7 @@ function shuffleDown()
obj = board[index(column,row)];
if(obj == null)
continue;
- obj.targetX -= fallDist * gameCanvas.blockSize;
+ obj.x -= fallDist * gameCanvas.blockSize;
board[index(column-fallDist,row)] = obj;
board[index(column,row)] = null;
}
@@ -184,8 +184,7 @@ function createBlock(column,row){
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.x = column*gameCanvas.blockSize;
- dynamicObject.targetX = column*gameCanvas.blockSize;
- dynamicObject.targetY = row*gameCanvas.blockSize;
+ dynamicObject.y = row*gameCanvas.blockSize;
dynamicObject.width = gameCanvas.blockSize;
dynamicObject.height = gameCanvas.blockSize;
dynamicObject.spawned = true;
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 2c3610c44c..afedb44d83 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -306,18 +306,17 @@ In anticipation of the new block animations, \c Block.qml file is now renamed to
\section3 Animating block movement
First we will animate the blocks so that they move in a fluid manner. QML has a number of methods for adding fluid
-movement, and in this case we're going to use the \l SpringFollow element to add an animation with a spring-like
-movement. In \c BoomBlock.qml, we apply a \l SpringFollow
-to the \c x and \c y properties so that the block will follow and animate its movement towards the
-position specified by the new \c targetX and \c targetY properties (whose values will be set by \c samegame.js).
-Here is the code added to \c BoomBlock.qml:
+movement, and in this case we're going to use the \l Behavior element to add a \l SpringAnimation.
+In \c BoomBlock.qml, we apply a \l SpringAnimation behavior to the \c x and \c y properties so that the
+block will follow and animate its movement in a spring-like fashion towards the specified position (whose
+values will be set by \c samegame.js).Here is the code added to \c BoomBlock.qml:
\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1
The \c spring and \c damping values can be changed to modify the spring-like effect of the animation.
The \c {enabled: spawned} setting refers to the \c spawned value that is set from \c createBlock() in \c samegame.js.
-This ensures the \l SpringFollow on the \c x is only enabled after \c createBlock() has set the block to
+This ensures the \l SpringAnimation on the \c x is only enabled after \c createBlock() has set the block to
the correct position. Otherwise, the blocks will slide out of the corner (0,0) when a game begins, instead of falling
from the top in rows. (Try commenting out \c {enabled: spawned} and see for yourself.)
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 48eb09fd30..0edd242ae8 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -76,11 +76,10 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt
\row \o \l {AnchorAnimation} \o Animates anchor changes
\row \o \l {PauseAnimation} \o Pauses an animation
\row \o \l {SmoothedAnimation} \o Allows a property to smoothly track a value
+\row \o \l {SpringAnimation} \o Allows a property to track a value in a spring-like motion
\row \o \l {PropertyAction} \o Sets immediate property changes during animation
\row \o \l {ScriptAction} \o Runs scripts during an animation
\row \o \l {Transition} \o Animates transitions during state changes
-\row \o \l {SpringFollow} \o Allows a property to follow value changes
-\row \o \l {SmoothedFollow} \o Allows animation to smoothly follow value changes
\header \o {2,1} \bold {Working with Data}
\row \o \l {Binding} \o Binds any value to any property
diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc
index 4ad11d97e9..ce5367705d 100644
--- a/doc/src/examples/qml-examples.qdoc
+++ b/doc/src/examples/qml-examples.qdoc
@@ -477,7 +477,7 @@
This example displays a set of clocks with different times for different cities.
Each clock is created by combining \l Image elements with \l Rotation transforms
- and \l SpringFollow animations.
+ and \l SpringAnimation behaviors.
\image qml-clocks-example.png
*/
@@ -517,7 +517,7 @@
\title Toys: TV Tennis
\example declarative/toys/tvtennis
- This example shows how to use animation components such as \l SpringFollow,
+ This example shows how to use animation components such as \l SpringAnimation,
\l SequentialAnimation and \l PropertyAction to create a game of TV tennis.
\image qml-tvtennis-example.png
@@ -545,7 +545,7 @@
\example declarative/ui-components/dialcontrol
This example shows how to create a dial-type control. It combines
- \l Image elements with \l Rotation transforms and \l SpringFollow animations
+ \l Image elements with \l Rotation transforms and \l SpringAnimatino behaviors
to produce an interactive speedometer-type dial.
\image qml-dialcontrol-example.png
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
index 7377cee76d..e92a429df4 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -108,8 +108,10 @@ Component {
Rectangle {
width: view.cellWidth; height: view.cellHeight
color: "lightsteelblue"; radius: 5
- SpringFollow on x { to: view.currentItem.x; spring: 3; damping: 0.2 }
- SpringFollow on y { to: view.currentItem.y; spring: 3; damping: 0.2 }
+ x: view.currentItem.x
+ y: view.currentItem.y
+ Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } }
+ Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } }
}
}
diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml
index 0c6dfd4dc7..cde820e2cd 100644
--- a/doc/src/snippets/declarative/listview/listview.qml
+++ b/doc/src/snippets/declarative/listview/listview.qml
@@ -99,10 +99,12 @@ Component {
Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
- SpringFollow on y {
- to: list.currentItem.y
- spring: 3
- damping: 0.2
+ y: list.currentItem.y
+ Behavior on y {
+ SpringAnimation {
+ spring: 3
+ damping: 0.2
+ }
}
}
}
diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml
index 37128b5aa6..6b2676e7e7 100644
--- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml
+++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml
@@ -57,10 +57,10 @@ Rectangle {
smooth: true
transform: Rotation {
id: hourRotation
- origin.x: 7.5; origin.y: 73; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: (clock.hours * 30) + (clock.minutes * 0.5)
+ origin.x: 7.5; origin.y: 73;
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+ Behavior on angle {
+ SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -71,10 +71,10 @@ Rectangle {
smooth: true
transform: Rotation {
id: minuteRotation
- origin.x: 6.5; origin.y: 83; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: clock.minutes * 6
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml
index 4c14f2a041..2d68da6f9c 100644
--- a/examples/declarative/modelviews/listview/highlight.qml
+++ b/examples/declarative/modelviews/listview/highlight.qml
@@ -39,7 +39,7 @@
****************************************************************************/
// This example shows how to create your own highlight delegate for a ListView
-// that uses a SpringFollow animation to provide custom movement when the
+// that uses a SpringAnimation to provide custom movement when the
// highlight bar is moved between items.
import Qt 4.7
@@ -78,7 +78,8 @@ Rectangle {
Rectangle {
width: 200; height: 50
color: "#FFFF88"
- SpringFollow on y { to: listView.currentItem.y; spring: 3; damping: 0.1 }
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
}
}
diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml
index 136573b69f..24a07ecef6 100644
--- a/examples/declarative/toys/clocks/content/Clock.qml
+++ b/examples/declarative/toys/clocks/content/Clock.qml
@@ -45,10 +45,10 @@ Item {
width: 200; height: 230
property alias city: cityLabel.text
- property variant hours
- property variant minutes
- property variant seconds
- property variant shift : 0
+ property int hours
+ property int minutes
+ property int seconds
+ property real shift
property bool night: false
function timeChanged() {
@@ -60,23 +60,24 @@ Item {
}
Timer {
- interval: 100; running: true; repeat: true; triggeredOnStart: true
+ interval: 100; running: true; repeat: true;
onTriggered: clock.timeChanged()
}
Image { id: background; source: "clock.png"; visible: clock.night == false }
Image { source: "clock-night.png"; visible: clock.night == true }
+
Image {
x: 92.5; y: 27
source: "hour.png"
smooth: true
transform: Rotation {
id: hourRotation
- origin.x: 7.5; origin.y: 73; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: (clock.hours * 30) + (clock.minutes * 0.5)
+ origin.x: 7.5; origin.y: 73;
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+ Behavior on angle {
+ NumberAnimation{}
}
}
}
@@ -87,10 +88,10 @@ Item {
smooth: true
transform: Rotation {
id: minuteRotation
- origin.x: 6.5; origin.y: 83; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: clock.minutes * 6
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ NumberAnimation{}
}
}
}
@@ -101,10 +102,10 @@ Item {
smooth: true
transform: Rotation {
id: secondRotation
- origin.x: 2.5; origin.y: 80; angle: 0
- SpringFollow on angle {
- spring: 5; damping: 0.25; modulus: 360
- to: clock.seconds * 6
+ origin.x: 2.5; origin.y: 80;
+ angle: clock.seconds * 6
+ Behavior on angle {
+ NumberAnimation{}
}
}
}
diff --git a/examples/declarative/toys/corkboards/Day.qml b/examples/declarative/toys/corkboards/Day.qml
index cc297b13f8..9d1f3ae329 100644
--- a/examples/declarative/toys/corkboards/Day.qml
+++ b/examples/declarative/toys/corkboards/Day.qml
@@ -70,9 +70,9 @@ Component {
x: randomX; y: randomY
- SpringFollow on rotation {
- to: -flickable.horizontalVelocity / 100
- spring: 2.0; damping: 0.15
+ rotation: -flickable.horizontalVelocity / 100;
+ Behavior on rotation {
+ SpringAnimation { spring: 2.0; damping: 0.15 }
}
Item {
diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml
index 726c649e4a..2e144ed8de 100644
--- a/examples/declarative/toys/tvtennis/tvtennis.qml
+++ b/examples/declarative/toys/tvtennis/tvtennis.qml
@@ -50,7 +50,6 @@ Rectangle {
id: ball
// Add a property for the target y coordinate
- property int targetY : page.height - 10
property variant direction : "right"
x: 20; width: 20; height: 20; z: 1
@@ -65,15 +64,18 @@ Rectangle {
PropertyAction { target: ball; property: "direction"; value: "right" }
}
- // Make y follow the target y coordinate, with a velocity of 200
- SpringFollow on y { to: ball.targetY; velocity: 200 }
+ // Make y move with a velocity of 200
+ Behavior on y { SpringAnimation{ velocity: 200; }
+ }
+
+ Component.onCompleted: y = page.height-10; // start the ball motion
// Detect the ball hitting the top or bottom of the view and bounce it
onYChanged: {
if (y <= 0) {
- targetY = page.height - 20;
+ y = page.height - 20;
} else if (y >= page.height - 20) {
- targetY = 0;
+ y = 0;
}
}
}
@@ -84,19 +86,15 @@ Rectangle {
id: leftBat
color: "Lime"
x: 2; width: 20; height: 90
- SpringFollow on y {
- to: ball.y - 45; velocity: 300
- enabled: ball.direction == 'left'
- }
+ y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
}
Rectangle {
id: rightBat
color: "Lime"
x: page.width - 22; width: 20; height: 90
- SpringFollow on y {
- to: ball.y-45; velocity: 300
- enabled: ball.direction == 'right'
- }
+ y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
}
// The rest, to make it look realistic, if neither ever scores...
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
index 1f51e13dd9..92c607fabf 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -49,11 +49,14 @@ Item {
//![1]
property bool spawned: false
- property int targetX: 0
- property int targetY: 0
- SpringFollow on x { to: targetX; spring: 2; damping: 0.2; enabled: spawned }
- SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
//![1]
//![2]
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index 930a3d8734..b1f427c8d7 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -57,8 +57,7 @@ function createBlock(column, row) {
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.x = column * gameCanvas.blockSize;
- dynamicObject.targetX = column * gameCanvas.blockSize;
- dynamicObject.targetY = row * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
dynamicObject.width = gameCanvas.blockSize;
dynamicObject.height = gameCanvas.blockSize;
dynamicObject.spawned = true;
@@ -128,7 +127,7 @@ function shuffleDown() {
} else {
if (fallDist > 0) {
var obj = board[index(column, row)];
- obj.targetY += fallDist * gameCanvas.blockSize;
+ obj.y += fallDist * gameCanvas.blockSize;
board[index(column, row + fallDist)] = obj;
board[index(column, row)] = null;
}
@@ -146,7 +145,7 @@ function shuffleDown() {
obj = board[index(column, row)];
if (obj == null)
continue;
- obj.targetX -= fallDist * gameCanvas.blockSize;
+ obj.x -= fallDist * gameCanvas.blockSize;
board[index(column - fallDist, row)] = obj;
board[index(column, row)] = null;
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 3efb9ad098..dce6f0e40a 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1390,7 +1390,7 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
highlight is not moved by the view, and any movement must be implemented
by the highlight.
- Here is a highlight with its motion defined by a \l {SpringFollow} item:
+ Here is a highlight with its motion defined by a \l {SpringAnimation} item:
\snippet doc/src/snippets/declarative/gridview/gridview.qml highlightFollowsCurrentItem
*/
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 9497cb7d22..91e9995ca3 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1727,7 +1727,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight)
highlight is not moved by the view, and any movement must be implemented
by the highlight.
- Here is a highlight with its motion defined by a \l {SpringFollow} item:
+ Here is a highlight with its motion defined by a \l {SpringAniamtion} item:
\snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem
diff --git a/src/declarative/util/qdeclarativesmoothedfollow.cpp b/src/declarative/util/qdeclarativesmoothedfollow.cpp
deleted file mode 100644
index f70df9d924..0000000000
--- a/src/declarative/util/qdeclarativesmoothedfollow.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativesmoothedfollow_p.h"
-#include "qdeclarativesmoothedanimation_p_p.h"
-
-#include <private/qobject_p.h>
-#include <QtCore/qnumeric.h>
-
-#include "qdeclarativeglobal_p.h"
-
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSmoothedFollowPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeSmoothedFollow)
-public:
- QDeclarativeSmoothedFollowPrivate();
-
- bool enabled;
- QSmoothedAnimation *anim;
-};
-
-/*!
- \qmlclass SmoothedFollow QDeclarativeSmoothedFollow
- \since 4.7
- \inherits NumberAnimation
- \brief The SmoothedFollow element allows a property to smoothly track a value.
-
- The SmoothedFollow 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 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.
- If both a velocity and a duration are specified, the one that results in
- the quickest animation is chosen for each change in the target value.
-
- For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
- take 4 seconds with both a velocity of 200 and a duration of 8000 set.
- Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
- will take 8 seconds with a duration of 8000 set, and will take 8 seconds
- with both a velocity of 200 and a duration of 8000 set.
-
- The follow example shows one rectangle tracking the position of another.
-\code
-import Qt 4.7
-
-Rectangle {
- width: 800; height: 600; color: "blue"
-
- Rectangle {
- color: "green"
- width: 60; height: 60;
- SmoothedFollow on x { to: rect1.x - 5; velocity: 200 }
- SmoothedFollow on y { to: rect1.y - 5; velocity: 200 }
- }
-
- Rectangle {
- id: rect1
- color: "red"
- width: 50; height: 50;
- }
-
- focus: true
- Keys.onRightPressed: rect1.x = rect1.x + 100
- Keys.onLeftPressed: rect1.x = rect1.x - 100
- Keys.onUpPressed: rect1.y = rect1.y - 100
- Keys.onDownPressed: rect1.y = rect1.y + 100
-}
-\endcode
-
- The default velocity of SmoothedFollow is 200 units/second. Note that if the range of the
- value being animated is small, then the velocity will need to be adjusted
- appropriately. For example, the opacity of an item ranges from 0 - 1.0.
- To enable a smooth animation in this range the velocity will need to be
- set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
- of 0.5 will take 2000 ms to complete.
-
- \sa SpringFollow
-*/
-
-QDeclarativeSmoothedFollow::QDeclarativeSmoothedFollow(QObject *parent)
- : QObject(*(new QDeclarativeSmoothedFollowPrivate), parent)
-{
-}
-
-QDeclarativeSmoothedFollow::~QDeclarativeSmoothedFollow()
-{
-}
-
-QDeclarativeSmoothedFollowPrivate::QDeclarativeSmoothedFollowPrivate()
- : enabled(true), anim(new QSmoothedAnimation)
-{
- Q_Q(QDeclarativeSmoothedFollow);
- QDeclarative_setParent_noEvent(anim, q);
-}
-
-/*!
- \qmlproperty enumeration SmoothedFollow::reversingMode
-
- Sets how the SmoothedFollow behaves if an animation direction is reversed.
-
- If reversing mode is \c SmoothedFollow.Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c SmoothedFollow.Immediate, the
- animation will immediately begin accelerating in the reverse direction,
- begining with a velocity of 0. If the reversing mode is \c SmoothedFollow.Sync, the
- property is immediately set to the target value.
-*/
-QDeclarativeSmoothedFollow::ReversingMode QDeclarativeSmoothedFollow::reversingMode() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return (ReversingMode) d->anim->reversingMode;
-}
-
-void QDeclarativeSmoothedFollow::setReversingMode(ReversingMode m)
-{
- Q_D(QDeclarativeSmoothedFollow);
- if (d->anim->reversingMode == (QDeclarativeSmoothedAnimation::ReversingMode) m)
- return;
-
- d->anim->reversingMode = (QDeclarativeSmoothedAnimation::ReversingMode) m;
- emit reversingModeChanged();
-}
-
-/*!
- \qmlproperty int SmoothedFollow::duration
-
- This property holds the animation duration, in msecs, used when tracking the source.
-
- Setting this to -1 (the default) disables the duration value.
-*/
-int QDeclarativeSmoothedFollow::duration() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return d->anim->userDuration;
-}
-
-void QDeclarativeSmoothedFollow::setDuration(int duration)
-{
- Q_D(QDeclarativeSmoothedFollow);
- if (duration == d->anim->duration())
- return;
-
- d->anim->userDuration = duration;
- emit durationChanged();
-}
-
-qreal QDeclarativeSmoothedFollow::velocity() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return d->anim->velocity;
-}
-
-/*!
- \qmlproperty real SmoothedFollow::velocity
-
- This property holds the average velocity allowed when tracking the 'to' value.
-
- The default velocity of SmoothedFollow is 200 units/second.
-
- Setting this to -1 disables the velocity value.
-*/
-void QDeclarativeSmoothedFollow::setVelocity(qreal v)
-{
- Q_D(QDeclarativeSmoothedFollow);
- if (d->anim->velocity == v)
- return;
-
- d->anim->velocity = v;
- emit velocityChanged();
-}
-
-/*!
- \qmlproperty int SmoothedFollow::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.
-
- The default value is -1.
-*/
-int QDeclarativeSmoothedFollow::maximumEasingTime() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return d->anim->maximumEasingTime;
-}
-
-void QDeclarativeSmoothedFollow::setMaximumEasingTime(int v)
-{
- Q_D(QDeclarativeSmoothedFollow);
- d->anim->maximumEasingTime = v;
- emit maximumEasingTimeChanged();
-}
-
-/*!
- \qmlproperty real SmoothedFollow::to
- This property holds the ending value.
- If not set, then the value defined in the end state of the transition or Behavior.
-*/
-qreal QDeclarativeSmoothedFollow::to() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return d->anim->to;
-}
-
-void QDeclarativeSmoothedFollow::setTo(qreal t)
-{
- Q_D(QDeclarativeSmoothedFollow);
-
- if (qIsNaN(t))
- return;
-
- if (d->anim->to == t)
- return;
-
- d->anim->to = t;
-
- if (d->enabled)
- d->anim->restart();
-}
-
-/*!
- \qmlproperty bool SmoothedFollow::enabled
- This property whether this animation should automatically restart when
- the 'to' property is upated.
-
- The default value of this property is 'true'.
-*/
-bool QDeclarativeSmoothedFollow::enabled() const
-{
- Q_D(const QDeclarativeSmoothedFollow);
- return d->enabled;
-}
-
-void QDeclarativeSmoothedFollow::setEnabled(bool e)
-{
- Q_D(QDeclarativeSmoothedFollow);
- if (d->enabled == e)
- return;
- d->enabled = e;
-
- if (d->enabled)
- d->anim->restart();
- else
- d->anim->stop();
- emit enabledChanged();
-}
-
-void QDeclarativeSmoothedFollow::setTarget(const QDeclarativeProperty &t)
-{
- Q_D(QDeclarativeSmoothedFollow);
- d->anim->target = t;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativesmoothedfollow_p.h b/src/declarative/util/qdeclarativesmoothedfollow_p.h
deleted file mode 100644
index f852311e56..0000000000
--- a/src/declarative/util/qdeclarativesmoothedfollow_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHEDFOLLOW_H
-#define QDECLARATIVESMOOTHEDFOLLOW_H
-
-#include <qdeclarative.h>
-#include <qdeclarativepropertyvaluesource.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeProperty;
-class QDeclarativeSmoothedFollowPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeSmoothedFollow : public QObject,
- public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeSmoothedFollow)
- Q_INTERFACES(QDeclarativePropertyValueSource)
- Q_ENUMS(ReversingMode)
-
- Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
- Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
-
-public:
- enum ReversingMode { Eased, Immediate, Sync };
-
- QDeclarativeSmoothedFollow(QObject *parent = 0);
- ~QDeclarativeSmoothedFollow();
-
- qreal to() const;
- void setTo(qreal);
-
- ReversingMode reversingMode() const;
- void setReversingMode(ReversingMode);
-
- int duration() const;
- void setDuration(int);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- int maximumEasingTime() const;
- void setMaximumEasingTime(int);
-
- bool enabled() const;
- void setEnabled(bool);
-
- virtual void setTarget(const QDeclarativeProperty &);
-
-Q_SIGNALS:
- void velocityChanged();
- void durationChanged();
- void reversingModeChanged();
- void maximumEasingTimeChanged();
- void enabledChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSmoothedFollow)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESMOOTHEDFOLLOW_H
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
deleted file mode 100644
index aae66ac52a..0000000000
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ /dev/null
@@ -1,464 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qdeclarativespringfollow_p.h"
-
-#include "private/qdeclarativeanimation_p_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include <limits.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarativeSpringFollowPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeSpringFollow)
-public:
- QDeclarativeSpringFollowPrivate()
- : currentValue(0), to(0), maxVelocity(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01)
- , modulus(0.0), useMass(false), haveModulus(false), enabled(true), mode(Track), clock(this) {}
-
- QDeclarativeProperty property;
- qreal currentValue;
- qreal to;
- qreal maxVelocity;
- qreal velocityms;
- int lastTime;
- qreal mass;
- qreal spring;
- qreal damping;
- qreal velocity;
- qreal epsilon;
- qreal modulus;
-
- bool useMass : 1;
- bool haveModulus : 1;
- bool enabled : 1;
-
- enum Mode {
- Track,
- Velocity,
- Spring
- };
- Mode mode;
-
- void tick(int);
- void updateMode();
- void start();
- void stop();
-
- QTickAnimationProxy<QDeclarativeSpringFollowPrivate, &QDeclarativeSpringFollowPrivate::tick> clock;
-};
-
-void QDeclarativeSpringFollowPrivate::tick(int time)
-{
- Q_Q(QDeclarativeSpringFollow);
-
- int elapsed = time - lastTime;
- if (!elapsed)
- return;
- qreal srcVal = to;
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- srcVal = fmod(srcVal, modulus);
- }
- if (mode == Spring) {
- if (elapsed < 16) // capped at 62fps.
- return;
- // Real men solve the spring DEs using RK4.
- // We'll do something much simpler which gives a result that looks fine.
- int count = elapsed / 16;
- for (int i = 0; i < count; ++i) {
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (useMass)
- velocity = velocity + (spring * diff - damping * velocity) / mass;
- else
- velocity = velocity + spring * diff - damping * velocity;
- if (maxVelocity > 0.) {
- // limit velocity
- if (velocity > maxVelocity)
- velocity = maxVelocity;
- else if (velocity < -maxVelocity)
- velocity = -maxVelocity;
- }
- currentValue += velocity * 16.0 / 1000.0;
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- if (currentValue < 0.0)
- currentValue += modulus;
- }
- }
- if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
- velocity = 0.0;
- currentValue = srcVal;
- clock.stop();
- }
- lastTime = time - (elapsed - count * 16);
- } else {
- qreal moveBy = elapsed * velocityms;
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (diff > 0) {
- currentValue += moveBy;
- if (haveModulus)
- currentValue = fmod(currentValue, modulus);
- if (currentValue > to) {
- currentValue = to;
- clock.stop();
- }
- } else {
- currentValue -= moveBy;
- if (haveModulus && currentValue < 0.0)
- currentValue = fmod(currentValue, modulus) + modulus;
- if (currentValue < to) {
- currentValue = to;
- clock.stop();
- }
- }
- lastTime = time;
- }
- property.write(currentValue);
- emit q->valueChanged(currentValue);
- if (clock.state() != QAbstractAnimation::Running)
- emit q->syncChanged();
-}
-
-void QDeclarativeSpringFollowPrivate::updateMode()
-{
- if (spring == 0. && maxVelocity == 0.)
- mode = Track;
- else if (spring > 0.)
- mode = Spring;
- else
- mode = Velocity;
-}
-
-void QDeclarativeSpringFollowPrivate::start()
-{
- if (!enabled)
- return;
-
- Q_Q(QDeclarativeSpringFollow);
- if (mode == QDeclarativeSpringFollowPrivate::Track) {
- currentValue = to;
- property.write(currentValue);
- } else if (to != currentValue && clock.state() != QAbstractAnimation::Running) {
- lastTime = 0;
- currentValue = property.read().toReal();
- clock.start(); // infinity??
- emit q->syncChanged();
- }
-}
-
-void QDeclarativeSpringFollowPrivate::stop()
-{
- clock.stop();
-}
-
-/*!
- \qmlclass SpringFollow QDeclarativeSpringFollow
- \since 4.7
- \brief The SpringFollow element allows a property to track a value.
-
- In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200:
- \code
- Rectangle {
- id: rect1
- width: 20; height: 20
- color: "#00ff00"
- y: 200 // initial value
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation {
- to: 200
- easing.type: Easing.OutBounce
- easing.amplitude: 100
- duration: 2000
- }
- PauseAnimation { duration: 1000 }
- }
- }
- Rectangle {
- id: rect2
- x: rect1.width
- width: 20; height: 20
- color: "#ff0000"
- SpringFollow on y { to: rect1.y; velocity: 200 }
- }
- \endcode
-*/
-
-QDeclarativeSpringFollow::QDeclarativeSpringFollow(QObject *parent)
-: QObject(*(new QDeclarativeSpringFollowPrivate),parent)
-{
-}
-
-QDeclarativeSpringFollow::~QDeclarativeSpringFollow()
-{
-}
-
-void QDeclarativeSpringFollow::setTarget(const QDeclarativeProperty &property)
-{
- Q_D(QDeclarativeSpringFollow);
- d->property = property;
- d->currentValue = property.read().toReal();
-}
-
-qreal QDeclarativeSpringFollow::to() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->to;
-}
-
-/*!
- \qmlproperty real SpringFollow::to
- This property holds the target value which will be tracked.
-
- Bind to a property in order to track its changes.
-*/
-
-void QDeclarativeSpringFollow::setTo(qreal value)
-{
- Q_D(QDeclarativeSpringFollow);
- if (d->clock.state() == QAbstractAnimation::Running && d->to == value)
- return;
-
- d->to = value;
- d->start();
-}
-
-/*!
- \qmlproperty real SpringFollow::velocity
- This property holds the maximum velocity allowed when tracking the source.
-*/
-
-qreal QDeclarativeSpringFollow::velocity() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->maxVelocity;
-}
-
-void QDeclarativeSpringFollow::setVelocity(qreal velocity)
-{
- Q_D(QDeclarativeSpringFollow);
- d->maxVelocity = velocity;
- d->velocityms = velocity / 1000.0;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real SpringFollow::spring
- This property holds the spring constant
-
- The spring constant describes how strongly the target is pulled towards the
- source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
-
- When a spring constant is set and the velocity property is greater than 0,
- velocity limits the maximum speed.
-*/
-qreal QDeclarativeSpringFollow::spring() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->spring;
-}
-
-void QDeclarativeSpringFollow::setSpring(qreal spring)
-{
- Q_D(QDeclarativeSpringFollow);
- d->spring = spring;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real SpringFollow::damping
- This property holds the spring damping constant
-
- The damping constant describes how quickly a sprung follower comes to rest.
- Useful range is 0 - 1.0
-*/
-qreal QDeclarativeSpringFollow::damping() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->damping;
-}
-
-void QDeclarativeSpringFollow::setDamping(qreal damping)
-{
- Q_D(QDeclarativeSpringFollow);
- if (damping > 1.)
- damping = 1.;
-
- d->damping = damping;
-}
-
-
-/*!
- \qmlproperty real SpringFollow::epsilon
- This property holds the spring epsilon
-
- The epsilon is the rate and amount of change in the value which is close enough
- to 0 to be considered equal to zero. This will depend on the usage of the value.
- For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
-
- The default is 0.01. Tuning this value can provide small performance improvements.
-*/
-qreal QDeclarativeSpringFollow::epsilon() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->epsilon;
-}
-
-void QDeclarativeSpringFollow::setEpsilon(qreal epsilon)
-{
- Q_D(QDeclarativeSpringFollow);
- d->epsilon = epsilon;
-}
-
-/*!
- \qmlproperty real SpringFollow::modulus
- This property holds the modulus value.
-
- Setting a \a modulus forces the target value to "wrap around" at the modulus.
- For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
-*/
-qreal QDeclarativeSpringFollow::modulus() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->modulus;
-}
-
-void QDeclarativeSpringFollow::setModulus(qreal modulus)
-{
- Q_D(QDeclarativeSpringFollow);
- if (d->modulus != modulus) {
- d->haveModulus = modulus != 0.0;
- d->modulus = modulus;
- emit modulusChanged();
- }
-}
-
-/*!
- \qmlproperty real SpringFollow::mass
- This property holds the "mass" of the property being moved.
-
- mass is 1.0 by default. Setting a different mass changes the dynamics of
- a \l spring follow.
-*/
-qreal QDeclarativeSpringFollow::mass() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->mass;
-}
-
-void QDeclarativeSpringFollow::setMass(qreal mass)
-{
- Q_D(QDeclarativeSpringFollow);
- if (d->mass != mass && mass > 0.0) {
- d->useMass = mass != 1.0;
- d->mass = mass;
- emit massChanged();
- }
-}
-
-/*!
- \qmlproperty bool SpringFollow::enabled
- This property holds whether the target will track the source.
-
- The default value of this property is 'true'.
-*/
-bool QDeclarativeSpringFollow::enabled() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->enabled;
-}
-
-void QDeclarativeSpringFollow::setEnabled(bool enabled)
-{
- Q_D(QDeclarativeSpringFollow);
- d->enabled = enabled;
- if (enabled)
- d->start();
- else
- d->stop();
-}
-
-/*!
- \qmlproperty bool SpringFollow::inSync
- This property is true when target is equal to the source; otherwise
- false. If inSync is true the target is not being animated.
-
- If \l enabled is false then inSync will also be false.
-*/
-bool QDeclarativeSpringFollow::inSync() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->enabled && d->clock.state() != QAbstractAnimation::Running;
-}
-
-/*!
- \qmlproperty real SpringFollow::value
- The current value.
-*/
-qreal QDeclarativeSpringFollow::value() const
-{
- Q_D(const QDeclarativeSpringFollow);
- return d->currentValue;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativespringfollow_p.h b/src/declarative/util/qdeclarativespringfollow_p.h
deleted file mode 100644
index b6277c3b8f..0000000000
--- a/src/declarative/util/qdeclarativespringfollow_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHFOLLOW_H
-#define QDECLARATIVESMOOTHFOLLOW_H
-
-#include <qdeclarativepropertyvaluesource.h>
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeSpringFollowPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeSpringFollow : public QObject,
- public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeSpringFollow)
- Q_INTERFACES(QDeclarativePropertyValueSource)
-
- Q_PROPERTY(qreal to READ to WRITE setTo)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal spring READ spring WRITE setSpring)
- Q_PROPERTY(qreal damping READ damping WRITE setDamping)
- Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(qreal value READ value NOTIFY valueChanged)
- Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
- Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
- Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
-
-public:
- QDeclarativeSpringFollow(QObject *parent=0);
- ~QDeclarativeSpringFollow();
-
- virtual void setTarget(const QDeclarativeProperty &);
-
- qreal to() const;
- void setTo(qreal value);
-
- qreal velocity() const;
- void setVelocity(qreal velocity);
-
- qreal spring() const;
- void setSpring(qreal spring);
-
- qreal damping() const;
- void setDamping(qreal damping);
-
- qreal epsilon() const;
- void setEpsilon(qreal epsilon);
-
- qreal mass() const;
- void setMass(qreal modulus);
-
- qreal modulus() const;
- void setModulus(qreal modulus);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
- bool inSync() const;
-
- qreal value() const;
-
-Q_SIGNALS:
- void valueChanged(qreal);
- void modulusChanged();
- void massChanged();
- void syncChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSpringFollow)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESMOOTHFOLLOW_H
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 74fdac65eb..c5bfebdf7d 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -46,7 +46,6 @@
#include "private/qdeclarativebind_p.h"
#include "private/qdeclarativeconnections_p.h"
#include "private/qdeclarativesmoothedanimation_p.h"
-#include "private/qdeclarativesmoothedfollow_p.h"
#include "private/qdeclarativefontloader_p.h"
#include "private/qdeclarativelistaccessor_p.h"
#include "private/qdeclarativelistmodel_p.h"
@@ -56,7 +55,6 @@
#include "private/qdeclarativepixmapcache_p.h"
#include "private/qdeclarativepropertychanges_p.h"
#include "qdeclarativepropertymap.h"
-#include "private/qdeclarativespringfollow_p.h"
#include "private/qdeclarativespringanimation_p.h"
#include "private/qdeclarativestategroup_p.h"
#include "private/qdeclarativestateoperations_p.h"
@@ -84,7 +82,6 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeColorAnimation>("Qt",4,7,"ColorAnimation");
qmlRegisterType<QDeclarativeConnections>("Qt",4,7,"Connections");
qmlRegisterType<QDeclarativeSmoothedAnimation>("Qt",4,7,"SmoothedAnimation");
- qmlRegisterType<QDeclarativeSmoothedFollow>("Qt",4,7,"SmoothedFollow");
qmlRegisterType<QDeclarativeFontLoader>("Qt",4,7,"FontLoader");
qmlRegisterType<QDeclarativeListElement>("Qt",4,7,"ListElement");
qmlRegisterType<QDeclarativeNumberAnimation>("Qt",4,7,"NumberAnimation");
@@ -98,7 +95,6 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeRotationAnimation>("Qt",4,7,"RotationAnimation");
qmlRegisterType<QDeclarativeScriptAction>("Qt",4,7,"ScriptAction");
qmlRegisterType<QDeclarativeSequentialAnimation>("Qt",4,7,"SequentialAnimation");
- qmlRegisterType<QDeclarativeSpringFollow>("Qt",4,7,"SpringFollow");
qmlRegisterType<QDeclarativeSpringAnimation>("Qt",4,7,"SpringAnimation");
qmlRegisterType<QDeclarativeStateChangeScript>("Qt",4,7,"StateChangeScript");
qmlRegisterType<QDeclarativeStateGroup>("Qt",4,7,"StateGroup");
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 0cbcbd7589..fd5714458a 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -7,10 +7,8 @@ SOURCES += \
$$PWD/qdeclarativepackage.cpp \
$$PWD/qdeclarativeanimation.cpp \
$$PWD/qdeclarativesystempalette.cpp \
- $$PWD/qdeclarativespringfollow.cpp \
$$PWD/qdeclarativespringanimation.cpp \
$$PWD/qdeclarativesmoothedanimation.cpp \
- $$PWD/qdeclarativesmoothedfollow.cpp \
$$PWD/qdeclarativestate.cpp\
$$PWD/qdeclarativetransitionmanager.cpp \
$$PWD/qdeclarativestateoperations.cpp \
@@ -39,10 +37,8 @@ HEADERS += \
$$PWD/qdeclarativeanimation_p.h \
$$PWD/qdeclarativeanimation_p_p.h \
$$PWD/qdeclarativesystempalette_p.h \
- $$PWD/qdeclarativespringfollow_p.h \
$$PWD/qdeclarativespringanimation_p.h \
$$PWD/qdeclarativesmoothedanimation_p.h \
- $$PWD/qdeclarativesmoothedfollow_p.h \
$$PWD/qdeclarativesmoothedanimation_p_p.h \
$$PWD/qdeclarativestate_p.h\
$$PWD/qdeclarativestateoperations_p.h \
diff --git a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml
new file mode 100644
index 0000000000..07587bd851
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml
@@ -0,0 +1,4 @@
+import Qt 4.7
+
+SpringAnimation {
+}
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml
index 0fa4aa9cf0..562f44af14 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
+++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml
@@ -1,8 +1,9 @@
import Qt 4.7
-SpringFollow {
+SpringAnimation {
to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
- mass: 2.0; enabled: false
+ mass: 2.0;
+ running: true;
}
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml
index 31a740affb..9f70bf48de 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
+++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml
@@ -1,8 +1,8 @@
import Qt 4.7
-SpringFollow {
+SpringAnimation {
to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
- mass: 2.0; enabled: true
+ mass: 2.0; running: false
}
diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro
index 1c17ba07f9..213b262fce 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
+++ b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro
@@ -2,7 +2,7 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativespringfollow.cpp
+SOURCES += tst_qdeclarativespringanimation.cpp
symbian: {
importFiles.sources = data
diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
index e0e2892ab0..4b17a47960 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
+++ b/tests/auto/declarative/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
@@ -41,7 +41,7 @@
#include <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativespringfollow_p.h>
+#include <private/qdeclarativespringanimation_p.h>
#include <private/qdeclarativevaluetype_p.h>
#include "../../../shared/util.h"
@@ -50,11 +50,11 @@
#define SRCDIR "."
#endif
-class tst_qdeclarativespringfollow : public QObject
+class tst_qdeclarativespringanimation : public QObject
{
Q_OBJECT
public:
- tst_qdeclarativespringfollow();
+ tst_qdeclarativespringanimation();
private slots:
void defaultValues();
@@ -65,15 +65,15 @@ private:
QDeclarativeEngine engine;
};
-tst_qdeclarativespringfollow::tst_qdeclarativespringfollow()
+tst_qdeclarativespringanimation::tst_qdeclarativespringanimation()
{
}
-void tst_qdeclarativespringfollow::defaultValues()
+void tst_qdeclarativespringanimation::defaultValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml"));
- QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation1.qml"));
+ QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
@@ -83,19 +83,17 @@ void tst_qdeclarativespringfollow::defaultValues()
QCOMPARE(obj->damping(), 0.);
QCOMPARE(obj->epsilon(), 0.01);
QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->value(), 0.);
QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->inSync(), true);
+ QCOMPARE(obj->isRunning(), false);
delete obj;
}
-void tst_qdeclarativespringfollow::values()
+void tst_qdeclarativespringanimation::values()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml"));
- QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation2.qml"));
+ QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
@@ -106,19 +104,18 @@ void tst_qdeclarativespringfollow::values()
QCOMPARE(obj->epsilon(), 0.25);
QCOMPARE(obj->modulus(), 360.0);
QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->isRunning(), true);
- QTRY_COMPARE(obj->value(), 1.44);
- QTRY_COMPARE(obj->inSync(), true);
+ QTRY_COMPARE(obj->isRunning(), false);
delete obj;
}
-void tst_qdeclarativespringfollow::disabled()
+void tst_qdeclarativespringanimation::disabled()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml"));
- QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation3.qml"));
+ QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
@@ -129,14 +126,11 @@ void tst_qdeclarativespringfollow::disabled()
QCOMPARE(obj->epsilon(), 0.25);
QCOMPARE(obj->modulus(), 360.0);
QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->enabled(), false);
-
- QCOMPARE(obj->value(), 0.0);
- QCOMPARE(obj->inSync(), false);
+ QCOMPARE(obj->isRunning(), false);
delete obj;
}
-QTEST_MAIN(tst_qdeclarativespringfollow)
+QTEST_MAIN(tst_qdeclarativespringanimation)
-#include "tst_qdeclarativespringfollow.moc"
+#include "tst_qdeclarativespringanimation.moc"
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
deleted file mode 100644
index 8528cfa840..0000000000
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import Qt 4.7
-
-SpringFollow {
-}