summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2015-07-24 10:53:32 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-08 10:36:12 +0000
commitf11c9a24e685178a0a1a2db453e0e43b7ca3a5f2 (patch)
tree677aa9d7264248fc2539734352cf456f8980b13c /tests/manual
parent6de499a7d042194e98fcb26731d99cd5d8eefadb (diff)
add MomentumAnimation as a manual test / experiment
It could be exposed as a new type of animation, but for now it's just an experiment. Change-Id: Ic900752a90ccae93270e27399f370f5d47495f74 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/pointer/content/MomentumAnimation.qml71
-rw-r--r--tests/manual/pointer/flingAnimation.qml84
-rw-r--r--tests/manual/pointer/main.qml1
-rw-r--r--tests/manual/pointer/qml.qrc2
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/manual/pointer/content/MomentumAnimation.qml b/tests/manual/pointer/content/MomentumAnimation.qml
new file mode 100644
index 0000000000..abd9ac9269
--- /dev/null
+++ b/tests/manual/pointer/content/MomentumAnimation.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the manual tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+
+ParallelAnimation {
+ id: root
+ property Item target: null
+ property int duration: 500
+ property vector2d velocity: Qt.vector2d(0,0)
+
+ function restart(vel) {
+ stop()
+ velocity = vel
+ start()
+ }
+
+ NumberAnimation {
+ id: xAnim
+ target: root.target
+ property: "x"
+ to: target.x + velocity.x / duration * 100000
+ duration: root.duration
+ easing.type: Easing.OutQuad
+ }
+ NumberAnimation {
+ id: yAnim
+ target: root.target
+ property: "y"
+ to: target.y + velocity.y / duration * 100000
+ duration: root.duration
+ easing.type: Easing.OutQuad
+ }
+}
diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml
new file mode 100644
index 0000000000..11b97dbb31
--- /dev/null
+++ b/tests/manual/pointer/flingAnimation.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the manual tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import Qt.labs.handlers 1.0
+import "content"
+
+Rectangle {
+ id: root
+ width: 640
+ height: 480
+ color: "black"
+
+ Repeater {
+ model: 2
+
+ Image {
+ id: ball
+ objectName: "ball" + index
+ source: "resources/redball.png"
+ width: 80; height: 80; x: 200 + index * 200; y: 200
+
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ text: anim.velocity.x.toFixed(2) + "," + anim.velocity.y.toFixed(2)
+ }
+
+ MomentumAnimation { id: anim; target: ball }
+
+ DragHandler {
+ id: dragHandler
+ onActiveChanged: {
+ if (!active)
+ anim.restart(velocity)
+ }
+ }
+ Rectangle {
+ visible: dragHandler.active
+ anchors.fill: parent
+ anchors.margins: -5
+ radius: width / 2
+ opacity: 0.25
+ }
+ }
+ }
+}
diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml
index 62202c39b1..3289df161c 100644
--- a/tests/manual/pointer/main.qml
+++ b/tests/manual/pointer/main.qml
@@ -56,6 +56,7 @@ Window {
addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml"))
addExample("map", "scale and pan", Qt.resolvedUrl("map.qml"))
addExample("custom map", "scale and pan", Qt.resolvedUrl("map2.qml"))
+ addExample("fling animation", "DragHandler: after dragging, use an animation to simulate momentum", Qt.resolvedUrl("flingAnimation.qml"))
}
}
}
diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc
index adf255ea1f..9463ae4c84 100644
--- a/tests/manual/pointer/qml.qrc
+++ b/tests/manual/pointer/qml.qrc
@@ -1,11 +1,13 @@
<RCC>
<qresource prefix="/">
+ <file>flingAnimation.qml</file>
<file>main.qml</file>
<file>joystick.qml</file>
<file>map.qml</file>
<file>mixer.qml</file>
<file>pinchHandler.qml</file>
<file>singlePointHandlerProperties.qml</file>
+ <file>content/MomentumAnimation.qml</file>
<file>content/Slider.qml</file>
<file>resources/arrowhead.png</file>
<file>resources/grabbing-location.svg</file>