aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-12-06 14:39:35 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-12-13 06:53:21 +0000
commit735b588e64d29c5336402c8e1d43f77e8b2cbe31 (patch)
tree0c63ae29e37bd68603cb6cafb90ca98a21de0adc /tests/manual
parent7b0a9e6a01b49f911ab7e98873731050380e9242 (diff)
flingAnimation manual test: add velocity vectors; install a ball return
Just like the one at the bowling alley... no actually the problem was that it's easy to fling the balls right out of the window, and we don't have collision detection so we can't make them bounce. Now they simply come back "home" after a delay. Change-Id: I297828321fce975b929e449e56799fd9280b682d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/pointer/flingAnimation.qml60
1 files changed, 57 insertions, 3 deletions
diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml
index 851ffd1083..3b0d359530 100644
--- a/tests/manual/pointer/flingAnimation.qml
+++ b/tests/manual/pointer/flingAnimation.qml
@@ -43,15 +43,48 @@ Rectangle {
id: ball
objectName: "ball" + index
source: "resources/redball.png"
- width: 80; height: 80; x: 200 + index * 200; y: 200
+ property real homeX: 200 + index * 200
+ property real homeY: 200
+ width: 80; height: 80; x: homeX; y: 200
Text {
anchors.centerIn: parent
color: "white"
- text: anim.velocity.x.toFixed(2) + "," + anim.velocity.y.toFixed(2)
+ text: momentum.velocity.x.toFixed(2) + "," + momentum.velocity.y.toFixed(2)
}
- MomentumAnimation { id: anim; target: ball }
+ SequentialAnimation {
+ id: anim
+
+ function restart(vel) {
+ stop()
+ momentum.velocity = vel
+ start()
+ }
+
+ MomentumAnimation { id: momentum; target: ball }
+
+ PauseAnimation { duration: 500 }
+
+ ParallelAnimation {
+ id: ballReturn
+ NumberAnimation {
+ target: ball
+ property: "x"
+ to: homeX
+ duration: 1000
+ easing.period: 50
+ easing.type: Easing.OutElastic
+ }
+ NumberAnimation {
+ target: ball
+ property: "y"
+ to: homeY
+ duration: 1000
+ easing.type: Easing.OutElastic
+ }
+ }
+ }
DragHandler {
id: dragHandler
@@ -68,6 +101,27 @@ Rectangle {
radius: width / 2
opacity: 0.25
}
+
+ Rectangle {
+ visible: width > 0
+ width: dragHandler.point.velocity.length() * 100
+ height: 2
+ x: ball.width / 2
+ y: ball.height / 2
+ z: -1
+ rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI
+ transformOrigin: Item.BottomLeft
+ antialiasing: true
+
+ Image {
+ source: "resources/arrowhead.png"
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ width: 16
+ height: 12
+ antialiasing: true
+ }
+ }
}
}
}