From 735b588e64d29c5336402c8e1d43f77e8b2cbe31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 6 Dec 2017 14:39:35 +0100 Subject: 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 --- tests/manual/pointer/flingAnimation.qml | 60 +++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'tests/manual') 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 + } + } } } } -- cgit v1.2.3