From 524686cf13aa5647eae4ebb630d58396862027e5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 3 Aug 2016 15:44:19 +0200 Subject: add PointerHandler manual test project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QML manual tests will be added to test specific handlers later. Change-Id: I691cff23f97fc79020d1090448e70a78de3b4be9 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.cpp | 51 ++++++++++++++++++++++++++++++++++++ tests/manual/pointer/main.qml | 56 ++++++++++++++++++++++++++++++++++++++++ tests/manual/pointer/pointer.pro | 7 +++++ tests/manual/pointer/qml.qrc | 5 ++++ 4 files changed, 119 insertions(+) create mode 100644 tests/manual/pointer/main.cpp create mode 100644 tests/manual/pointer/main.qml create mode 100644 tests/manual/pointer/pointer.pro create mode 100644 tests/manual/pointer/qml.qrc (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.cpp b/tests/manual/pointer/main.cpp new file mode 100644 index 0000000000..a4e1060cf5 --- /dev/null +++ b/tests/manual/pointer/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://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$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml new file mode 100644 index 0000000000..aad848c8f0 --- /dev/null +++ b/tests/manual/pointer/main.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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 QtQuick.Window 2.2 +import "qrc:/quick/shared/" as Examples + +Window { + width: 800 + height: 600 + visible: true + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { +// addExample("pointer", "PointerHandler: demonstrate the basics", Qt.resolvedUrl("pointerHandler.qml")) + } + } +} diff --git a/tests/manual/pointer/pointer.pro b/tests/manual/pointer/pointer.pro new file mode 100644 index 0000000000..3705d41df0 --- /dev/null +++ b/tests/manual/pointer/pointer.pro @@ -0,0 +1,7 @@ +TEMPLATE = app + +QT += qml quick + +SOURCES += main.cpp + +RESOURCES += qml.qrc ../../../examples/quick/shared/quick_shared.qrc diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc new file mode 100644 index 0000000000..5f6483ac33 --- /dev/null +++ b/tests/manual/pointer/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + -- cgit v1.2.3 From 124181973f586a67990c9a68e25a3642623b998a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Jul 2016 14:22:15 +0200 Subject: Introduce DragHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A handler for dragging Items around by touch or mouse. Change-Id: Id83fea568095eb6374f3f1abc6f550d81f3731df Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/Slider.qml | 117 ++++++++++++++++++++++++++ tests/manual/pointer/joystick.qml | 75 +++++++++++++++++ tests/manual/pointer/main.qml | 3 +- tests/manual/pointer/mixer.qml | 72 ++++++++++++++++ tests/manual/pointer/qml.qrc | 6 ++ tests/manual/pointer/resources/mixer-knob.png | Bin 0 -> 8555 bytes tests/manual/pointer/resources/redball.png | Bin 0 -> 10002 bytes 7 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 tests/manual/pointer/content/Slider.qml create mode 100644 tests/manual/pointer/joystick.qml create mode 100644 tests/manual/pointer/mixer.qml create mode 100644 tests/manual/pointer/resources/mixer-knob.png create mode 100644 tests/manual/pointer/resources/redball.png (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml new file mode 100644 index 0000000000..363f6911d4 --- /dev/null +++ b/tests/manual/pointer/content/Slider.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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 + +Item { + id: root + property int value: 50 + property int maximumValue: 99 + property alias label: label.text + + Rectangle { + id: slot + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 10 + anchors.topMargin: 30 + anchors.bottomMargin: 30 + anchors.horizontalCenter: parent.horizontalCenter + width: 10 + color: "black" + radius: width / 2 + smooth: true + } + + Rectangle { + // RectangularGlow is better, but that's a different module + id: glow + anchors.fill: knob + anchors.margins: -5 + anchors.leftMargin: -2 + anchors.horizontalCenterOffset: 1 + radius: 5 + color: "#4400FFFF" + visible: dragHandler.dragging + } + Image { + id: knob + source: "../resources/mixer-knob.png" + antialiasing: true + x: slot.x - width / 2 + slot.width / 2 + height: root.width / 2 + width: implicitWidth / implicitHeight * height + property bool programmatic: false + property real multiplier: root.maximumValue / (dragHandler.yAxis.maximum - dragHandler.yAxis.minimum) + onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier + transformOrigin: Item.Center + function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } + DragHandler { + id: dragHandler + xAxis.enabled: false + yAxis.minimum: slot.y + yAxis.maximum: slot.height + slot.y - knob.height + } + } + + Text { + font.pointSize: 16 + color: "red" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: root.value + } + + Text { + id: label + font.pointSize: 12 + color: "red" + anchors.top: parent.top + anchors.topMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + } + + onHeightChanged: { + knob.programmatic = true + knob.setValue(root.value) + knob.programmatic = false + } +} diff --git a/tests/manual/pointer/joystick.qml b/tests/manual/pointer/joystick.qml new file mode 100644 index 0000000000..7959eaea42 --- /dev/null +++ b/tests/manual/pointer/joystick.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 + +Rectangle { + width: 480 + height: 480 + color: "black" + + Image { + id: knob + source: "resources/redball.png" + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + DragHandler { + id: dragHandler + } + states: [ + State { + when: dragHandler.dragging + AnchorChanges { + target: knob + anchors.horizontalCenter: undefined + anchors.verticalCenter: undefined + } + } + ] + transitions: [ + Transition { + AnchorAnimation { easing.type: Easing.OutElastic } + } + ] + } +} diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index aad848c8f0..efe603c57f 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -50,7 +50,8 @@ Window { id: ll anchors.fill: parent Component.onCompleted: { -// addExample("pointer", "PointerHandler: demonstrate the basics", Qt.resolvedUrl("pointerHandler.qml")) + addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml")) + addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) } } } diff --git a/tests/manual/pointer/mixer.qml b/tests/manual/pointer/mixer.qml new file mode 100644 index 0000000000..84ad975340 --- /dev/null +++ b/tests/manual/pointer/mixer.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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: 1280 + height: 960 + objectName: "root" + color: "#222222" + + ListView { + id: list + objectName: "listView" + anchors.fill: parent + anchors.margins: 10 + orientation: Qt.Horizontal + + model: 20 + + delegate: Item { + objectName: "delegateItem" + index + width: 154 + height: list.height + + Slider { + anchors.fill: parent + label: "Channel " + (index + 1) + } + } + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 5f6483ac33..b802a73f08 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -1,5 +1,11 @@ main.qml + joystick.qml + main.qml + mixer.qml + content/Slider.qml + resources/mixer-knob.png + resources/redball.png diff --git a/tests/manual/pointer/resources/mixer-knob.png b/tests/manual/pointer/resources/mixer-knob.png new file mode 100644 index 0000000000..02cc9fc72b Binary files /dev/null and b/tests/manual/pointer/resources/mixer-knob.png differ diff --git a/tests/manual/pointer/resources/redball.png b/tests/manual/pointer/resources/redball.png new file mode 100644 index 0000000000..68d2e1d638 Binary files /dev/null and b/tests/manual/pointer/resources/redball.png differ -- cgit v1.2.3 From 678d3de4b53f22ead68a0874df2892137ad3b7f7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 11 Aug 2015 18:14:02 +0200 Subject: Introduce PinchHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to PinchArea but with improvements: - Allows rotating and scaling about an arbitrary point rather than the center - It's possible to require more than 2 fingers. E.g. maybe you use 3 fingers to manage a window, 2 fingers to manipulate content inside. This could be achieved with two independent PinchHandlers. Change-Id: Ifd40cfee115d7bc298378b26a58318bea40a8230 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/pinchHandler.qml | 93 +++++++++++++++++++++++++++++++++++ tests/manual/pointer/qml.qrc | 2 +- 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/manual/pointer/pinchHandler.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index efe603c57f..45a339b302 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -52,6 +52,7 @@ Window { Component.onCompleted: { addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml")) addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) + addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml")) } } } diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml new file mode 100644 index 0000000000..e4482a249d --- /dev/null +++ b/tests/manual/pointer/pinchHandler.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 + +Rectangle { + id: root + width: 1024; height: 600 + color: "black" + + Rectangle { + width: 400 + height: 300 + color: "lightsteelblue" + antialiasing: true + + Text { + anchors.centerIn: parent + text: "Pinch with 2 fingers to scale & rotate\nDrag with 1 finger\ncurrent rotation " + pinch2.rotation.toFixed(1) + } + + DragHandler { objectName: "DragHandler" } + + PinchHandler { + id: pinch2 + objectName: "2-finger pinch" + minimumRotation: -45 + maximumRotation: 45 + minimumScale: 0.1 + maximumScale: 10 + pointDistanceThreshold: 150 + } + } + + Rectangle { + x: 512 + width: 400 + height: 300 + color: "wheat" + antialiasing: true + + Text { + anchors.centerIn: parent + text: "Pinch with 3 fingers to scale & rotate\ncurrent rotation " + pinch3.rotation.toFixed(1) + } + + PinchHandler { + id: pinch3 + objectName: "3-finger pinch" + requiredPointCount: 3 + minimumScale: 0.1 + maximumScale: 10 + } + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index b802a73f08..dac6b08b12 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -2,8 +2,8 @@ main.qml joystick.qml - main.qml mixer.qml + pinchHandler.qml content/Slider.qml resources/mixer-knob.png resources/redball.png -- cgit v1.2.3 From 65c3548c433bf5c9c5e2d962c8ec6af3b65f2bb8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 29 Jun 2016 11:37:19 +0200 Subject: add a map example as a manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The public-domain map is adapted from https://openclipart.org/detail/67039/ Change-Id: Ia3da049174a38a6cc9e9632eda4f4553ad16d3bf Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/map.qml | 74 ++++++++++++++++++++++++++++++++ tests/manual/pointer/qml.qrc | 2 + tests/manual/pointer/resources/map.svgz | Bin 0 -> 27956 bytes 4 files changed, 77 insertions(+) create mode 100644 tests/manual/pointer/map.qml create mode 100644 tests/manual/pointer/resources/map.svgz (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index 45a339b302..7ba0d9a466 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -53,6 +53,7 @@ Window { addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml")) addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml")) + addExample("map", "scale and pan", Qt.resolvedUrl("map.qml")) } } } diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml new file mode 100644 index 0000000000..e1ca889064 --- /dev/null +++ b/tests/manual/pointer/map.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 + +Item { + width: 640 + height: 480 + + Rectangle { + id: map + color: "aqua" + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: image.implicitWidth + height: image.implicitHeight + + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: "resources/map.svgz" + } + } + + PinchHandler { + id: pinch + target: map + minimumScale: 0.1 + maximumScale: 10 + } + + DragHandler { + target: map + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index dac6b08b12..3d7de4b728 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -2,9 +2,11 @@ main.qml joystick.qml + map.qml mixer.qml pinchHandler.qml content/Slider.qml + resources/map.svgz resources/mixer-knob.png resources/redball.png diff --git a/tests/manual/pointer/resources/map.svgz b/tests/manual/pointer/resources/map.svgz new file mode 100644 index 0000000000..64d509c106 Binary files /dev/null and b/tests/manual/pointer/resources/map.svgz differ -- cgit v1.2.3 From b8106804c87f70c3be034dc3e191966293a8b877 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 2 Sep 2016 12:58:43 +0200 Subject: Move device id to be in bits 24-31 of the point id This allows us for lossless conversion between QTouchEvent::TouchPoint id and QQuickEventPoint::pointId (both ways). Change-Id: I2087847a579dd8bc5b526515ad07b55c9ae8aa42 Reviewed-by: Shawn Rutledge --- tests/manual/touch/mpta-crosshairs.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/touch/mpta-crosshairs.qml b/tests/manual/touch/mpta-crosshairs.qml index 8b71e4fdc3..901b3e8bac 100644 --- a/tests/manual/touch/mpta-crosshairs.qml +++ b/tests/manual/touch/mpta-crosshairs.qml @@ -85,11 +85,22 @@ Rectangle { } Rectangle { color: touchPoint.color - width: 50 * touchPoint.pressure + width: Math.max(2, 50 * touchPoint.pressure) height: width radius: width / 2 x: touchPoint.x - width / 2 y: touchPoint.y - width / 2 + Rectangle { + y: -40 + anchors.horizontalCenter: parent.horizontalCenter + color: "#c0c0c0" + implicitWidth: label.implicitWidth + implicitHeight: label.implicitHeight + Text { + id: label + text: 'id: ' + touchPoint.pointId.toString(16) + '\npos: (' + touchPoint.x.toFixed(2) + ', ' + touchPoint.y.toFixed(2) + ')' + } + } } Rectangle { id: velocityVector -- cgit v1.2.3 From c364b935f06256ec7adfaf486ef35b3996152804 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 2 Sep 2016 17:07:57 +0200 Subject: Fix rotation in PinchHandler If we want to allow rotation with more than 2 fingers, its not straightforward to calculate the rotation angle, because we cannot anymore calculate the angle between the two touchpoints. The approach chosen was to calculate the angle between the centroid and the touchpoints, and take the average between the angles. Then, for the next event we calculated the new average of the angles. However, this is not really reliable in some scenarios, suppose we have these three angles: 0 120 240, avg = 360/3 = 120 next, touch points rotate clockwise with 2 degrees, and we get these angles: 358 118 238, avg = 714/3 = 238 So, just by rotating all fingers by 2 degrees, we got a jump by 118 degrees "in average". Instead we need to track the angles of *all* touch points, and when the next touch event is received we calculate how much the angle has changed per touch point. We then take the average of those angles as the effective "rotation" of the PinchHandler Change-Id: I2bfdf80b886751177efe81bcc7b698af0d2938e3 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/pinchHandler.qml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index e4482a249d..d163343a3e 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -54,18 +54,21 @@ Rectangle { Text { anchors.centerIn: parent - text: "Pinch with 2 fingers to scale & rotate\nDrag with 1 finger\ncurrent rotation " + pinch2.rotation.toFixed(1) + text: "Pinch with 2 fingers to scale, rotate and translate" + + "\ncurrent rotation: " + pinch2.rotation.toFixed(1) + + "\nscale: " + pinch2.scale.toFixed(1) + + "\ntranslation: " + pinch2.translation } - DragHandler { objectName: "DragHandler" } - PinchHandler { id: pinch2 objectName: "2-finger pinch" minimumRotation: -45 maximumRotation: 45 - minimumScale: 0.1 - maximumScale: 10 + minimumScale: 0.5 + maximumScale: 3 + minimumX: 0 + maximumX: 600 pointDistanceThreshold: 150 } } @@ -79,8 +82,10 @@ Rectangle { Text { anchors.centerIn: parent - text: "Pinch with 3 fingers to scale & rotate\ncurrent rotation " + pinch3.rotation.toFixed(1) + text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" + + "\ncurrent rotation " + pinch3.rotation.toFixed(1) } + DragHandler { objectName: "DragHandler" } PinchHandler { id: pinch3 @@ -90,4 +95,17 @@ Rectangle { maximumScale: 10 } } + + Rectangle { + id: centroidIndicator + property QtObject pincher: pinch2.active ? pinch2 : pinch3 + x: pincher.centroid.x + y: pincher.centroid.y + z: 1 + visible: pincher.active + radius: width / 2 + width: 10 + height: width + color: "red" + } } -- cgit v1.2.3 From 542eda976c2767ed6c1eecb4dbcbf838e0ca5a19 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Tue, 18 Oct 2016 11:49:13 +0200 Subject: Fixed some problems with the centroid in PinchHandler The centroid was not always mapped to the correct coordinate system In addition, the return value of startingCentroid() was not always desirable, because its implementation calls sceneGrabPos(). We therefore had to get the starting centroid by querying touchPointCentroid() whenever the handler became active. Change-Id: I69de6b832b9bda208fda4eb90a8a95cc975405c2 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/pinchHandler.qml | 96 +++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 44 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index d163343a3e..3ab196a10a 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -42,60 +42,68 @@ import QtQuick 2.8 import Qt.labs.handlers 1.0 Rectangle { - id: root width: 1024; height: 600 - color: "black" - + color: "#eee" Rectangle { - width: 400 - height: 300 - color: "lightsteelblue" - antialiasing: true + id: root + color: "black" + width: 900 + height: 600 + x: 100 - Text { - anchors.centerIn: parent - text: "Pinch with 2 fingers to scale, rotate and translate" - + "\ncurrent rotation: " + pinch2.rotation.toFixed(1) - + "\nscale: " + pinch2.scale.toFixed(1) - + "\ntranslation: " + pinch2.translation - } + Rectangle { + width: 400 + height: 300 + color: "lightsteelblue" + antialiasing: true - PinchHandler { - id: pinch2 - objectName: "2-finger pinch" - minimumRotation: -45 - maximumRotation: 45 - minimumScale: 0.5 - maximumScale: 3 - minimumX: 0 - maximumX: 600 - pointDistanceThreshold: 150 + Text { + anchors.centerIn: parent + text: "Pinch with 2 fingers to scale, rotate and translate" + + "\ncurrent rotation: " + pinch2.rotation.toFixed(1) + + "\nscale: " + pinch2.scale.toFixed(1) + + "\ntranslation: " + pinch2.translation + } + + PinchHandler { + id: pinch2 + objectName: "2-finger pinch" + minimumRotation: -45 + maximumRotation: 45 + minimumScale: 0.5 + maximumScale: 3 + minimumX: 0 + maximumX: 600 + pointDistanceThreshold: 150 + } } - } - Rectangle { - x: 512 - width: 400 - height: 300 - color: "wheat" - antialiasing: true + Rectangle { + x: 500 + width: 400 + height: 300 + color: "wheat" + antialiasing: true - Text { - anchors.centerIn: parent - text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" - + "\ncurrent rotation " + pinch3.rotation.toFixed(1) - } - DragHandler { objectName: "DragHandler" } + Text { + anchors.centerIn: parent + text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" + + "\ncurrent rotation " + pinch3.rotation.toFixed(1) + + "\nscale: " + pinch3.scale.toFixed(1) + + "\ntranslation: " + pinch3.translation + } + DragHandler { objectName: "DragHandler" } - PinchHandler { - id: pinch3 - objectName: "3-finger pinch" - requiredPointCount: 3 - minimumScale: 0.1 - maximumScale: 10 + PinchHandler { + id: pinch3 + objectName: "3-finger pinch" + requiredPointCount: 3 + minimumScale: 0.1 + maximumScale: 10 + } } - } + } Rectangle { id: centroidIndicator property QtObject pincher: pinch2.active ? pinch2 : pinch3 -- cgit v1.2.3 From 3eeffae835b3474c8a3ca62125cb8ec24acdaa84 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Tue, 13 Dec 2016 11:38:23 +0100 Subject: Let pinchhandler operate on QQuickItem properties This requires coordinate system mapping that varies with the transformOrigin. The properties exposed from PinchHandler (rotation, scale and translation) are currently relative to the point when the pinch became active. (Therefore, rotation, will reset back to 0 when a new pinch is activated). Its still unclear how the properties that limits the transform should influence. With this patch, they are like this: * {min,max}imumRotation applies to the actual rotation of the item. * {min,max}imumScale applies to the actual scale of the item. * {min,max}imum{X,Y} applies to the actual position of the item. (This has some unfortunate side-effects when the item is scaled or rotated, since the items actual position will change as it rotates) In addition, the behavior described above means that the limits won't have any effect if there is no target item. Change-Id: I279fb03667cd75324e8337039ae2594658265d13 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/pinchHandler.qml | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index 3ab196a10a..f317f361e2 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -44,25 +44,38 @@ import Qt.labs.handlers 1.0 Rectangle { width: 1024; height: 600 color: "#eee" + + function getTransformationDetails(item, pinchhandler) { + return "\n\npinch.scale:" + pinchhandler.scale.toFixed(2) + + "\npinch.rotation:" + pinchhandler.rotation.toFixed(2) + + "\npinch.translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + + "\nrect.scale: " + item.scale.toFixed(2) + + "\nrect.rotation: " + item.rotation.toFixed(2) + + "\nrect.position: " + "(" + item.x.toFixed(2) + "," + item.y.toFixed(2) + ")" + } + Rectangle { - id: root - color: "black" - width: 900 - height: 600 - x: 100 + // Purpose of this item is just to make sure the rectangles are transformed into + // a coordinate system that is different from the scene coordinate system. + anchors.fill: parent + anchors.margins: 50 + color: "#ffe0e0e0" Rectangle { + id: rect2 width: 400 height: 300 color: "lightsteelblue" antialiasing: true + x: 100 + y: 200 + rotation: 30 + transformOrigin: Item.TopRight Text { anchors.centerIn: parent text: "Pinch with 2 fingers to scale, rotate and translate" - + "\ncurrent rotation: " + pinch2.rotation.toFixed(1) - + "\nscale: " + pinch2.scale.toFixed(1) - + "\ntranslation: " + pinch2.translation + + getTransformationDetails(rect2, pinch2) } PinchHandler { @@ -74,11 +87,12 @@ Rectangle { maximumScale: 3 minimumX: 0 maximumX: 600 - pointDistanceThreshold: 150 + pointDistanceThreshold: 0 } } Rectangle { + id: rect3 x: 500 width: 400 height: 300 @@ -88,9 +102,7 @@ Rectangle { Text { anchors.centerIn: parent text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" - + "\ncurrent rotation " + pinch3.rotation.toFixed(1) - + "\nscale: " + pinch3.scale.toFixed(1) - + "\ntranslation: " + pinch3.translation + + getTransformationDetails(rect3, pinch3) } DragHandler { objectName: "DragHandler" } @@ -102,13 +114,12 @@ Rectangle { maximumScale: 10 } } - } Rectangle { id: centroidIndicator property QtObject pincher: pinch2.active ? pinch2 : pinch3 - x: pincher.centroid.x - y: pincher.centroid.y + x: pincher.centroid.x - radius + y: pincher.centroid.y - radius z: 1 visible: pincher.active radius: width / 2 -- cgit v1.2.3 From 871314ced803afe0ac31033cfbd79fa4c1b18e3d Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 8 Dec 2016 19:19:04 +0100 Subject: DragHandler active property replaces dragging; same as grabbing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a QQuickPointerSingleHandler grabs a point, it's definitely in the active state: doing something with the point. (The converse is not always true though: e.g. TapHandler can sometimes detect a tap without ever grabbing.) In DragHandler, the "dragging" property means the same as "active": we always grab when dragging, to be sure to get the updates. So the "dragging" property is removed because it's redundant. In QQuickPointerHandler we don't say that "wanting" an event is the same as being active, because 1) it won't necessarily grab right away and 2) every handler which was active should "want" the release event, yet it needs to setActive(false) as soon as it's done processing it. Change-Id: Ie010db54714a7914109da6469e79865f9a0a18e4 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/Slider.qml | 2 +- tests/manual/pointer/joystick.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index 363f6911d4..cd52dfac80 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -70,7 +70,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - visible: dragHandler.dragging + opacity: dragHandler.active ? 1 : 0 } Image { id: knob diff --git a/tests/manual/pointer/joystick.qml b/tests/manual/pointer/joystick.qml index 7959eaea42..bcc4564471 100644 --- a/tests/manual/pointer/joystick.qml +++ b/tests/manual/pointer/joystick.qml @@ -58,7 +58,7 @@ Rectangle { } states: [ State { - when: dragHandler.dragging + when: dragHandler.active AnchorChanges { target: knob anchors.horizontalCenter: undefined -- cgit v1.2.3 From 9aa0e84d974d86cf9366714107e9c84dcde15490 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 23 Dec 2016 15:35:43 +0100 Subject: Add a DragHandler::translation property This allows the application developer to get the translation of the dragged pointer, and apply it in a custom way. This should usually be combined with setting target to null. This will for instance be needed when we want to drag QtLocations map, where a map is dragged by specifying the geo location of the center of the map. The map2.qml example demonstrates this. Change-Id: I652d9fc92fa9b6dfd3796c7147832f25af0cc5bc Reviewed-by: Shawn Rutledge --- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/map2.qml | 91 +++++++++++++++++++++++++++++++++++++++++++ tests/manual/pointer/qml.qrc | 1 + 3 files changed, 93 insertions(+) create mode 100644 tests/manual/pointer/map2.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index 7ba0d9a466..64b7148bd2 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -54,6 +54,7 @@ Window { addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) 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")) } } } diff --git a/tests/manual/pointer/map2.qml b/tests/manual/pointer/map2.qml new file mode 100644 index 0000000000..fcd144bd7f --- /dev/null +++ b/tests/manual/pointer/map2.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 + +Item { + width: 640 + height: 480 + + Rectangle { + id: map + color: "aqua" + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: image.implicitWidth + height: image.implicitHeight + property point center : Qt.point(x + map.width/2, y + map.height/2) + + function setCenter(xx, yy) { + map.x = xx - map.width/2 + map.y = yy - map.height/2 + } + + + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: "resources/map.svgz" + } + } + + PinchHandler { + id: pinch + target: map + minimumScale: 0.1 + maximumScale: 10 + } + + DragHandler { + property point startDrag + target: null + onActiveChanged: { + if (active) + startDrag = map.center + } + + onTranslationChanged: { + if (!target) + map.setCenter(startDrag.x + translation.x, startDrag.y + translation.y) + } + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 3d7de4b728..08488b020b 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -9,5 +9,6 @@ resources/map.svgz resources/mixer-knob.png resources/redball.png + map2.qml -- cgit v1.2.3 From 5c6245b7ff7a941c0a2425f32909c0dc0982e199 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 25 Nov 2016 15:38:42 +0100 Subject: QQPSingleHandler: copy some values from QQuickEventPoint to properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can't copy the eventpoint and we can't continue to refer to it after delivery, either. So we can't have an event property. Some QML use cases depend on being able to access last-known values between events. Change-Id: Ice8a1763015f2554275d0cb76824fd0366eaef56 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/qml.qrc | 7 + tests/manual/pointer/resources/arrowhead.png | Bin 0 -> 883 bytes .../manual/pointer/resources/grabbing-location.svg | 1 + tests/manual/pointer/resources/mouse.png | Bin 0 -> 1919 bytes tests/manual/pointer/resources/mouse_left.png | Bin 0 -> 740 bytes tests/manual/pointer/resources/mouse_middle.png | Bin 0 -> 558 bytes tests/manual/pointer/resources/mouse_right.png | Bin 0 -> 906 bytes .../pointer/singlePointHandlerProperties.qml | 162 +++++++++++++++++++++ 9 files changed, 171 insertions(+) create mode 100644 tests/manual/pointer/resources/arrowhead.png create mode 100644 tests/manual/pointer/resources/grabbing-location.svg create mode 100644 tests/manual/pointer/resources/mouse.png create mode 100644 tests/manual/pointer/resources/mouse_left.png create mode 100644 tests/manual/pointer/resources/mouse_middle.png create mode 100644 tests/manual/pointer/resources/mouse_right.png create mode 100644 tests/manual/pointer/singlePointHandlerProperties.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index 64b7148bd2..62202c39b1 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -50,6 +50,7 @@ Window { id: ll anchors.fill: parent Component.onCompleted: { + addExample("single point handler", "QQuickPointerSingleHandler: test properties copied from events", Qt.resolvedUrl("singlePointHandlerProperties.qml")) addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml")) addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml")) diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 08488b020b..adf255ea1f 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -5,9 +5,16 @@ map.qml mixer.qml pinchHandler.qml + singlePointHandlerProperties.qml content/Slider.qml + resources/arrowhead.png + resources/grabbing-location.svg resources/map.svgz resources/mixer-knob.png + resources/mouse.png + resources/mouse_left.png + resources/mouse_middle.png + resources/mouse_right.png resources/redball.png map2.qml diff --git a/tests/manual/pointer/resources/arrowhead.png b/tests/manual/pointer/resources/arrowhead.png new file mode 100644 index 0000000000..7719bc6d6a Binary files /dev/null and b/tests/manual/pointer/resources/arrowhead.png differ diff --git a/tests/manual/pointer/resources/grabbing-location.svg b/tests/manual/pointer/resources/grabbing-location.svg new file mode 100644 index 0000000000..c26881e9ba --- /dev/null +++ b/tests/manual/pointer/resources/grabbing-location.svg @@ -0,0 +1 @@ + diff --git a/tests/manual/pointer/resources/mouse.png b/tests/manual/pointer/resources/mouse.png new file mode 100644 index 0000000000..268946df0a Binary files /dev/null and b/tests/manual/pointer/resources/mouse.png differ diff --git a/tests/manual/pointer/resources/mouse_left.png b/tests/manual/pointer/resources/mouse_left.png new file mode 100644 index 0000000000..9292301b47 Binary files /dev/null and b/tests/manual/pointer/resources/mouse_left.png differ diff --git a/tests/manual/pointer/resources/mouse_middle.png b/tests/manual/pointer/resources/mouse_middle.png new file mode 100644 index 0000000000..064e8b9c16 Binary files /dev/null and b/tests/manual/pointer/resources/mouse_middle.png differ diff --git a/tests/manual/pointer/resources/mouse_right.png b/tests/manual/pointer/resources/mouse_right.png new file mode 100644 index 0000000000..cab1a36ba6 Binary files /dev/null and b/tests/manual/pointer/resources/mouse_right.png differ diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml new file mode 100644 index 0000000000..f5a938e401 --- /dev/null +++ b/tests/manual/pointer/singlePointHandlerProperties.qml @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.9 +import Qt.labs.handlers 1.0 + +Rectangle { + id: root + width: 480 + height: 480 + color: "black" + + Item { + id: crosshairs + x: dragHandler.pos.x - width / 2 + y: dragHandler.pos.y - height / 2 + width: parent.width / 2; height: parent.height / 2 + visible: dragHandler.active + rotation: dragHandler.rotation + + Rectangle { + color: "goldenrod" + anchors.centerIn: parent + width: 2; height: parent.height + antialiasing: true + } + Rectangle { + color: "goldenrod" + anchors.centerIn: parent + width: parent.width; height: 2 + antialiasing: true + } + Rectangle { + color: "goldenrod" + width: Math.max(2, 50 * dragHandler.pressure) + height: width + radius: width / 2 + anchors.centerIn: parent + antialiasing: true + Rectangle { + y: -40 + anchors.horizontalCenter: parent.horizontalCenter + color: "lightsteelblue" + implicitWidth: label.implicitWidth + implicitHeight: label.implicitHeight + Text { + id: label + text: 'id: ' + dragHandler.pointId.toString(16) + " uid: " + dragHandler.uniquePointId.numericId + + '\npos: (' + dragHandler.pos.x.toFixed(2) + ', ' + dragHandler.pos.y.toFixed(2) + ')' + } + } + } + Rectangle { + color: "transparent" + border.color: "white" + antialiasing: true + width: dragHandler.ellipseDiameters.width + height: dragHandler.ellipseDiameters.height + radius: Math.min(width / 2, height / 2) + anchors.centerIn: parent + } + } + Rectangle { + id: velocityVector + visible: width > 0 + width: dragHandler.velocity.length() * 100 + height: 2 + x: dragHandler.pos.x + y: dragHandler.pos.y + rotation: Math.atan2(dragHandler.velocity.y, dragHandler.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 + } + } + + Component { + id: grabbingLocationIndicator + Image { + source: "resources/grabbing-location.svg" + sourceSize.width: 32 + sourceSize.height: 32 + } + } + + Component { + id: mouseButtonIndicator + Image { + property int buttons + source: "resources/mouse.png" + Image { + source: "resources/mouse_left.png" + visible: buttons & Qt.LeftButton + } + Image { + source: "resources/mouse_middle.png" + visible: buttons & Qt.MidButton + } + Image { + source: "resources/mouse_right.png" + visible: buttons & Qt.RightButton + } + } + } + + DragHandler { + id: dragHandler + target: null + onGrabChanged: if (active) { + console.log("grabbed " + point.pointId + " @ " + sceneGrabPos) + grabbingLocationIndicator.createObject(root, {"x": sceneGrabPos.x, "y": sceneGrabPos.y - 16}) + } + onPressedButtonsChanged: { + if (pressedButtons) + mouseButtonIndicator.createObject(root, {"x": pressPos.x - 44, "y": pressPos.y - 64, "buttons": pressedButtons}) + } + } +} -- cgit v1.2.3 From f11c9a24e685178a0a1a2db453e0e43b7ca3a5f2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 24 Jul 2015 10:53:32 +0200 Subject: add MomentumAnimation as a manual test / experiment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/manual/pointer/content/MomentumAnimation.qml | 71 ++++++++++++++++++ tests/manual/pointer/flingAnimation.qml | 84 ++++++++++++++++++++++ tests/manual/pointer/main.qml | 1 + tests/manual/pointer/qml.qrc | 2 + 4 files changed, 158 insertions(+) create mode 100644 tests/manual/pointer/content/MomentumAnimation.qml create mode 100644 tests/manual/pointer/flingAnimation.qml (limited to 'tests/manual') 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 @@ + flingAnimation.qml main.qml joystick.qml map.qml mixer.qml pinchHandler.qml singlePointHandlerProperties.qml + content/MomentumAnimation.qml content/Slider.qml resources/arrowhead.png resources/grabbing-location.svg -- cgit v1.2.3 From 5d59327ebd0b19a8043f9d35c1c6cbf90681b5b2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 6 Aug 2015 15:43:34 +0200 Subject: add FakeFlickable manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Demonstrate that DragHandler, MomentumAnimation and a couple of Items are enough to implement most of Flickable's functionality. Change-Id: I59dae38dc66c16813385aa6c00e3a1a834520f31 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/FakeFlickable.qml | 89 ++++++++++++++++++++++++++ tests/manual/pointer/fakeFlickable.qml | 88 +++++++++++++++++++++++++ tests/manual/pointer/main.qml | 1 + tests/manual/pointer/qml.qrc | 2 + 4 files changed, 180 insertions(+) create mode 100644 tests/manual/pointer/content/FakeFlickable.qml create mode 100644 tests/manual/pointer/fakeFlickable.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml new file mode 100644 index 0000000000..bfae653503 --- /dev/null +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 + +Item { + id: root + default property alias data: __contentItem.data + property alias velocity: anim.velocity + property alias contentX: __contentItem.x // sign is reversed compared to Flickable.contentX + property alias contentY: __contentItem.y // sign is reversed compared to Flickable.contentY + property alias contentWidth: __contentItem.width + property alias contentHeight: __contentItem.height + signal flickStarted + signal flickEnded + + Item { + id: __contentItem + objectName: "__contentItem" + width: childrenRect.width + height: childrenRect.height + + property real xlimit: root.width - __contentItem.width + property real ylimit: root.height - __contentItem.height + + function returnToBounds() { + if (x > 0) + x = 0 + else if (x < xlimit) + x = xlimit + if (y > 0) + y = 0 + else if (y < ylimit) + y = ylimit + } + + DragHandler { + id: dragHandler + onActiveChanged: if (!active) anim.restart(velocity) + } + MomentumAnimation { + id: anim + target: __contentItem + onStarted: root.flickStarted() + onStopped: { + __contentItem.returnToBounds() + root.flickEnded() + } + } + } +} diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml new file mode 100644 index 0000000000..31e3d9f74c --- /dev/null +++ b/tests/manual/pointer/fakeFlickable.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 { + color: "#444" + width: 480 + height: 480 + + FakeFlickable { + anchors.fill: parent + Row { + Item { + width: 100 + height: 400 + Slider { + id: slider + label: "font size" + anchors.fill: parent + maximumValue: 36 + value: 14 + } + } + Text { + id: text + color: "beige" + font.family: "mono" + font.pointSize: slider.value + onTextChanged: console.log("text geom " + width + "x" + height + + ", parent " + parent + " geom " + parent.width + "x" + parent.height) + } + } + + + onFlickStarted: console.log("flick started with velocity " + velocity) + onFlickEnded: console.log("flick ended") + + Component.onCompleted: { + var request = new XMLHttpRequest() + request.open('GET', 'content/FakeFlickable.qml') + request.onreadystatechange = function(event) { + if (request.readyState === XMLHttpRequest.DONE) + text.text = request.responseText + } + request.send() + } + } +} diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index 3289df161c..e61d0ab576 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -57,6 +57,7 @@ Window { 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")) + addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml")) } } } diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 9463ae4c84..50c0dc748d 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -2,11 +2,13 @@ flingAnimation.qml main.qml + fakeFlickable.qml joystick.qml map.qml mixer.qml pinchHandler.qml singlePointHandlerProperties.qml + content/FakeFlickable.qml content/MomentumAnimation.qml content/Slider.qml resources/arrowhead.png -- cgit v1.2.3 From f1f3fdd166c70da696981ff9070ebfa08df81d80 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 7 Aug 2015 13:29:04 +0200 Subject: add modified photosurface as a manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a version of examples/quick/demos/photosurface updated to use handlers instead of Areas. Change-Id: I80a6c46f2ea4821097f3654cd885553aa484d405 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.qml | 3 +- tests/manual/pointer/photosurface.qml | 175 ++++++++++++++++++++++++++++++++++ tests/manual/pointer/qml.qrc | 1 + 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 tests/manual/pointer/photosurface.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index e61d0ab576..601065081d 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -58,6 +58,7 @@ Window { 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")) addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml")) + addExample("photo surface", "re-implementation of the existing photo surface demo using Handlers", Qt.resolvedUrl("photosurface.qml")) } } } diff --git a/tests/manual/pointer/photosurface.qml b/tests/manual/pointer/photosurface.qml new file mode 100644 index 0000000000..6601909a37 --- /dev/null +++ b/tests/manual/pointer/photosurface.qml @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 QtQuick.Dialogs 1.0 +import Qt.labs.folderlistmodel 1.0 +import Qt.labs.handlers 1.0 +import "content" + +Rectangle { + id: root + visible: true + width: 1024; height: 600 + color: "black" + property int highestZ: 0 + property real defaultSize: 200 + property real surfaceViewportRatio: 1.5 + + FileDialog { + id: fileDialog + title: "Choose a folder with some images" + selectFolder: true + onAccepted: folderModel.folder = fileUrl + "/" + } + Shortcut { + id: openShortcut + sequence: StandardKey.Open + onActivated: fileDialog.open() + } + + FakeFlickable { + id: flick + anchors.fill: parent + contentWidth: width * 2 + contentHeight: height * 2 + Repeater { + model: FolderListModel { + id: folderModel + folder: "resources/" + objectName: "folderModel" + showDirs: false + nameFilters: ["*.png", "*.jpg", "*.gif"] + } + Rectangle { + id: photoFrame + objectName: "frame-" + fileName + width: image.width * (1 + 0.10 * image.height / image.width) + height: image.height * 1.10 + scale: defaultSize / Math.max(image.sourceSize.width, image.sourceSize.height) + Behavior on scale { NumberAnimation { duration: 200 } } + Behavior on x { NumberAnimation { duration: 200 } } + Behavior on y { NumberAnimation { duration: 200 } } + border.color: pinchHandler.active || dragHandler.active ? "red" : "black" + border.width: 2 + smooth: true + antialiasing: true + Component.onCompleted: { + x = Math.random() * root.width - width / 2 + y = Math.random() * root.height - height / 2 + rotation = Math.random() * 13 - 6 + } + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: folderModel.folder + fileName + antialiasing: true + } + + MomentumAnimation { id: anim; target: photoFrame } + + DragHandler { + id: dragHandler + onActiveChanged: { + if (!active) + anim.restart(velocity) + } + } + + PinchHandler { + id: pinchHandler + minimumRotation: -360 + maximumRotation: 360 + minimumScale: 0.1 + maximumScale: 10 + property real zRestore: 0 + } + } + } + } + + Rectangle { + id: verticalScrollDecorator + anchors.right: parent.right + anchors.margins: 2 + color: "cyan" + border.color: "black" + border.width: 1 + width: 5 + radius: 2 + antialiasing: true + height: flick.height * (flick.height / flick.contentHeight) - (width - anchors.margins) * 2 + y: -flick.contentY * (flick.height / flick.contentHeight) + NumberAnimation on opacity { id: vfade; to: 0; duration: 500 } + onYChanged: { opacity = 1.0; fadeTimer.restart() } + } + + Rectangle { + id: horizontalScrollDecorator + anchors.bottom: parent.bottom + anchors.margins: 2 + color: "cyan" + border.color: "black" + border.width: 1 + height: 5 + radius: 2 + antialiasing: true + width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2 + x: -flick.contentX * (flick.width / flick.contentWidth) + NumberAnimation on opacity { id: hfade; to: 0; duration: 500 } + onXChanged: { opacity = 1.0; fadeTimer.restart() } + } + + Timer { id: fadeTimer; interval: 1000; onTriggered: { hfade.start(); vfade.start() } } + + Text { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 10 + color: "darkgrey" + wrapMode: Text.WordWrap + font.pointSize: 8 + text: "Press " + openShortcut.nativeText + " to choose a different image folder\n" + + "On a touchscreen: use two fingers to zoom and rotate, one finger to drag\n" + + "With a mouse: drag normally" + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 50c0dc748d..87fc021680 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -6,6 +6,7 @@ joystick.qml map.qml mixer.qml + photosurface.qml pinchHandler.qml singlePointHandlerProperties.qml content/FakeFlickable.qml -- cgit v1.2.3 From 2d61a39dedfb2718cdb6c26b370b7e4103db9c4a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 28 Jul 2015 15:24:29 +0200 Subject: Introduce TapHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Device-agnostic tap/click detection. Also detect whether the taps or clicks occur close enough together in both time and space to be considered part of a multi-tap gesture. Change-Id: I41a378feea3340b9f0409118273746a289641d6c Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/qml.qrc | 1 + tests/manual/pointer/tapHandler.qml | 136 ++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 tests/manual/pointer/tapHandler.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index 601065081d..b06d3cf155 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -59,6 +59,7 @@ Window { addExample("fling animation", "DragHandler: after dragging, use an animation to simulate momentum", Qt.resolvedUrl("flingAnimation.qml")) addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml")) addExample("photo surface", "re-implementation of the existing photo surface demo using Handlers", Qt.resolvedUrl("photosurface.qml")) + addExample("tap", "TapHandler: device-agnostic tap/click detection for buttons", Qt.resolvedUrl("tapHandler.qml")) } } } diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 87fc021680..4535a26802 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -9,6 +9,7 @@ photosurface.qml pinchHandler.qml singlePointHandlerProperties.qml + tapHandler.qml content/FakeFlickable.qml content/MomentumAnimation.qml content/Slider.qml diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml new file mode 100644 index 0000000000..d099fc7faf --- /dev/null +++ b/tests/manual/pointer/tapHandler.qml @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "qrc:/quick/shared/" as Examples + +Item { + width: 480 + height: 320 + + Rectangle { + id: rect + anchors.fill: parent; anchors.margins: 40 + border.width: 3; border.color: "transparent" + color: handler.isPressed ? "lightsteelblue" : "darkgrey" + + TapHandler { + id: handler + acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) | + (middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) | + (rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton) + onCanceled: { + console.log("canceled @ " + pos) + borderBlink.blinkColor = "red" + borderBlink.start() + } + onTapped: { + console.log("tapped @ " + point.pos + " button(s) " + point.event.button + " tapCount " + tapCount) + if (tapCount > 1) { + tapCountLabel.text = tapCount + flashAnimation.start() + } else { + switch (point.event.button) { + case Qt.LeftButton: borderBlink.blinkColor = "green"; break; + case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break; + case Qt.RightButton: borderBlink.blinkColor = "magenta"; break; + } + borderBlink.start() + } + } + } + + Text { + id: tapCountLabel + anchors.centerIn: parent + font.pixelSize: 72 + font.weight: Font.Black + SequentialAnimation { + id: flashAnimation + PropertyAction { target: tapCountLabel; property: "visible"; value: true } + PropertyAction { target: tapCountLabel; property: "opacity"; value: 1.0 } + PropertyAction { target: tapCountLabel; property: "scale"; value: 1.0 } + ParallelAnimation { + NumberAnimation { + target: tapCountLabel + property: "opacity" + to: 0 + duration: 500 + } + NumberAnimation { + target: tapCountLabel + property: "scale" + to: 1.5 + duration: 500 + } + } + } + } + + SequentialAnimation { + id: borderBlink + property color blinkColor: "blue" + loops: 3 + ScriptAction { script: rect.border.color = borderBlink.blinkColor } + PauseAnimation { duration: 100 } + ScriptAction { script: rect.border.color = "transparent" } + PauseAnimation { duration: 100 } + } + } + + Row { + spacing: 6 + Text { text: "accepted mouse clicks:"; anchors.verticalCenter: leftAllowedCB.verticalCenter } + Examples.CheckBox { + id: leftAllowedCB + checked: true + text: "left click" + } + Examples.CheckBox { + id: middleAllowedCB + text: "middle click" + } + Examples.CheckBox { + id: rightAllowedCB + text: "right click" + } + } +} -- cgit v1.2.3 From 3e21962cea50433c8f043d2a8a0d61ef86339a22 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 3 Jan 2017 08:57:02 +0100 Subject: add flickableWithHandlers manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to verify that Flickable still works after the changes in event delivery logic, even when it contains a mix of various Areas and Handlers. Change-Id: Ibf68bc8b403718c87c7e647b17837f2a8e4e3f0e Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/MouseAreaButton.qml | 86 ++++++++++++++++ tests/manual/pointer/content/MouseAreaSlider.qml | 119 ++++++++++++++++++++++ tests/manual/pointer/content/MptaButton.qml | 87 ++++++++++++++++ tests/manual/pointer/content/TapHandlerButton.qml | 84 +++++++++++++++ tests/manual/pointer/flickableWithHandlers.qml | 88 ++++++++++++++++ 5 files changed, 464 insertions(+) create mode 100644 tests/manual/pointer/content/MouseAreaButton.qml create mode 100644 tests/manual/pointer/content/MouseAreaSlider.qml create mode 100644 tests/manual/pointer/content/MptaButton.qml create mode 100644 tests/manual/pointer/content/TapHandlerButton.qml create mode 100644 tests/manual/pointer/flickableWithHandlers.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/MouseAreaButton.qml b/tests/manual/pointer/content/MouseAreaButton.qml new file mode 100644 index 0000000000..de1d972386 --- /dev/null +++ b/tests/manual/pointer/content/MouseAreaButton.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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.1 +import QtQuick.Window 2.1 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias containsMouse: mouseArea.containsMouse + property alias pressed: mouseArea.pressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + hoverEnabled: true + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/pointer/content/MouseAreaSlider.qml b/tests/manual/pointer/content/MouseAreaSlider.qml new file mode 100644 index 0000000000..c34c528c7d --- /dev/null +++ b/tests/manual/pointer/content/MouseAreaSlider.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.7 + +Item { + id: root + property int value: 50 + property int maximumValue: 99 + property alias label: label.text + + Rectangle { + id: slot + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 10 + anchors.topMargin: 30 + anchors.bottomMargin: 30 + anchors.horizontalCenter: parent.horizontalCenter + width: 10 + color: "black" + radius: width / 2 + smooth: true + } + + Rectangle { + // RectangularGlow is better, but that's a different module + id: glow + anchors.fill: knob + anchors.margins: -5 + anchors.leftMargin: -2 + anchors.horizontalCenterOffset: 1 + radius: 5 + color: "#4400FFFF" + opacity: ma.pressed ? 1 : 0 + } + Image { + id: knob + source: "../resources/mixer-knob.png" + antialiasing: true + x: slot.x - width / 2 + slot.width / 2 + height: root.width / 2 + width: implicitWidth / implicitHeight * height + property bool programmatic: false + property real multiplier: root.maximumValue / (ma.drag.maximumY - ma.drag.minimumY) + onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - ma.drag.minimumY) * multiplier + transformOrigin: Item.Center + function setValue(value) { knob.y = ma.drag.maximumY - value / knob.multiplier } + MouseArea { + id: ma + anchors.fill: parent + drag.target: parent + drag.minimumX: knob.x + drag.maximumX: knob.x + drag.minimumY: slot.y + drag.maximumY: slot.height + slot.y - knob.height + } + } + + Text { + font.pointSize: 16 + color: "red" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: root.value + } + + Text { + id: label + font.pointSize: 12 + color: "red" + anchors.top: parent.top + anchors.topMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + } + + onHeightChanged: { + knob.programmatic = true + knob.setValue(root.value) + knob.programmatic = false + } +} diff --git a/tests/manual/pointer/content/MptaButton.qml b/tests/manual/pointer/content/MptaButton.qml new file mode 100644 index 0000000000..836744822b --- /dev/null +++ b/tests/manual/pointer/content/MptaButton.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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.7 +import QtQuick.Window 2.1 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias pressed: point.pressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: container.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + MultiPointTouchArea { + id: mpta + anchors.fill: parent + touchPoints: [ TouchPoint { + id: point + onPressedChanged: if (!pressed) container.clicked() + } ] + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/pointer/content/TapHandlerButton.qml b/tests/manual/pointer/content/TapHandlerButton.qml new file mode 100644 index 0000000000..e40c539686 --- /dev/null +++ b/tests/manual/pointer/content/TapHandlerButton.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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.7 +import QtQuick.Window 2.1 +import Qt.labs.handlers 1.0 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias pressed: th.isPressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: container.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + TapHandler { + id: th + onTapped: container.clicked() + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/pointer/flickableWithHandlers.qml b/tests/manual/pointer/flickableWithHandlers.qml new file mode 100644 index 0000000000..59e8661aac --- /dev/null +++ b/tests/manual/pointer/flickableWithHandlers.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.7 +import Qt.labs.handlers 1.0 +import "content" + +Rectangle { + id: root + width: 300 + height: 400 + objectName: "root" + color: "#222222" + + Flickable { + anchors.fill: parent + anchors.margins: 10 + contentHeight: 600 + contentWidth: 600 + + Row { + spacing: 6 + Slider { + label: "DragHandler" + width: 100; height: 500 + } + MouseAreaSlider { + label: "MouseArea" + width: 100; height: 500 + } + Column { + spacing: 6 + MouseAreaButton { + text: "MouseArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + TapHandlerButton { + text: "TapHandler" + } + TapHandlerButton { + text: "TapHandler" + } + } + } + } +} -- cgit v1.2.3 From 5c639a07fd90916d39823e800d5d89f779d892e9 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 18 Nov 2016 15:02:18 +0100 Subject: TapHandler: add long-press feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a longPressed signal, emitted when the point is held long enough. Add the longPressThreshold to control how long that is. Change-Id: I95a65f1e4c62eb41fb9ea02b14bdc3f16aa72ec2 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/tapHandler.qml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index d099fc7faf..f2a454fb80 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -57,6 +57,11 @@ Item { acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) | (middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) | (rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton) + onPressedButtonsChanged: switch (pressedButtons) { + case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break; + case Qt.RightButton: borderBlink.blinkColor = "magenta"; break; + default: borderBlink.blinkColor = "green"; break; + } onCanceled: { console.log("canceled @ " + pos) borderBlink.blinkColor = "red" @@ -68,14 +73,13 @@ Item { tapCountLabel.text = tapCount flashAnimation.start() } else { - switch (point.event.button) { - case Qt.LeftButton: borderBlink.blinkColor = "green"; break; - case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break; - case Qt.RightButton: borderBlink.blinkColor = "magenta"; break; - } borderBlink.start() } } + onLongPressed: longPressFeedback.createObject(rect, + {"x": pos.x, "y": pos.y, + "text": "long press", + "color": borderBlink.blinkColor}) } Text { @@ -105,6 +109,11 @@ Item { } } + Component { + id: longPressFeedback + Text { } + } + SequentialAnimation { id: borderBlink property color blinkColor: "blue" -- cgit v1.2.3 From cb78d5c91ed33543a8e7fe7717f74f95834e4cc3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 18 Oct 2016 18:45:49 +0200 Subject: TapHandler: add gesturePolicy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now it behaved as if this was set to DragThreshold: give up on the tap as soon as you are clearly dragging rather than tapping. But that's not what is normally wanted when building a Button control, for example. So provide 3 options: give up past the drag threshold, when the pointer goes outside the bounds, or when it's released outside the bounds. The longPressThreshold also constrains all three cases: holding (or dragging) for too long will not result in an immediate cancellation, but it also will not be a tap gesture. Change-Id: I95aec978e783892b55371391a27642751d91d9ff Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/FlashAnimation.qml | 57 ++++++++++++++ tests/manual/pointer/content/MultiButton.qml | 85 +++++++++++++++++++++ tests/manual/pointer/content/Slider.qml | 19 ++++- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/multibuttons.qml | 95 ++++++++++++++++++++++++ tests/manual/pointer/qml.qrc | 6 ++ tests/manual/pointer/resources/balloon.png | Bin 0 -> 3759 bytes tests/manual/pointer/resources/fighter.png | Bin 0 -> 9669 bytes tests/manual/pointer/resources/missile.png | Bin 0 -> 2305 bytes tests/manual/pointer/resources/mixer-knob.png | Bin 8555 -> 7821 bytes tests/manual/pointer/tapHandler.qml | 29 ++++++++ 11 files changed, 290 insertions(+), 2 deletions(-) create mode 100644 tests/manual/pointer/content/FlashAnimation.qml create mode 100644 tests/manual/pointer/content/MultiButton.qml create mode 100644 tests/manual/pointer/multibuttons.qml create mode 100644 tests/manual/pointer/resources/balloon.png create mode 100644 tests/manual/pointer/resources/fighter.png create mode 100644 tests/manual/pointer/resources/missile.png (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/FlashAnimation.qml b/tests/manual/pointer/content/FlashAnimation.qml new file mode 100644 index 0000000000..b628255a3d --- /dev/null +++ b/tests/manual/pointer/content/FlashAnimation.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.0 + +SequentialAnimation { + id: tapFlash + running: false + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } + PauseAnimation { duration: 100 } + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } + PauseAnimation { duration: 100 } + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } +} diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml new file mode 100644 index 0000000000..5b31e9ebd0 --- /dev/null +++ b/tests/manual/pointer/content/MultiButton.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 + +Rectangle { + id: root + property alias label: label.text + property alias pressed: tap.isPressed + property bool checked: false + property alias gesturePolicy: tap.gesturePolicy + signal tapped + + width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0 + border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true + + gradient: Gradient { + GradientStop { position: 0.0; color: tap.isPressed ? "#b8b5b2" : "#efebe7" } + GradientStop { position: 1.0; color: "#b8b5b2" } + } + + TapHandler { + id: tap + objectName: label.text + onTapped: { + tapFlash.start() + root.tapped + } + } + + Text { + id: label + font.pointSize: 14 + text: "Button" + anchors.centerIn: parent + } + + Rectangle { + anchors.fill: parent + color: "transparent" + border.width: 2; radius: root.radius; antialiasing: true + opacity: tapFlash.running ? 1 : 0 + FlashAnimation on visible { + id: tapFlash + } + } +} diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index cd52dfac80..a1decf8c4b 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -46,6 +46,9 @@ Item { property int value: 50 property int maximumValue: 99 property alias label: label.text + property alias tapEnabled: tap.enabled + property alias pressed: tap.isPressed + signal tapped Rectangle { id: slot @@ -70,7 +73,10 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: dragHandler.active ? 1 : 0 + opacity: dragHandler.active || tapFlash.running ? 1 : 0 + FlashAnimation on visible { + id: tapFlash + } } Image { id: knob @@ -90,6 +96,15 @@ Item { yAxis.minimum: slot.y yAxis.maximum: slot.height + slot.y - knob.height } + TapHandler { + id: tap + objectName: label.text + gesturePolicy: TapHandler.DragThreshold + onTapped: { + tapFlash.start() + root.tapped + } + } } Text { diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index b06d3cf155..a71490d23b 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -60,6 +60,7 @@ Window { addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml")) addExample("photo surface", "re-implementation of the existing photo surface demo using Handlers", Qt.resolvedUrl("photosurface.qml")) addExample("tap", "TapHandler: device-agnostic tap/click detection for buttons", Qt.resolvedUrl("tapHandler.qml")) + addExample("multibuttons", "TapHandler: gesturePolicy (99 red balloons)", Qt.resolvedUrl("multibuttons.qml")) } } } diff --git a/tests/manual/pointer/multibuttons.qml b/tests/manual/pointer/multibuttons.qml new file mode 100644 index 0000000000..16d2f191e7 --- /dev/null +++ b/tests/manual/pointer/multibuttons.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.0 +import QtQuick.Particles 2.0 +import QtQuick.Layouts 1.0 +import Qt.labs.handlers 1.0 +import "content" + +Item { + width: 800 + height: 800 + ColumnLayout { + anchors.right: parent.right + spacing: 20 + Text { text: "protagonist"; font.pointSize: 12 } + MultiButton { + id: balloonsButton + label: "Launch Balloons" + Layout.fillWidth: true + gesturePolicy: TapHandler.DragThreshold + } + Text { text: "the goons"; font.pointSize: 12 } + MultiButton { + id: missilesButton + label: "Launch Missiles" + Layout.fillWidth: true + gesturePolicy: TapHandler.WithinBounds + } + MultiButton { + id: fightersButton + label: "Launch Fighters" + Layout.fillWidth: true + gesturePolicy: TapHandler.ReleaseWithinBounds + } + } + ParticleSystem { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.leftMargin: 150 + ImageParticle { source: "resources/balloon.png" } + Emitter { anchors.bottom: parent.bottom; enabled: balloonsButton.pressed; lifeSpan: 5000; size: 64 + maximumEmitted: 99 + emitRate: 50; velocity: PointDirection { x: 10; y: -150; yVariation: 30; xVariation: 50 } } } + ParticleSystem { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + ImageParticle { source: "resources/fighter.png" } + Emitter { anchors.bottom: parent.bottom; enabled: fightersButton.pressed; lifeSpan: 15000; size: 204 + emitRate: 3; velocity: PointDirection { x: -1000; y: -250; yVariation: 150; xVariation: 50 } } } + ParticleSystem { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.rightMargin: 100 + ImageParticle { source: "resources/missile.png"; autoRotation: true; rotation: 90 } + Emitter { anchors.bottom: parent.bottom; enabled: missilesButton.pressed; lifeSpan: 5000; size: 128 + emitRate: 10; velocity: PointDirection { x: -200; y: -350; yVariation: 200; xVariation: 100 } } } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 4535a26802..4113974d46 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -6,16 +6,22 @@ joystick.qml map.qml mixer.qml + multibuttons.qml photosurface.qml pinchHandler.qml singlePointHandlerProperties.qml tapHandler.qml content/FakeFlickable.qml + content/FlashAnimation.qml content/MomentumAnimation.qml + content/MultiButton.qml content/Slider.qml resources/arrowhead.png + resources/balloon.png + resources/fighter.png resources/grabbing-location.svg resources/map.svgz + resources/missile.png resources/mixer-knob.png resources/mouse.png resources/mouse_left.png diff --git a/tests/manual/pointer/resources/balloon.png b/tests/manual/pointer/resources/balloon.png new file mode 100644 index 0000000000..6476facc49 Binary files /dev/null and b/tests/manual/pointer/resources/balloon.png differ diff --git a/tests/manual/pointer/resources/fighter.png b/tests/manual/pointer/resources/fighter.png new file mode 100644 index 0000000000..2acee43cba Binary files /dev/null and b/tests/manual/pointer/resources/fighter.png differ diff --git a/tests/manual/pointer/resources/missile.png b/tests/manual/pointer/resources/missile.png new file mode 100644 index 0000000000..72c02d1fb9 Binary files /dev/null and b/tests/manual/pointer/resources/missile.png differ diff --git a/tests/manual/pointer/resources/mixer-knob.png b/tests/manual/pointer/resources/mixer-knob.png index 02cc9fc72b..b7d42ee3bd 100644 Binary files a/tests/manual/pointer/resources/mixer-knob.png and b/tests/manual/pointer/resources/mixer-knob.png differ diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index f2a454fb80..2e45b1c369 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -57,6 +57,9 @@ Item { acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) | (middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) | (rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton) + gesturePolicy: (policyDragThresholdCB.checked ? TapHandler.DragThreshold : + policyWithinBoundsCB.checked ? TapHandler.WithinBounds : + TapHandler.ReleaseWithinBounds) onPressedButtonsChanged: switch (pressedButtons) { case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break; case Qt.RightButton: borderBlink.blinkColor = "magenta"; break; @@ -141,5 +144,31 @@ Item { id: rightAllowedCB text: "right click" } + Text { text: " gesture policy:"; anchors.verticalCenter: leftAllowedCB.verticalCenter } + Examples.CheckBox { + id: policyDragThresholdCB + text: "drag threshold" + onCheckedChanged: if (checked) { + policyWithinBoundsCB.checked = false; + policyReleaseWithinBoundsCB.checked = false; + } + } + Examples.CheckBox { + id: policyWithinBoundsCB + text: "within bounds" + onCheckedChanged: if (checked) { + policyDragThresholdCB.checked = false; + policyReleaseWithinBoundsCB.checked = false; + } + } + Examples.CheckBox { + id: policyReleaseWithinBoundsCB + checked: true + text: "release within bounds" + onCheckedChanged: if (checked) { + policyDragThresholdCB.checked = false; + policyWithinBoundsCB.checked = false; + } + } } } -- cgit v1.2.3 From 12f3f20be7e160b4f8de4ee267909fec61673111 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 5 Aug 2015 12:45:48 +0200 Subject: TapHandler: add timeHeld property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It enables long-press gestures to have continuous feedback. Change-Id: Idd0838aff6213ebfc2fce66639bbc932e77208b4 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/tapHandler.qml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index 2e45b1c369..06070a02ff 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -81,7 +81,7 @@ Item { } onLongPressed: longPressFeedback.createObject(rect, {"x": pos.x, "y": pos.y, - "text": "long press", + "text": Math.round(handler.timeHeld).toFixed(3) + " sec", "color": borderBlink.blinkColor}) } @@ -112,6 +112,20 @@ Item { } } + Rectangle { + id: expandingCircle + radius: handler.timeHeld * 100 + visible: radius > 0 && handler.isPressed + border.width: 3 + border.color: borderBlink.blinkColor + color: "transparent" + width: radius * 2 + height: radius * 2 + x: handler.pressPos.x - radius + y: handler.pressPos.y - radius + opacity: 0.25 + } + Component { id: longPressFeedback Text { } -- cgit v1.2.3 From 4e7041c65216ada4f5fb604a9df840152ba60317 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 8 Feb 2017 15:08:53 +0100 Subject: pointer handlers manual test: can give arg with qml to launch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it easier to repeatedly launch the same test: specify the qml file on the command line instead of having to click the list item each time. e.g. ./pointer tapHandler.qml Change-Id: I30b449b161107b1746418fc45518d202ba7d8381 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/main.cpp | 15 +++++++++++++++ tests/manual/pointer/main.qml | 1 + 2 files changed, 16 insertions(+) (limited to 'tests/manual') diff --git a/tests/manual/pointer/main.cpp b/tests/manual/pointer/main.cpp index a4e1060cf5..7935b4072c 100644 --- a/tests/manual/pointer/main.cpp +++ b/tests/manual/pointer/main.cpp @@ -39,6 +39,8 @@ ****************************************************************************/ #include #include +#include +#include int main(int argc, char *argv[]) { @@ -46,6 +48,19 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (!app.arguments().isEmpty()) { + QQuickWindow * win = static_cast(engine.rootObjects().first()); + auto lastArg = app.arguments().last(); + if (lastArg.endsWith(QLatin1String(".qml"))) { + auto root = win->findChild("LauncherList"); + int showExampleIdx = -1; + for (int i = root->metaObject()->methodCount(); showExampleIdx < 0 && i >= 0; --i) + if (root->metaObject()->method(i).name() == QByteArray("showExample")) + showExampleIdx = i; + QMetaMethod showExampleFn = root->metaObject()->method(showExampleIdx); + showExampleFn.invoke(root, Q_ARG(QVariant, QVariant(QLatin1String("../../") + lastArg))); + } + } return app.exec(); } diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index a71490d23b..e60edd06ce 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -48,6 +48,7 @@ Window { visible: true Examples.LauncherList { id: ll + objectName: "LauncherList" anchors.fill: parent Component.onCompleted: { addExample("single point handler", "QQuickPointerSingleHandler: test properties copied from events", Qt.resolvedUrl("singlePointHandlerProperties.qml")) -- cgit v1.2.3 From 7042cfd9cb1b552c5fd753b6912439ce604eb1a0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 20 Jan 2017 11:41:23 +0100 Subject: allow stealing grab from handlers; notify passive grabbers when stolen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now if a Button with a TapHandler is pressed and has only a passive grab, Flickable can take the exclusive grab, and it notifies the TapHandler so that the button can go back to released state. This reverts parts of commit e2fd141372335f917c2d216051abb00d8b15f87c such that more of tst_PointerHandlers is working the same as it was before we started adding the passive grab concept. Change-Id: I88970716fcbbfb066a313fcefb233cf9263da944 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/flickableWithHandlers.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/flickableWithHandlers.qml b/tests/manual/pointer/flickableWithHandlers.qml index 59e8661aac..822ca7dc8a 100644 --- a/tests/manual/pointer/flickableWithHandlers.qml +++ b/tests/manual/pointer/flickableWithHandlers.qml @@ -44,7 +44,7 @@ import "content" Rectangle { id: root - width: 300 + width: 400 height: 400 objectName: "root" color: "#222222" -- cgit v1.2.3 From 55cb6574d41ff6e50d2956d7c6f1dd5ac1315741 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 21 Feb 2017 15:32:36 +0100 Subject: flickableWithHandlers manual test improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add it to main.qml and it and its dependencies to resources Add checkbox to control Flickable's pressDelay Change-Id: Ifaa4bbbaf61944231ab80cf356d7a3c44b24d73b Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/flickableWithHandlers.qml | 62 +++++++++++++++++--------- tests/manual/pointer/main.qml | 1 + tests/manual/pointer/qml.qrc | 5 +++ 3 files changed, 47 insertions(+), 21 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/flickableWithHandlers.qml b/tests/manual/pointer/flickableWithHandlers.qml index 822ca7dc8a..8225012591 100644 --- a/tests/manual/pointer/flickableWithHandlers.qml +++ b/tests/manual/pointer/flickableWithHandlers.qml @@ -40,6 +40,7 @@ import QtQuick 2.7 import Qt.labs.handlers 1.0 +import "qrc:/quick/shared/" as Examples import "content" Rectangle { @@ -52,35 +53,54 @@ Rectangle { Flickable { anchors.fill: parent anchors.margins: 10 + anchors.topMargin: 40 contentHeight: 600 contentWidth: 600 + pressDelay: pressDelayCB.checked ? 1000 : 0 - Row { + Column { spacing: 6 - Slider { - label: "DragHandler" - width: 100; height: 500 - } - MouseAreaSlider { - label: "MouseArea" - width: 100; height: 500 + Rectangle { + radius: 5 + width: parent.width - 12 + height: pressDelayCB.implicitHeight + 12 + x: 6 + color: "lightgray" + Examples.CheckBox { + x: 6; y: 6 + id: pressDelayCB + text: "press delay" + } } - Column { + + + Row { spacing: 6 - MouseAreaButton { - text: "MouseArea" - } - MptaButton { - text: "MultiPointTouchArea" - } - MptaButton { - text: "MultiPointTouchArea" + Slider { + label: "DragHandler" + value: 49; width: 100; height: 400 } - TapHandlerButton { - text: "TapHandler" + MouseAreaSlider { + label: "MouseArea" + value: 49; width: 100; height: 400 } - TapHandlerButton { - text: "TapHandler" + Column { + spacing: 6 + MouseAreaButton { + text: "MouseArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + TapHandlerButton { + text: "TapHandler" + } + TapHandlerButton { + text: "TapHandler" + } } } } diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml index e60edd06ce..df34c7d4a3 100644 --- a/tests/manual/pointer/main.qml +++ b/tests/manual/pointer/main.qml @@ -62,6 +62,7 @@ Window { addExample("photo surface", "re-implementation of the existing photo surface demo using Handlers", Qt.resolvedUrl("photosurface.qml")) addExample("tap", "TapHandler: device-agnostic tap/click detection for buttons", Qt.resolvedUrl("tapHandler.qml")) addExample("multibuttons", "TapHandler: gesturePolicy (99 red balloons)", Qt.resolvedUrl("multibuttons.qml")) + addExample("flickable with Handlers", "Flickable with buttons, sliders etc. implemented in various ways", Qt.resolvedUrl("flickableWithHandlers.qml")) } } } diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 4113974d46..5bb79176c7 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -3,6 +3,7 @@ flingAnimation.qml main.qml fakeFlickable.qml + flickableWithHandlers.qml joystick.qml map.qml mixer.qml @@ -14,8 +15,12 @@ content/FakeFlickable.qml content/FlashAnimation.qml content/MomentumAnimation.qml + content/MouseAreaButton.qml + content/MouseAreaSlider.qml + content/MptaButton.qml content/MultiButton.qml content/Slider.qml + content/TapHandlerButton.qml resources/arrowhead.png resources/balloon.png resources/fighter.png -- cgit v1.2.3 From 95d1ff465c292445d36fa071b1f37a8cdaa2d7aa Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 18 Oct 2016 18:45:49 +0200 Subject: TapHandler manual test: demonstrate tapped signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Missiles are too expensive to launch in continuous sprays anyway. Also, it's too hard to keep holding down the "balloons" button if we use policy DragThreshold. This is better to have on the fighters button, since the usual use case is that ballons are launched first, and cheap enough to launch continuously. Change-Id: I3b52556b81afad9fb7ec1a4b1dec4dde3bab104c Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/MultiButton.qml | 2 +- tests/manual/pointer/multibuttons.qml | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml index 5b31e9ebd0..4a737dc9b0 100644 --- a/tests/manual/pointer/content/MultiButton.qml +++ b/tests/manual/pointer/content/MultiButton.qml @@ -62,7 +62,7 @@ Rectangle { objectName: label.text onTapped: { tapFlash.start() - root.tapped + root.tapped() } } diff --git a/tests/manual/pointer/multibuttons.qml b/tests/manual/pointer/multibuttons.qml index 16d2f191e7..748ec87c86 100644 --- a/tests/manual/pointer/multibuttons.qml +++ b/tests/manual/pointer/multibuttons.qml @@ -55,20 +55,21 @@ Item { id: balloonsButton label: "Launch Balloons" Layout.fillWidth: true - gesturePolicy: TapHandler.DragThreshold + gesturePolicy: TapHandler.WithinBounds } Text { text: "the goons"; font.pointSize: 12 } MultiButton { id: missilesButton - label: "Launch Missiles" + label: "Launch Missile" Layout.fillWidth: true - gesturePolicy: TapHandler.WithinBounds + gesturePolicy: TapHandler.ReleaseWithinBounds + onTapped: missileEmitter.burst(1) } MultiButton { id: fightersButton label: "Launch Fighters" Layout.fillWidth: true - gesturePolicy: TapHandler.ReleaseWithinBounds + gesturePolicy: TapHandler.DragThreshold } } ParticleSystem { @@ -90,6 +91,6 @@ Item { anchors.right: parent.right anchors.rightMargin: 100 ImageParticle { source: "resources/missile.png"; autoRotation: true; rotation: 90 } - Emitter { anchors.bottom: parent.bottom; enabled: missilesButton.pressed; lifeSpan: 5000; size: 128 - emitRate: 10; velocity: PointDirection { x: -200; y: -350; yVariation: 200; xVariation: 100 } } } + Emitter { id: missileEmitter; anchors.bottom: parent.bottom; lifeSpan: 5000; size: 128; + emitRate: 0; velocity: PointDirection { x: -200; y: -350; yVariation: 200; xVariation: 100 } } } } -- cgit v1.2.3 From 54bb88bc99a0ea3966b6bde2ba06e4ece237a32c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 21 Feb 2017 17:02:08 +0100 Subject: add ScrollBar manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It demonstrates that DragHandler's grabs work well enough, so that you can grab the knob and drag it even while the cursor goes outside the window. Also the TapHandler for detecting clicks or taps within the "trough". And for completeness, the FakeFlickable example needed scrollbars, to prove that it's possible to build all the flicking and scrolling behaviors with only PointerHandlers. Change-Id: I9d9323b1f583a02e0157edb85b6bffbe1652711f Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/ScrollBar.qml | 160 +++++++++++++++++++++++++++++ tests/manual/pointer/fakeFlickable.qml | 29 ++++++ tests/manual/pointer/qml.qrc | 1 + 3 files changed, 190 insertions(+) create mode 100644 tests/manual/pointer/content/ScrollBar.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/ScrollBar.qml b/tests/manual/pointer/content/ScrollBar.qml new file mode 100644 index 0000000000..94d5ae47a7 --- /dev/null +++ b/tests/manual/pointer/content/ScrollBar.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 + +Rectangle { + id: root + property real contentHeight: 100 + property FakeFlickable flick: null + property real position + + onPositionChanged: if (flick && (drag.active || tap.active)) { + if (knob.state === "horizontal") + flick.contentX = position * knob.scrollDistance + else if (knob.state === "vertical") + flick.contentY = position * knob.scrollDistance + } + + SystemPalette { id: palette } + + color: palette.button + border.color: Qt.darker(palette.button, 1.5) + gradient: Gradient { + GradientStop { position: 0; color: Qt.darker(palette.button, 1.3) } + GradientStop { position: 1; color: palette.button } + } + antialiasing: true + radius: Math.min(width, height) / 6 + width: 20 + height: 20 + + TapHandler { + id: tap + onTapped: { + if (knob.state === "horizontal") + knob.x = pos.x - knob.width / 2 + else if (knob.state === "vertical") + knob.y = pos.y - knob.height / 2 + } + } + + Rectangle { + id: knob + border.color: "black" + border.width: 1 + gradient: Gradient { + GradientStop { position: 0; color: palette.button } + GradientStop { position: 1; color: Qt.darker(palette.button, 1.3) } + } + radius: 2 + antialiasing: true + state: root.height > root.width ? "vertical" : root.height < root.width ? "horizontal" : "" + property real scrollDistance: 0 + property real scrolledX: 0 + property real scrolledY: 0 + property real max: 0 + + Binding on x { + value: knob.scrolledX + when: !drag.active + } + + Binding on y { + value: knob.scrolledY + when: !drag.active + } + + states: [ + // We will control the horizontal. We will control the vertical. + State { + name: "horizontal" + PropertyChanges { + target: knob + max: root.width - knob.width + scrolledX: Math.min(max, Math.max(0, max * flick.contentX / (flick.width - flick.contentWidth))) + scrolledY: 1 + scrollDistance: flick.width - flick.contentWidth + width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2 + height: root.height - 2 + } + PropertyChanges { + target: drag + xAxis.minimum: 0 + xAxis.maximum: knob.max + yAxis.minimum: 1 + yAxis.maximum: 1 + } + PropertyChanges { + target: root + position: knob.x / drag.xAxis.maximum + } + }, + State { + name: "vertical" + PropertyChanges { + target: knob + max: root.height - knob.height + scrolledX: 1 + scrolledY: Math.min(max, Math.max(0, max * flick.contentY / (flick.height - flick.contentHeight))) + scrollDistance: flick.height - flick.contentHeight + width: root.width - 2 + height: root.width - 2 + } + PropertyChanges { + target: drag + xAxis.minimum: 1 + xAxis.maximum: 1 + yAxis.minimum: 0 + yAxis.maximum: knob.max + } + PropertyChanges { + target: root + position: knob.y / drag.yAxis.maximum + } + } + ] + + DragHandler { + id: drag + } + } +} diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml index 31e3d9f74c..22b23a00c8 100644 --- a/tests/manual/pointer/fakeFlickable.qml +++ b/tests/manual/pointer/fakeFlickable.qml @@ -48,7 +48,9 @@ Rectangle { height: 480 FakeFlickable { + id: ff anchors.fill: parent + anchors.rightMargin: rightSB.width Row { Item { width: 100 @@ -85,4 +87,31 @@ Rectangle { request.send() } } + + ScrollBar { + id: rightSB + objectName: "rightSB" + flick: ff + height: parent.height - width + anchors.right: parent.right + } + + ScrollBar { + id: bottomSB + objectName: "bottomSB" + flick: ff + width: parent.width - height + anchors.bottom: parent.bottom + } + + Rectangle { + id: cornerCover + color: "lightgray" + width: rightSB.width + height: bottomSB.height + anchors { + right: parent.right + bottom: parent.bottom + } + } } diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc index 5bb79176c7..68937a8c4a 100644 --- a/tests/manual/pointer/qml.qrc +++ b/tests/manual/pointer/qml.qrc @@ -19,6 +19,7 @@ content/MouseAreaSlider.qml content/MptaButton.qml content/MultiButton.qml + content/ScrollBar.qml content/Slider.qml content/TapHandlerButton.qml resources/arrowhead.png -- cgit v1.2.3 From 659317abee487c51837484208cc9e41061d3901f Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 9 Mar 2017 15:11:22 +0100 Subject: Red frame indicates that the item has an active handler Change-Id: I360063f3fe80eefb112b348d1b93f38d34416696 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/pinchHandler.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index f317f361e2..7f2f9bd70f 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -71,6 +71,8 @@ Rectangle { y: 200 rotation: 30 transformOrigin: Item.TopRight + border.width: pinch2.active ? 2 : 0 + border.color: pinch2.active ? "red" : "transparent" Text { anchors.centerIn: parent @@ -98,13 +100,18 @@ Rectangle { height: 300 color: "wheat" antialiasing: true + border.width: (dragHandler.active || pinch3.active) ? 2 : 0 + border.color: border.width > 0 ? "red" : "transparent" Text { anchors.centerIn: parent text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" + getTransformationDetails(rect3, pinch3) } - DragHandler { objectName: "DragHandler" } + DragHandler { + id: dragHandler + objectName: "DragHandler" + } PinchHandler { id: pinch3 -- cgit v1.2.3 From c2d6f267a74f7fdd9422af88e35ade280cf0a3d3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 31 Mar 2017 23:42:04 +0200 Subject: PinchHandler: add centroidVelocity Change-Id: I34cc9146155bded8311c1173e4b8d34d8b17b034 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/pinchHandler.qml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index 7f2f9bd70f..1d0a859564 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -40,6 +40,7 @@ import QtQuick 2.8 import Qt.labs.handlers 1.0 +import "content" Rectangle { width: 1024; height: 600 @@ -119,7 +120,13 @@ Rectangle { requiredPointCount: 3 minimumScale: 0.1 maximumScale: 10 + onActiveChanged: { + if (!active) + anim.restart(centroidVelocity) + } } + + MomentumAnimation { id: anim; target: rect3 } } } Rectangle { -- cgit v1.2.3 From 11034bd4ab4163797ae9e0dffd110217d2aafdaa Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sat, 15 Apr 2017 10:22:34 +0200 Subject: PH manual tests: better object names for easier debugging Change-Id: Icd5b9dc5fa00c98cc40b03e9d72f6b28fc51a579 Reviewed-by: Shawn Rutledge --- tests/manual/pointer/content/Slider.qml | 3 ++- tests/manual/pointer/flingAnimation.qml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index a1decf8c4b..44dea8e33b 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -92,13 +92,14 @@ Item { function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } DragHandler { id: dragHandler + objectName: label.text + " DragHandler" xAxis.enabled: false yAxis.minimum: slot.y yAxis.maximum: slot.height + slot.y - knob.height } TapHandler { id: tap - objectName: label.text + objectName: label.text + " TapHandler" gesturePolicy: TapHandler.DragThreshold onTapped: { tapFlash.start() diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml index 11b97dbb31..c8722fabb1 100644 --- a/tests/manual/pointer/flingAnimation.qml +++ b/tests/manual/pointer/flingAnimation.qml @@ -67,6 +67,7 @@ Rectangle { DragHandler { id: dragHandler + objectName: "dragHandler" + index onActiveChanged: { if (!active) anim.restart(velocity) -- cgit v1.2.3 From f569af401aae651ea9bfa1f3a8ff68a58f8d71d1 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 31 Mar 2017 18:36:53 +0200 Subject: QQuickPointerDeviceHandler: add acceptedModifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes you want to require holding down a key in order to enable some interaction. As with the other "accepted" flags, it's better to do this with a property than with Javascript. Change-Id: Ie29880f5f9f496ddca1bee462e2c0e6dd30fa9f5 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/pinchHandler.qml | 1 + tests/manual/pointer/tapWithModifiers.qml | 58 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/manual/pointer/tapWithModifiers.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml index 1d0a859564..71cdd98e4f 100644 --- a/tests/manual/pointer/pinchHandler.qml +++ b/tests/manual/pointer/pinchHandler.qml @@ -91,6 +91,7 @@ Rectangle { minimumX: 0 maximumX: 600 pointDistanceThreshold: 0 + // acceptedModifiers: Qt.ControlModifier } } diff --git a/tests/manual/pointer/tapWithModifiers.qml b/tests/manual/pointer/tapWithModifiers.qml new file mode 100644 index 0000000000..9a6977da1c --- /dev/null +++ b/tests/manual/pointer/tapWithModifiers.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 + +Item { + width: 200 + height: 200 + TapHandler { + acceptedModifiers: Qt.ControlModifier + onTapped: console.log("control-tapped") + } + TapHandler { + acceptedModifiers: Qt.NoModifier + onTapped: console.log("tapped with no modifiers") + } + TapHandler { + onTapped: console.log("tapped with modifiers " + point.event.modifiers) + } +} -- cgit v1.2.3 From 4ff6bb3edc18a251dd1395ff0cb6fd50a3d79abf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 31 Mar 2017 10:36:57 +0200 Subject: add pinchDragFlingMPTA example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a prototype of what 3-finger pinch is intended for: manipulating a container exclusively with a 3-finger gesture while not interfering at all with other gestures that occur inside the container. And it's normal that existing Items (like MPTA) do implicit grabs of touchpoints just by accepting, so this is also a test of cooperation between PointerHandlers and legacy Areas. It also adds the ability to drag the MPTA only while the Meta key is held down. And there is momentum on release whether you are doing a 3-finger pinch or via the DragHandler. Change-Id: Icd0e84809ec32dc8f347dd9c8f875d10f52eba19 Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/pinchDragFlingMPTA.qml | 97 +++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tests/manual/pointer/pinchDragFlingMPTA.qml (limited to 'tests/manual') diff --git a/tests/manual/pointer/pinchDragFlingMPTA.qml b/tests/manual/pointer/pinchDragFlingMPTA.qml new file mode 100644 index 0000000000..25be48bb42 --- /dev/null +++ b/tests/manual/pointer/pinchDragFlingMPTA.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 { + width: 1024; height: 600 + color: "beige" + objectName: "beige root" + + function getTransformationDetails(item, pinchhandler) { + return "scale:" + pinchhandler.scale.toFixed(2) + + " rotation:" + pinchhandler.rotation.toFixed(2) + + " translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + } + + Rectangle { + id: container + objectName: "container rect" + width: 600 + height: 500 + color: pinch3.active ? "red" : "black" + antialiasing: true + Loader { + source: "../touch/mpta-crosshairs.qml" + anchors.fill: parent + anchors.margins: 2 + } + Item { + anchors.fill: parent + // In order for PinchHandler to get a chance to take a passive grab, it has to get the touchpoints first. + // In order to get the touchpoints first, it has to be on top of the Z order: i.e. come last in paintOrderChildItems(). + // This is the opposite situation as with filtersChildMouseEvents: e.g. PinchArea would have wanted to be the parent, + // if it even knew that trick (which it doesn't). + PinchHandler { + id: pinch3 + objectName: "3-finger pinch" + target: container + requiredPointCount: 3 + minimumScale: 0.1 + maximumScale: 10 + onActiveChanged: if (!active) fling.restart(centroidVelocity) + } + DragHandler { + id: dragHandler + objectName: "DragHandler" + target: container + acceptedModifiers: Qt.MetaModifier + onActiveChanged: if (!active) fling.restart(velocity) + } + } + MomentumAnimation { id: fling; target: container } + } + Text { + anchors.bottom: parent.bottom + text: pinch3.active ? getTransformationDetails(container, pinch3) : "Pinch with 3 fingers to scale, rotate and translate" + } +} -- cgit v1.2.3 From b7f9f342480c669780a244c237642edaf5b57bc3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 27 Apr 2017 12:16:20 +0200 Subject: QQMultiPointerHandler: don't steal grab if keepMouseGrab/keepTouchGrab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An Item (such as MPTA with onGestureStarted: gesture.grab()) may set these flags, traditionally to prevent Flickable from stealing the grab. QQuickMultiPointerHandler (and thus PinchHandler) now respects these flags too. Change-Id: Iac3ab796c5aa410be45639d679ecf82b7c44a442 Reviewed-by: Jan Arve Sæther --- tests/manual/touch/mpta-crosshairs.qml | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/manual') diff --git a/tests/manual/touch/mpta-crosshairs.qml b/tests/manual/touch/mpta-crosshairs.qml index d1dbd0f188..efea16029b 100644 --- a/tests/manual/touch/mpta-crosshairs.qml +++ b/tests/manual/touch/mpta-crosshairs.qml @@ -50,6 +50,7 @@ Rectangle { MultiPointTouchArea { id: mpta anchors.fill: parent + //onGestureStarted: gesture.grab() // in case this is embedded in something that might steal touchPoints: [ TouchPoint { property color color: "red" }, TouchPoint { property color color: "orange" }, -- cgit v1.2.3 From 47479c0e969a3b3d220c77b8bb7cb8f2d58c07ae Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 24 Apr 2017 08:51:47 +0200 Subject: DragHandler: allow parent to be different from target The most obvious way to implement a Slider is to allow dragging the knob - as on a real-world physical sliding potentiometer. But to make it easier on a touchscreen, it should be possible to touch anywhere along the slider's travel, as on a QtQuick.Controls 2 Slider. For that purpose, we need to respond to events within the bounds of one Item while actually dragging a different Item (the knob). It's similar to the way that PinchHandler can handle pinch gestures within one Item while transforming another (which may be too small to get both fingers inside). Change-Id: Iac9a5f11a7a45e22d93fe52bf62d157c48d72d3d Reviewed-by: Shawn Rutledge --- tests/manual/pointer/content/Slider.qml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index 44dea8e33b..ecf45c02f3 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -50,6 +50,15 @@ Item { property alias pressed: tap.isPressed signal tapped + DragHandler { + id: dragHandler + objectName: label.text + " DragHandler" + target: knob + xAxis.enabled: false + yAxis.minimum: slot.y + yAxis.maximum: slot.height + slot.y - knob.height + } + Rectangle { id: slot anchors.top: parent.top @@ -90,13 +99,6 @@ Item { onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier transformOrigin: Item.Center function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } - DragHandler { - id: dragHandler - objectName: label.text + " DragHandler" - xAxis.enabled: false - yAxis.minimum: slot.y - yAxis.maximum: slot.height + slot.y - knob.height - } TapHandler { id: tap objectName: label.text + " TapHandler" -- cgit v1.2.3 From 80e5e6976afe4425cc8fd22c010fcf039c5b4b91 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 28 Apr 2017 10:38:52 +0200 Subject: tst_flickableinterop: test buttons with all gesturePolicy values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If3d9e10bb54fc75a7e72bc6367de3e083611a45f Reviewed-by: Jan Arve Sæther --- tests/manual/pointer/content/Slider.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index ecf45c02f3..809e4c5f1c 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -82,7 +82,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: dragHandler.active || tapFlash.running ? 1 : 0 + opacity: tap.isPressed || tapFlash.running ? 1 : 0 FlashAnimation on visible { id: tapFlash } -- cgit v1.2.3 From 057fc4b5b037284ffe299a28725fcf59c7ac066f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 27 Apr 2017 11:11:49 +0200 Subject: FakeFlickable: animate returnToBounds() when flicking is done It looks much nicer than just jerking back into position. We still don't have "resistance" to dragging past the bounds, though. Change-Id: I60f6f58fe87638fd17144ea6640bae673a3b633d Reviewed-by: Shawn Rutledge --- tests/manual/pointer/content/FakeFlickable.qml | 49 +++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml index bfae653503..801b6b9f31 100644 --- a/tests/manual/pointer/content/FakeFlickable.qml +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -62,14 +62,23 @@ Item { property real ylimit: root.height - __contentItem.height function returnToBounds() { - if (x > 0) - x = 0 - else if (x < xlimit) - x = xlimit - if (y > 0) - y = 0 - else if (y < ylimit) - y = ylimit + var startAnim = false + if (x > 0) { + returnToBoundsAnim.x = 0 + startAnim = true + } else if (x < xlimit) { + returnToBoundsAnim.x = xlimit + startAnim = true + } + if (y > 0) { + returnToBoundsAnim.y = 0 + startAnim = true + } else if (y < ylimit) { + returnToBoundsAnim.y = ylimit + startAnim = true + } + if (startAnim) + returnToBoundsAnim.start() } DragHandler { @@ -85,5 +94,29 @@ Item { root.flickEnded() } } + ParallelAnimation { + id: returnToBoundsAnim + property Item target: __contentItem + property int duration: 200 + property real x: 0 + property real y: 0 + + NumberAnimation { + id: xAnim + target: returnToBoundsAnim.target + property: "x" + to: returnToBoundsAnim.x + duration: returnToBoundsAnim.duration + easing.type: Easing.OutQuad + } + NumberAnimation { + id: yAnim + target: returnToBoundsAnim.target + property: "y" + to: returnToBoundsAnim.y + duration: returnToBoundsAnim.duration + easing.type: Easing.OutQuad + } + } } } -- cgit v1.2.3 From 5d4f488bf30f5650051d6cc226a75dbd17cd9a70 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 24 Feb 2017 16:42:47 +0100 Subject: Move properties into grouped "point" property Change-Id: I80000110a2e0ca69210322a0fcc587d86158358e Reviewed-by: Shawn Rutledge --- tests/manual/pointer/content/FakeFlickable.qml | 2 +- tests/manual/pointer/content/ScrollBar.qml | 4 +-- tests/manual/pointer/fakeFlickable.qml | 2 +- tests/manual/pointer/flingAnimation.qml | 2 +- tests/manual/pointer/photosurface.qml | 2 +- tests/manual/pointer/pinchDragFlingMPTA.qml | 2 +- .../pointer/singlePointHandlerProperties.qml | 37 +++++++++++----------- tests/manual/pointer/tapHandler.qml | 24 +++++++------- 8 files changed, 39 insertions(+), 36 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml index 801b6b9f31..55dafef82e 100644 --- a/tests/manual/pointer/content/FakeFlickable.qml +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -83,7 +83,7 @@ Item { DragHandler { id: dragHandler - onActiveChanged: if (!active) anim.restart(velocity) + onActiveChanged: if (!active) anim.restart(point.velocity) } MomentumAnimation { id: anim diff --git a/tests/manual/pointer/content/ScrollBar.qml b/tests/manual/pointer/content/ScrollBar.qml index 94d5ae47a7..ef18ceb98f 100644 --- a/tests/manual/pointer/content/ScrollBar.qml +++ b/tests/manual/pointer/content/ScrollBar.qml @@ -71,9 +71,9 @@ Rectangle { id: tap onTapped: { if (knob.state === "horizontal") - knob.x = pos.x - knob.width / 2 + knob.x = position.x - knob.width / 2 else if (knob.state === "vertical") - knob.y = pos.y - knob.height / 2 + knob.y = position.y - knob.height / 2 } } diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml index 22b23a00c8..0c6dbe4558 100644 --- a/tests/manual/pointer/fakeFlickable.qml +++ b/tests/manual/pointer/fakeFlickable.qml @@ -75,7 +75,7 @@ Rectangle { onFlickStarted: console.log("flick started with velocity " + velocity) - onFlickEnded: console.log("flick ended") + onFlickEnded: console.log("flick ended with velocity " + velocity) Component.onCompleted: { var request = new XMLHttpRequest() diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml index c8722fabb1..d868fcc498 100644 --- a/tests/manual/pointer/flingAnimation.qml +++ b/tests/manual/pointer/flingAnimation.qml @@ -70,7 +70,7 @@ Rectangle { objectName: "dragHandler" + index onActiveChanged: { if (!active) - anim.restart(velocity) + anim.restart(point.velocity) } } Rectangle { diff --git a/tests/manual/pointer/photosurface.qml b/tests/manual/pointer/photosurface.qml index 6601909a37..a2e8b2aede 100644 --- a/tests/manual/pointer/photosurface.qml +++ b/tests/manual/pointer/photosurface.qml @@ -110,7 +110,7 @@ Rectangle { id: dragHandler onActiveChanged: { if (!active) - anim.restart(velocity) + anim.restart(point.velocity) } } diff --git a/tests/manual/pointer/pinchDragFlingMPTA.qml b/tests/manual/pointer/pinchDragFlingMPTA.qml index 25be48bb42..6446a17873 100644 --- a/tests/manual/pointer/pinchDragFlingMPTA.qml +++ b/tests/manual/pointer/pinchDragFlingMPTA.qml @@ -85,7 +85,7 @@ Rectangle { objectName: "DragHandler" target: container acceptedModifiers: Qt.MetaModifier - onActiveChanged: if (!active) fling.restart(velocity) + onActiveChanged: if (!active) fling.restart(point.velocity) } } MomentumAnimation { id: fling; target: container } diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml index f5a938e401..f91094ee9e 100644 --- a/tests/manual/pointer/singlePointHandlerProperties.qml +++ b/tests/manual/pointer/singlePointHandlerProperties.qml @@ -49,11 +49,11 @@ Rectangle { Item { id: crosshairs - x: dragHandler.pos.x - width / 2 - y: dragHandler.pos.y - height / 2 + x: dragHandler.point.position.x - width / 2 + y: dragHandler.point.position.y - height / 2 width: parent.width / 2; height: parent.height / 2 visible: dragHandler.active - rotation: dragHandler.rotation + rotation: dragHandler.point.rotation Rectangle { color: "goldenrod" @@ -69,7 +69,7 @@ Rectangle { } Rectangle { color: "goldenrod" - width: Math.max(2, 50 * dragHandler.pressure) + width: Math.max(2, 50 * dragHandler.point.pressure) height: width radius: width / 2 anchors.centerIn: parent @@ -82,8 +82,8 @@ Rectangle { implicitHeight: label.implicitHeight Text { id: label - text: 'id: ' + dragHandler.pointId.toString(16) + " uid: " + dragHandler.uniquePointId.numericId + - '\npos: (' + dragHandler.pos.x.toFixed(2) + ', ' + dragHandler.pos.y.toFixed(2) + ')' + text: 'id: ' + dragHandler.point.id.toString(16) + " uid: " + dragHandler.point.uniqueId.numericId + + '\npos: (' + dragHandler.point.position.x.toFixed(2) + ', ' + dragHandler.point.position.y.toFixed(2) + ')' } } } @@ -91,8 +91,8 @@ Rectangle { color: "transparent" border.color: "white" antialiasing: true - width: dragHandler.ellipseDiameters.width - height: dragHandler.ellipseDiameters.height + width: dragHandler.point.ellipseDiameters.width + height: dragHandler.point.ellipseDiameters.height radius: Math.min(width / 2, height / 2) anchors.centerIn: parent } @@ -100,11 +100,11 @@ Rectangle { Rectangle { id: velocityVector visible: width > 0 - width: dragHandler.velocity.length() * 100 + width: dragHandler.point.velocity.length() * 100 height: 2 - x: dragHandler.pos.x - y: dragHandler.pos.y - rotation: Math.atan2(dragHandler.velocity.y, dragHandler.velocity.x) * 180 / Math.PI + x: dragHandler.point.position.x + y: dragHandler.point.position.y + rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI transformOrigin: Item.BottomLeft antialiasing: true @@ -150,13 +150,14 @@ Rectangle { DragHandler { id: dragHandler target: null - onGrabChanged: if (active) { - console.log("grabbed " + point.pointId + " @ " + sceneGrabPos) - grabbingLocationIndicator.createObject(root, {"x": sceneGrabPos.x, "y": sceneGrabPos.y - 16}) + onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance + console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos) + grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPos.x, "y": point.sceneGrabPos.y - 16}) } - onPressedButtonsChanged: { - if (pressedButtons) - mouseButtonIndicator.createObject(root, {"x": pressPos.x - 44, "y": pressPos.y - 64, "buttons": pressedButtons}) + onPointChanged: { + // Here, 'point' is referring to the property of the DragHandler + if (point.pressedButtons) + mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons}) } } } diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index 06070a02ff..5dac99a899 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -60,17 +60,13 @@ Item { gesturePolicy: (policyDragThresholdCB.checked ? TapHandler.DragThreshold : policyWithinBoundsCB.checked ? TapHandler.WithinBounds : TapHandler.ReleaseWithinBounds) - onPressedButtonsChanged: switch (pressedButtons) { - case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break; - case Qt.RightButton: borderBlink.blinkColor = "magenta"; break; - default: borderBlink.blinkColor = "green"; break; - } + onCanceled: { - console.log("canceled @ " + pos) + console.log("canceled @ " + point.position) borderBlink.blinkColor = "red" borderBlink.start() } - onTapped: { + onTapped: { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance console.log("tapped @ " + point.pos + " button(s) " + point.event.button + " tapCount " + tapCount) if (tapCount > 1) { tapCountLabel.text = tapCount @@ -80,7 +76,7 @@ Item { } } onLongPressed: longPressFeedback.createObject(rect, - {"x": pos.x, "y": pos.y, + {"x": point.position.x, "y": point.position.y, "text": Math.round(handler.timeHeld).toFixed(3) + " sec", "color": borderBlink.blinkColor}) } @@ -121,8 +117,8 @@ Item { color: "transparent" width: radius * 2 height: radius * 2 - x: handler.pressPos.x - radius - y: handler.pressPos.y - radius + x: handler.point.pressPosition.x - radius + y: handler.point.pressPosition.y - radius opacity: 0.25 } @@ -133,7 +129,13 @@ Item { SequentialAnimation { id: borderBlink - property color blinkColor: "blue" + property color blinkColor: (function(pbtns) { + switch (pbtns) { + case Qt.MiddleButton: return "orange"; + case Qt.RightButton: return "magenta"; + default: return "green"; + } + })(handler.point.pressedButtons) loops: 3 ScriptAction { script: rect.border.color = borderBlink.blinkColor } PauseAnimation { duration: 100 } -- cgit v1.2.3