aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-09-06 21:40:18 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-09-29 00:19:19 +0200
commit5bac7893599ab3f2ac28076763f091e46f32f8e7 (patch)
tree6e2d737cbfce313565c35c5f8280f1c75b120102 /examples/quick
parent7d7cd23ae3a4d9be4f6e117c1d922526ff27c440 (diff)
Move most of the pointer manual tests to a new pointerhandlers example
They were always meant to be examples eventually. Now they will be used for an example of how to implement custom controls using only basic items and handlers. Some components are very similar to those in the shared directory; but most examples will use Qt Quick Controls, so those shared components can be removed when we no longer use them. This example should remain as the one that shows how to build reusable controls "from scratch". Removed InputInspector because it's inefficient, has limited usefulness, tends to require building the manual test to be able to run it, and could be better built as a reusable Qt.labs component later on, providing a model with all known devices and taking advantage of the QPointingDevice::grabChanged signal to track the grab states rather than polling. Change-Id: I47ab6ebb2cecab07a69cf96e546ffd0db3026a60 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 8503f884bbdb50c4bebc8f8a9fce05275b0612b1)
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/CMakeLists.txt2
-rw-r--r--examples/quick/pointerhandlers/CMakeLists.txt84
-rw-r--r--examples/quick/pointerhandlers/components/Button.qml105
-rw-r--r--examples/quick/pointerhandlers/components/CheckBox.qml105
-rw-r--r--examples/quick/pointerhandlers/components/FakeFlickable.qml149
-rw-r--r--examples/quick/pointerhandlers/components/FlashAnimation.qml67
-rw-r--r--examples/quick/pointerhandlers/components/LeftDrawer.qml123
-rw-r--r--examples/quick/pointerhandlers/components/MomentumAnimation.qml81
-rw-r--r--examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml78
-rw-r--r--examples/quick/pointerhandlers/components/ScrollBar.qml167
-rw-r--r--examples/quick/pointerhandlers/components/Slider.qml159
-rw-r--r--examples/quick/pointerhandlers/components/TouchpointFeedbackSprite.qml72
-rw-r--r--examples/quick/pointerhandlers/components/images/checkmark.pngbin0 -> 809 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/fingersprite.pngbin0 -> 6792 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/mixer-knob.pngbin0 -> 7821 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/mouse.pngbin0 -> 1919 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/mouse_left.pngbin0 -> 740 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/mouse_middle.pngbin0 -> 558 bytes
-rw-r--r--examples/quick/pointerhandlers/components/images/mouse_right.pngbin0 -> 906 bytes
-rw-r--r--examples/quick/pointerhandlers/fakeFlickable.qml134
-rw-r--r--examples/quick/pointerhandlers/flingAnimation.qml148
-rw-r--r--examples/quick/pointerhandlers/images/arrowhead.pngbin0 -> 883 bytes
-rw-r--r--examples/quick/pointerhandlers/images/balloon.pngbin0 -> 3759 bytes
-rw-r--r--examples/quick/pointerhandlers/images/cursor-airbrush.pngbin0 -> 823 bytes
-rw-r--r--examples/quick/pointerhandlers/images/cursor-eraser.pngbin0 -> 1454 bytes
-rw-r--r--examples/quick/pointerhandlers/images/cursor-felt-marker.pngbin0 -> 513 bytes
-rw-r--r--examples/quick/pointerhandlers/images/cursor-pencil.pngbin0 -> 1307 bytes
-rw-r--r--examples/quick/pointerhandlers/images/fighter.pngbin0 -> 9669 bytes
-rw-r--r--examples/quick/pointerhandlers/images/grabbing-location.svg1
-rw-r--r--examples/quick/pointerhandlers/images/joystick-outer-case-pov.jpgbin0 -> 50687 bytes
-rw-r--r--examples/quick/pointerhandlers/images/map.svgzbin0 -> 27956 bytes
-rw-r--r--examples/quick/pointerhandlers/images/missile.pngbin0 -> 2305 bytes
-rw-r--r--examples/quick/pointerhandlers/images/redball.pngbin0 -> 10002 bytes
-rw-r--r--examples/quick/pointerhandlers/joystick.qml97
-rw-r--r--examples/quick/pointerhandlers/main.cpp51
-rw-r--r--examples/quick/pointerhandlers/map.qml135
-rw-r--r--examples/quick/pointerhandlers/mixer.qml81
-rw-r--r--examples/quick/pointerhandlers/multibuttons.qml118
-rw-r--r--examples/quick/pointerhandlers/pinchHandler.qml206
-rw-r--r--examples/quick/pointerhandlers/pointerhandlers.qml95
-rw-r--r--examples/quick/pointerhandlers/qml.qrc47
-rw-r--r--examples/quick/pointerhandlers/sidebar.qml222
-rw-r--r--examples/quick/pointerhandlers/singlePointHandlerProperties.qml186
-rw-r--r--examples/quick/pointerhandlers/tabletCanvasDrawing.qml251
-rw-r--r--examples/quick/pointerhandlers/tapHandler.qml222
-rw-r--r--examples/quick/pointerhandlers/tapWithModifiers.qml77
46 files changed, 3263 insertions, 0 deletions
diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt
index 734195e0f7..bf9c06e3c7 100644
--- a/examples/quick/CMakeLists.txt
+++ b/examples/quick/CMakeLists.txt
@@ -52,6 +52,8 @@ set(reused_dir_targets
window_shared
shapes_shared
imageelements_shared
+ delegatechooser_shared
+ pointerhandlers_shared
)
foreach(target IN LISTS reused_dir_targets)
if(TARGET ${target})
diff --git a/examples/quick/pointerhandlers/CMakeLists.txt b/examples/quick/pointerhandlers/CMakeLists.txt
new file mode 100644
index 0000000000..ca378d49e1
--- /dev/null
+++ b/examples/quick/pointerhandlers/CMakeLists.txt
@@ -0,0 +1,84 @@
+# Generated from pointer.pro.
+
+cmake_minimum_required(VERSION 3.16)
+project(pointerhandlers LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/pointerhandlers")
+
+find_package(Qt6 COMPONENTS Core Gui Quick Qml Svg)
+
+add_subdirectory("../shared" "shared")
+
+qt_add_executable(pointerhandlersexample WIN32 MACOSX_BUNDLE main.cpp)
+
+target_link_libraries(pointerhandlersexample PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+ Qt::Svg
+ pointerhandlers_shared
+)
+
+qt_add_qml_module(pointerhandlersexample
+ URI pointerhandlers
+ VERSION 1.0
+ QML_FILES
+ "components/Button.qml"
+ "components/CheckBox.qml"
+ "components/FakeFlickable.qml"
+ "components/FlashAnimation.qml"
+ "components/LeftDrawer.qml"
+ "components/MomentumAnimation.qml"
+ "components/MouseFeedbackSprite.qml"
+ "components/ScrollBar.qml"
+ "components/Slider.qml"
+ "components/TouchpointFeedbackSprite.qml"
+ "fakeFlickable.qml"
+ "flingAnimation.qml"
+ "joystick.qml"
+ "map.qml"
+ "mixer.qml"
+ "multibuttons.qml"
+ "pinchHandler.qml"
+ "pointerhandlers.qml"
+ "sidebar.qml"
+ "singlePointHandlerProperties.qml"
+ "tabletCanvasDrawing.qml"
+ "tapHandler.qml"
+ RESOURCES
+ "components/images/checkmark.png"
+ "components/images/fingersprite.png"
+ "components/images/mixer-knob.png"
+ "components/images/mouse.png"
+ "components/images/mouse_left.png"
+ "components/images/mouse_middle.png"
+ "components/images/mouse_right.png"
+ "images/arrowhead.png"
+ "images/balloon.png"
+ "images/cursor-airbrush.png"
+ "images/cursor-eraser.png"
+ "images/cursor-felt-marker.png"
+ "images/cursor-pencil.png"
+ "images/fighter.png"
+ "images/grabbing-location.svg"
+ "images/joystick-outer-case-pov.jpg"
+ "images/map.svgz"
+ "images/missile.png"
+ "images/redball.png"
+)
+
+install(TARGETS pointerhandlersexample
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+bundle_shared(pointerhandlersexample)
diff --git a/examples/quick/pointerhandlers/components/Button.qml b/examples/quick/pointerhandlers/components/Button.qml
new file mode 100644
index 0000000000..9ff3870d7b
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/Button.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+
+Rectangle {
+ id: root
+ property alias label: label
+ property alias text: label.text
+ property alias pressed: tap.pressed
+ property alias hovered: hoverHandler.hovered
+ property alias gesturePolicy: tap.gesturePolicy
+ property alias margin: tap.margin
+ signal tapped
+
+ implicitHeight: Math.max(Screen.pixelDensity * 7, label.implicitHeight * 2)
+ implicitWidth: Math.max(Screen.pixelDensity * 11, label.implicitWidth * 1.3)
+ height: implicitHeight
+ width: implicitWidth
+ radius: height / 6
+
+ border { color: Qt.darker(palette.button, 1.5); width: 1 }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: tap.pressed ? Qt.darker(palette.button, 1.3) : palette.button }
+ GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
+ }
+
+ TapHandler {
+ id: tap
+ margin: 10 // the user can tap a little beyond the edges
+ objectName: label.text + " Tap"
+ onTapped: {
+ tapFlash.start()
+ root.tapped()
+ }
+ }
+ HoverHandler {
+ id: hoverHandler
+ }
+
+ Text {
+ id: label
+ font.pointSize: 14
+ color: palette.buttonText
+ 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/examples/quick/pointerhandlers/components/CheckBox.qml b/examples/quick/pointerhandlers/components/CheckBox.qml
new file mode 100644
index 0000000000..bcd9ad99db
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/CheckBox.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+
+Item {
+ id: root
+ implicitHeight: frame.height
+ implicitWidth: row.implicitWidth
+ width: implicitWidth
+ height: implicitHeight
+ property alias text: label.text
+ property bool checked
+
+ property alias pressed: tapHandler.pressed
+ property alias row: row
+ signal clicked
+
+ Row {
+ id: row
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: 6
+ Rectangle {
+ id: frame
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: tapHandler.pressed ? Qt.darker(palette.button, 1.3) : palette.button }
+ GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
+ }
+ height: label.implicitHeight * 1.5
+ width: height
+ anchors.margins: 1
+ radius: 3
+ antialiasing: true
+ border.color: Qt.darker(palette.button, 1.5)
+ Image {
+ id: theX
+ source: "images/checkmark.png"
+ anchors.fill: frame
+ anchors.margins: frame.width / 5
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ visible: root.checked
+ }
+ }
+ Text {
+ id: label
+ color: palette.text
+ anchors.verticalCenter: frame.verticalCenter
+ }
+ }
+ TapHandler {
+ id: tapHandler
+ onTapped: {
+ parent.checked = !parent.checked
+ parent.clicked()
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/FakeFlickable.qml b/examples/quick/pointerhandlers/components/FakeFlickable.qml
new file mode 100644
index 0000000000..2857d066aa
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/FakeFlickable.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.14
+import Qt.labs.animation 1.0
+
+Item {
+ id: root
+ objectName: "viewport"
+ 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
+
+ BoundaryRule on x {
+ id: xbr
+ minimum: root.width - __contentItem.width
+ maximum: 0
+ minimumOvershoot: 100
+ maximumOvershoot: 100
+ overshootFilter: BoundaryRule.Peak
+ }
+
+ BoundaryRule on y {
+ id: ybr
+ minimum: root.height - __contentItem.height
+ maximum: 0
+ minimumOvershoot: 100
+ maximumOvershoot: 100
+ overshootFilter: BoundaryRule.Peak
+ }
+
+ DragHandler {
+ id: dragHandler
+ onActiveChanged:
+ if (active) {
+ anim.stop()
+ root.flickStarted()
+ } else {
+ var vel = centroid.velocity
+ if (xbr.returnToBounds())
+ vel.x = 0
+ if (ybr.returnToBounds())
+ vel.y = 0
+ if (vel.x !== 0 || vel.y !== 0)
+ anim.restart(vel)
+ else
+ root.flickEnded()
+ }
+ }
+ WheelHandler {
+ rotationScale: 15
+ property: "x"
+ orientation: Qt.Horizontal
+ acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
+ onActiveChanged:
+ // emitting signals in both instances is redundant but hard to avoid
+ // when the touchpad is flicking along both axes
+ if (active) {
+ anim.stop()
+ root.flickStarted()
+ } else {
+ xbr.returnToBounds()
+ root.flickEnded()
+ }
+ }
+ WheelHandler {
+ rotationScale: 15
+ property: "y"
+ orientation: Qt.Vertical
+ acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
+ onActiveChanged:
+ if (active) {
+ anim.stop()
+ root.flickStarted()
+ } else {
+ ybr.returnToBounds()
+ root.flickEnded()
+ }
+ }
+ MomentumAnimation {
+ id: anim
+ target: __contentItem
+ onStarted: root.flickStarted()
+ onStopped: {
+ xbr.returnToBounds()
+ ybr.returnToBounds()
+ root.flickEnded()
+ }
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/FlashAnimation.qml b/examples/quick/pointerhandlers/components/FlashAnimation.qml
new file mode 100644
index 0000000000..047112d22c
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/FlashAnimation.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+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/examples/quick/pointerhandlers/components/LeftDrawer.qml b/examples/quick/pointerhandlers/components/LeftDrawer.qml
new file mode 100644
index 0000000000..5cf1420519
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/LeftDrawer.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+import Qt.labs.animation
+
+Item {
+ id: root
+ objectName: "LeftHandlerDrawer"
+ width: 100
+ height: 400
+ property real stickout: 4
+ property real xOpen: rect.radius * -2
+ property real xClosed: stickout - width
+ x: xClosed
+ y: 10
+
+ function close() {
+ openCloseAnimation.to = xClosed
+ openCloseAnimation.start()
+ }
+ function open() {
+ openCloseAnimation.to = xOpen
+ openCloseAnimation.start()
+ }
+
+ DragHandler {
+ id: dragHandler
+ yAxis.enabled: false
+ xAxis.minimum: -1000
+ margin: 20
+ onActiveChanged:
+ if (!active) {
+ if (xbr.returnToBounds())
+ return;
+ if (activeTranslation.x > 0)
+ open()
+ if (activeTranslation.x < 0)
+ close()
+ }
+ }
+
+ BoundaryRule on x {
+ id: xbr
+ minimum: xClosed
+ maximum: xOpen
+ minimumOvershoot: rect.radius
+ maximumOvershoot: rect.radius
+ }
+
+ NumberAnimation on x {
+ id: openCloseAnimation
+ duration: 300
+ easing { type: Easing.OutBounce; overshoot: 5 }
+ }
+
+ // TODO this was supposed to be RectangularGlow but we lost QtGraphicalEffects in Qt 6
+ Rectangle {
+ id: effect
+ anchors.fill: parent
+ border.width: dragHandler.margin
+ border.color: "cyan"
+ opacity: 0.2
+ radius: rect.radius + dragHandler.margin
+ }
+
+ Rectangle {
+ id: rect
+ anchors.fill: parent
+ anchors.margins: 3
+ color: "#333"
+ border.color: "cyan"
+ border.width: 2
+ radius: 10
+ antialiasing: true
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/MomentumAnimation.qml b/examples/quick/pointerhandlers/components/MomentumAnimation.qml
new file mode 100644
index 0000000000..03e1689317
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/MomentumAnimation.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+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 * 100
+ duration: root.duration
+ easing.type: Easing.OutQuad
+ }
+ NumberAnimation {
+ id: yAnim
+ target: root.target
+ property: "y"
+ to: target.y + velocity.y / duration * 100
+ duration: root.duration
+ easing.type: Easing.OutQuad
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
new file mode 100644
index 0000000000..4d6f1843c8
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+PointHandler {
+ id: handler
+ objectName: "mouse point"
+ acceptedDevices: PointerDevice.Mouse
+ acceptedButtons: Qt.AllButtons
+ target: Image {
+ objectName: "mouse sprite"
+ source: "images/mouse.png"
+ visible: handler.active
+ x: handler.point.position.x - width / 2
+ y: handler.point.position.y - height / 2
+ parent: handler.parent
+ Image {
+ source: "images/mouse_left.png"
+ visible: handler.point.pressedButtons & Qt.LeftButton
+ }
+ Image {
+ source: "images/mouse_middle.png"
+ visible: handler.point.pressedButtons & Qt.MiddleButton
+ }
+ Image {
+ source: "images/mouse_right.png"
+ visible: handler.point.pressedButtons & Qt.RightButton
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/ScrollBar.qml b/examples/quick/pointerhandlers/components/ScrollBar.qml
new file mode 100644
index 0000000000..f5cf27a0c5
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/ScrollBar.qml
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+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
+ }
+
+ 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 = position.x - knob.width / 2
+ else if (knob.state === "vertical")
+ knob.y = position.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/examples/quick/pointerhandlers/components/Slider.qml b/examples/quick/pointerhandlers/components/Slider.qml
new file mode 100644
index 0000000000..0365d01149
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/Slider.qml
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+import Qt.labs.animation
+
+Item {
+ id: root
+ property int value: 50
+ property int maximumValue: 99
+ property alias label: label.text
+ property alias tapEnabled: tap.enabled
+ property alias pressed: tap.pressed
+ signal tapped
+
+ DragHandler {
+ id: dragHandler
+ objectName: label.text + " DragHandler"
+ target: knob
+ xAxis.enabled: false
+ }
+
+ WheelHandler {
+ id: wheelHandler
+ objectName: label.text + " WheelHandler"
+ acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
+ invertible: false // Don't let the system "natural scrolling" setting affect this
+ rotationScale: -0.5 // But make it go consistently in the same direction as the fingers or wheel, a bit slow
+ target: knob
+ property: "y"
+ }
+
+ Rectangle {
+ id: slot
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ anchors.topMargin: label.height + 6
+ anchors.bottomMargin: valueLabel.height + 4
+ 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: tap.pressed || tapFlash.running ? 1 : 0
+ FlashAnimation on visible {
+ id: tapFlash
+ }
+ }
+ Image {
+ id: knob
+ source: "images/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 / (ybr.maximum - ybr.minimum)
+ onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - ybr.minimum) * multiplier
+ transformOrigin: Item.Center
+ function setValue(value) { knob.y = ybr.maximum - value / knob.multiplier }
+ TapHandler {
+ id: tap
+ objectName: label.text + " TapHandler"
+ gesturePolicy: TapHandler.DragThreshold
+ onTapped: {
+ tapFlash.start()
+ root.tapped
+ }
+ }
+ BoundaryRule on y {
+ id: ybr
+ minimum: slot.y
+ maximum: slot.height + slot.y - knob.height
+ }
+ }
+
+ Text {
+ id: valueLabel
+ 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/examples/quick/pointerhandlers/components/TouchpointFeedbackSprite.qml b/examples/quick/pointerhandlers/components/TouchpointFeedbackSprite.qml
new file mode 100644
index 0000000000..5a4f258b8c
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/TouchpointFeedbackSprite.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+PointHandler {
+ id: handler
+ objectName: "point " + handler.point.id.toString(16)
+ acceptedDevices: PointerDevice.TouchScreen | PointerDevice.TouchPad
+ target: AnimatedSprite {
+ objectName: "sprite " + handler.point.id.toString(16)
+ source: "images/fingersprite.png"
+ visible: handler.active
+ running: visible // QTBUG-64544: running defaults to true, but we don't see it animating if we don't toggle it like this
+ x: handler.point.position.x - 20
+ y: handler.point.position.y - 13
+ width: frameWidth
+ height: frameHeight
+ frameWidth: 43
+ frameHeight: 64
+ frameCount: 3
+ frameRate: 5
+ parent: handler.parent
+ }
+}
diff --git a/examples/quick/pointerhandlers/components/images/checkmark.png b/examples/quick/pointerhandlers/components/images/checkmark.png
new file mode 100644
index 0000000000..821aafccdd
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/checkmark.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/fingersprite.png b/examples/quick/pointerhandlers/components/images/fingersprite.png
new file mode 100644
index 0000000000..423d115fdf
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/fingersprite.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/mixer-knob.png b/examples/quick/pointerhandlers/components/images/mixer-knob.png
new file mode 100644
index 0000000000..b7d42ee3bd
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/mixer-knob.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/mouse.png b/examples/quick/pointerhandlers/components/images/mouse.png
new file mode 100644
index 0000000000..268946df0a
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/mouse.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/mouse_left.png b/examples/quick/pointerhandlers/components/images/mouse_left.png
new file mode 100644
index 0000000000..9292301b47
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/mouse_left.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/mouse_middle.png b/examples/quick/pointerhandlers/components/images/mouse_middle.png
new file mode 100644
index 0000000000..064e8b9c16
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/mouse_middle.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/components/images/mouse_right.png b/examples/quick/pointerhandlers/components/images/mouse_right.png
new file mode 100644
index 0000000000..cab1a36ba6
--- /dev/null
+++ b/examples/quick/pointerhandlers/components/images/mouse_right.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/fakeFlickable.qml b/examples/quick/pointerhandlers/fakeFlickable.qml
new file mode 100644
index 0000000000..b6be729e3c
--- /dev/null
+++ b/examples/quick/pointerhandlers/fakeFlickable.qml
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+import "components"
+
+Rectangle {
+ id: root
+ color: "#444"
+ width: 480
+ height: 640
+
+ FakeFlickable {
+ id: ff
+ anchors.fill: parent
+ anchors.leftMargin: 20
+ anchors.rightMargin: rightSB.width
+
+ 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: {
+ root.border.color = "green"
+ console.log("flick started with velocity " + velocity)
+ }
+ onFlickEnded: {
+ root.border.color = "transparent"
+ console.log("flick ended with velocity " + velocity)
+ }
+
+ Component.onCompleted: {
+ var request = new XMLHttpRequest()
+ request.open('GET', 'components/FakeFlickable.qml')
+ request.onreadystatechange = function(event) {
+ if (request.readyState === XMLHttpRequest.DONE)
+ text.text = request.responseText
+ }
+ 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
+ }
+ }
+
+ LeftDrawer {
+ width: 100
+ anchors.verticalCenter: parent.verticalCenter
+ Slider {
+ id: slider
+ label: "font\nsize"
+ anchors.fill: parent
+ anchors.margins: 10
+ maximumValue: 36
+ value: 14
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/flingAnimation.qml b/examples/quick/pointerhandlers/flingAnimation.qml
new file mode 100644
index 0000000000..a2a6a0acd1
--- /dev/null
+++ b/examples/quick/pointerhandlers/flingAnimation.qml
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+import "components"
+
+Rectangle {
+ id: root
+ width: 640
+ height: 480
+ color: "black"
+
+ Repeater {
+ model: 2
+
+ Image {
+ id: ball
+ objectName: "ball" + index
+ source: "images/redball.png"
+ property real homeX: 200 + index * 200
+ property real homeY: 200
+ width: 80; height: 80; x: homeX; y: 200
+
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ text: momentum.velocity.x.toFixed(2) + "," + momentum.velocity.y.toFixed(2)
+ }
+
+ SequentialAnimation {
+ id: anim
+
+ function restart(vel) {
+ stop()
+ momentum.velocity = vel
+ start()
+ }
+
+ MomentumAnimation { id: momentum; target: ball }
+
+ PauseAnimation { duration: 500 }
+
+ ParallelAnimation {
+ id: ballReturn
+ NumberAnimation {
+ target: ball
+ property: "x"
+ to: homeX
+ duration: 1000
+ easing.period: 50
+ easing.type: Easing.OutElastic
+ }
+ NumberAnimation {
+ target: ball
+ property: "y"
+ to: homeY
+ duration: 1000
+ easing.type: Easing.OutElastic
+ }
+ }
+ }
+
+ DragHandler {
+ id: dragHandler
+ objectName: "dragHandler" + index
+ onActiveChanged: {
+ if (!active)
+ anim.restart(centroid.velocity)
+ }
+ }
+ Rectangle {
+ visible: dragHandler.active
+ anchors.fill: parent
+ anchors.margins: -5
+ radius: width / 2
+ opacity: 0.25
+ }
+
+ Rectangle {
+ visible: width > 0
+ width: dragHandler.centroid.velocity.length() / 10
+ height: 2
+ x: ball.width / 2
+ y: ball.height / 2
+ z: -1
+ rotation: Math.atan2(dragHandler.centroid.velocity.y, dragHandler.centroid.velocity.x) * 180 / Math.PI
+ transformOrigin: Item.BottomLeft
+ antialiasing: true
+
+ Image {
+ source: "images/arrowhead.png"
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ width: 16
+ height: 12
+ antialiasing: true
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/images/arrowhead.png b/examples/quick/pointerhandlers/images/arrowhead.png
new file mode 100644
index 0000000000..7719bc6d6a
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/arrowhead.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/balloon.png b/examples/quick/pointerhandlers/images/balloon.png
new file mode 100644
index 0000000000..6476facc49
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/balloon.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/cursor-airbrush.png b/examples/quick/pointerhandlers/images/cursor-airbrush.png
new file mode 100644
index 0000000000..bea756ed6f
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/cursor-airbrush.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/cursor-eraser.png b/examples/quick/pointerhandlers/images/cursor-eraser.png
new file mode 100644
index 0000000000..e5488a89f2
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/cursor-eraser.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/cursor-felt-marker.png b/examples/quick/pointerhandlers/images/cursor-felt-marker.png
new file mode 100644
index 0000000000..132f09aa39
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/cursor-felt-marker.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/cursor-pencil.png b/examples/quick/pointerhandlers/images/cursor-pencil.png
new file mode 100644
index 0000000000..cc2f447d02
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/cursor-pencil.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/fighter.png b/examples/quick/pointerhandlers/images/fighter.png
new file mode 100644
index 0000000000..2acee43cba
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/fighter.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/grabbing-location.svg b/examples/quick/pointerhandlers/images/grabbing-location.svg
new file mode 100644
index 0000000000..c26881e9ba
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/grabbing-location.svg
@@ -0,0 +1 @@
+<svg width="3408" height="3124"><path d="M1517 1562c0-126-93-229-208-229s-208 102-208 229c0 126 93 229 208 229s208-102 208-229zm123-172c-58-206-221-365-424-412l-270 531H380l203-223 219-241 346-380c42 14 82 32 121 54 232 128 402 375 449 671h-77zm-551-933c448 123 782 546 802 1055h1517C3386 673 2787 0 2050 0H696L0 1367h120l826-938 146 25c-1 1-2 2-3 4zm551 1277c-58 206-221 365-424 412l-270-531H380l203 223 219 241 346 380c42-14 82-32 121-54 232-128 402-375 449-671h-77zm-548 936l-146 25-826-938H0l696 1367h1354c737 0 1337-673 1358-1512H1891c-19 509-354 933-802 1055 1 1 2 2 3 4z" fill="#ee832b"/></svg>
diff --git a/examples/quick/pointerhandlers/images/joystick-outer-case-pov.jpg b/examples/quick/pointerhandlers/images/joystick-outer-case-pov.jpg
new file mode 100644
index 0000000000..01cd78fdcf
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/joystick-outer-case-pov.jpg
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/map.svgz b/examples/quick/pointerhandlers/images/map.svgz
new file mode 100644
index 0000000000..64d509c106
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/map.svgz
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/missile.png b/examples/quick/pointerhandlers/images/missile.png
new file mode 100644
index 0000000000..72c02d1fb9
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/missile.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/images/redball.png b/examples/quick/pointerhandlers/images/redball.png
new file mode 100644
index 0000000000..68d2e1d638
--- /dev/null
+++ b/examples/quick/pointerhandlers/images/redball.png
Binary files differ
diff --git a/examples/quick/pointerhandlers/joystick.qml b/examples/quick/pointerhandlers/joystick.qml
new file mode 100644
index 0000000000..c0445a5e21
--- /dev/null
+++ b/examples/quick/pointerhandlers/joystick.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+Item {
+ width: image.implicitWidth; height: image.implicitHeight
+ Image {
+ id: image
+ anchors.centerIn: parent
+ source: "images/joystick-outer-case-pov.jpg"
+ property real margin: 50
+
+ Image {
+ id: knob
+ source: "images/redball.png"
+ DragHandler {
+ id: dragHandler
+ xAxis {
+ minimum: image.margin
+ maximum: image.width - image.margin - knob.width
+ }
+ yAxis {
+ minimum: image.margin
+ maximum: image.height - image.margin - knob.height
+ }
+ }
+
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ states: [
+ State {
+ when: dragHandler.active
+ AnchorChanges {
+ target: knob
+ anchors.horizontalCenter: undefined
+ anchors.verticalCenter: undefined
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ AnchorAnimation { easing.type: Easing.OutElastic }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/main.cpp b/examples/quick/pointerhandlers/main.cpp
new file mode 100644
index 0000000000..c2c98b96d6
--- /dev/null
+++ b/examples/quick/pointerhandlers/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 "../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(pointerhandlers/pointerhandlers)
diff --git a/examples/quick/pointerhandlers/map.qml b/examples/quick/pointerhandlers/map.qml
new file mode 100644
index 0000000000..f54319f8aa
--- /dev/null
+++ b/examples/quick/pointerhandlers/map.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+
+Item {
+ width: 640
+ height: 480
+
+ Rectangle {
+ id: map
+ color: "aqua"
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: image.width
+ height: image.height
+ transform: Rotation {
+ id: tilt
+ origin.x: width / 2
+ origin.y: height / 2
+ axis { x: 1; y: 0; z: 0 }
+ angle: tiltHandler.persistentTranslation.y / -2
+ }
+
+ WheelHandler {
+ id: wheelHandler
+ objectName: "vertical mouse wheel for scaling"
+ property: "scale"
+ onWheel: function(event) {
+ console.log("rotation " + event.angleDelta + " scaled " + rotation + " @ " + point.position + " => " + map.scale)
+ }
+ }
+
+ WheelHandler {
+ id: horizontalWheelHandler
+ objectName: "horizontal mouse wheel for side-scrolling"
+ property: "x"
+ orientation: Qt.Horizontal
+ }
+
+ Image {
+ id: image
+ anchors.centerIn: parent
+ fillMode: Image.PreserveAspectFit
+ source: "images/map.svgz"
+ Component.onCompleted: { width = implicitWidth; height = implicitHeight }
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: image.sourceSize.width + " x " + image.sourceSize.height +
+ " scale " + map.scale.toFixed(2) + " active scale " + pinch.activeScale.toFixed(2)
+ }
+ }
+
+ DragHandler {
+ objectName: "single-point drag"
+ target: map
+ }
+
+ DragHandler {
+ id: tiltHandler
+ objectName: "two-point tilt"
+ minimumPointCount: 2
+ maximumPointCount: 2
+ xAxis.enabled: false
+ target: null
+ }
+
+ PinchHandler {
+ id: pinch
+ objectName: "two-point pinch"
+ target: map
+ minimumScale: 0.1
+ maximumScale: 10
+ xAxis.enabled: false
+ yAxis.enabled: false
+ onActiveChanged: if (!active) reRenderIfNecessary()
+ grabPermissions: PinchHandler.TakeOverForbidden // don't allow takeover if pinch has started
+ }
+
+ function reRenderIfNecessary() {
+ var newSourceWidth = image.sourceSize.width * pinch.scale
+ var ratio = newSourceWidth / image.sourceSize.width
+ if (ratio > 1.1 || ratio < 0.9)
+ image.sourceSize.width = newSourceWidth
+ }
+}
diff --git a/examples/quick/pointerhandlers/mixer.qml b/examples/quick/pointerhandlers/mixer.qml
new file mode 100644
index 0000000000..39cc2974d7
--- /dev/null
+++ b/examples/quick/pointerhandlers/mixer.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+import "components"
+
+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/examples/quick/pointerhandlers/multibuttons.qml b/examples/quick/pointerhandlers/multibuttons.qml
new file mode 100644
index 0000000000..a3a4e21771
--- /dev/null
+++ b/examples/quick/pointerhandlers/multibuttons.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+import QtQuick.Particles
+import QtQuick.Layouts
+import "components"
+
+Item {
+ width: 800
+ height: 800
+ ColumnLayout {
+ anchors.right: parent.right
+ anchors.margins: 20
+ spacing: 20
+ Text { text: "protagonist"; font.pointSize: 12; font.weight: Font.Bold; bottomPadding: -10 }
+ Button {
+ id: balloonsButton
+ text: "Launch Balloons"
+ Layout.fillWidth: true
+ gesturePolicy: TapHandler.WithinBounds
+ Text {
+ anchors { top: parent.bottom; horizontalCenter: parent.horizontalCenter }
+ text: "gesturePolicy: WithinBounds"
+ }
+ }
+ Text { text: "the goons"; font.pointSize: 12; font.weight: Font.Bold; bottomPadding: -10 }
+ Button {
+ id: missilesButton
+ text: "Launch Missile"
+ Layout.fillWidth: true
+ gesturePolicy: TapHandler.ReleaseWithinBounds
+ onTapped: missileEmitter.burst(1)
+ Text {
+ anchors { top: parent.bottom; horizontalCenter: parent.horizontalCenter }
+ text: "gesturePolicy: ReleaseWithinBounds"
+ }
+ }
+ Button {
+ id: fightersButton
+ text: "Launch Fighters"
+ Layout.fillWidth: true
+ gesturePolicy: TapHandler.DragThreshold
+ Text {
+ anchors { top: parent.bottom; horizontalCenter: parent.horizontalCenter }
+ text: "gesturePolicy: DragThreshold"
+ }
+ }
+ }
+ ParticleSystem {
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: 150
+ ImageParticle { source: "images/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: "images/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: "images/missile.png"; autoRotation: true; rotation: 90 }
+ Emitter { id: missileEmitter; anchors.bottom: parent.bottom; lifeSpan: 5000; size: 128;
+ emitRate: 0; velocity: PointDirection { x: -200; y: -350; yVariation: 200; xVariation: 100 } } }
+}
diff --git a/examples/quick/pointerhandlers/pinchHandler.qml b/examples/quick/pointerhandlers/pinchHandler.qml
new file mode 100644
index 0000000000..a4477b0af0
--- /dev/null
+++ b/examples/quick/pointerhandlers/pinchHandler.qml
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+import "components"
+
+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) + ")"
+ }
+
+ function activePincher() {
+ if (grandparentPinch.active)
+ return grandparentPinch
+ else if (parentPinch.active)
+ return parentPinch
+ else if (pinch2.active)
+ return pinch2
+ return pinch3 // always return a pinch handler, even when its inactive. The indicator will be invisble anyway.
+ }
+
+ Rectangle {
+ width: parent.width - 100; height: parent.height - 100; x: 50; y: 50
+ color: "beige"
+ border.width: grandparentPinch.active ? 2 : 0
+ border.color: border.width > 0 ? "red" : "transparent"
+ antialiasing: true
+
+ PinchHandler {
+ id: grandparentPinch
+ objectName: "grandparent pinch"
+ minimumScale: 0.5
+ maximumScale: 3
+ minimumPointCount: 3
+ maximumPointCount: 6 // mutants are allowed; using both hands is not normal for a pinch gesture, but we can't tell
+ }
+
+ Text {
+ text: "Pinch with 3 or more fingers to scale, rotate and translate"
+ + getTransformationDetails(parent, grandparentPinch)
+ }
+
+ Rectangle {
+ width: parent.width - 100; height: parent.height - 100; x: 50; y: 50
+ color: "#ffe0e0e0"
+ antialiasing: true
+
+ PinchHandler {
+ id: parentPinch
+ objectName: "parent pinch"
+ minimumScale: 0.5
+ maximumScale: 3
+ }
+
+ Text {
+ text: "Pinch with 2 fingers to scale, rotate and translate"
+ + getTransformationDetails(parent, parentPinch)
+ }
+
+ Rectangle {
+ id: rect2
+ width: 400
+ height: 300
+ color: "lightsteelblue"
+ antialiasing: true
+ x: 100
+ y: 200
+ rotation: 30
+ transformOrigin: Item.TopRight
+ border.width: (lsbDragHandler.active || pinch2.active) ? 2 : 0
+ border.color: border.width > 0 ? "red" : "transparent"
+
+ Text {
+ anchors.centerIn: parent
+ text: "Pinch with 2 fingers to scale, rotate and translate\nDrag with 1 finger"
+ + getTransformationDetails(rect2, pinch2) + "\nz " + rect2.z
+ }
+ DragHandler {
+ id: lsbDragHandler
+ objectName: "lightsteelblue drag"
+ }
+ PinchHandler {
+ id: pinch2
+ objectName: "lightsteelblue pinch"
+ minimumRotation: -45
+ maximumRotation: 45
+ minimumScale: 0.5
+ maximumScale: 3
+ xAxis.minimum: 0
+ xAxis.maximum: 600
+ // acceptedModifiers: Qt.ControlModifier
+ }
+ TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect2.z = rect3.z + 1 }
+ }
+
+ Rectangle {
+ id: rect3
+ x: 500
+ width: 400
+ height: 300
+ color: "wheat"
+ antialiasing: true
+ border.width: (wheatDragHandler.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) + "\nz " + rect3.z
+ }
+ DragHandler {
+ id: wheatDragHandler
+ objectName: "wheat drag"
+ }
+ PinchHandler {
+ id: pinch3
+ objectName: "wheat 3-finger pinch"
+ minimumPointCount: 3
+ minimumScale: 0.1
+ maximumScale: 10
+ onActiveChanged: {
+ if (!active)
+ anim.restart(centroid.velocity)
+ }
+ onGrabChanged: function (transition, point) {
+ if (transition === 0x10) { // GrabExclusive
+ console.log(point.id, "grabbed @", point.position)
+ Qt.createQmlObject("import QtQuick 2.0; Rectangle { opacity: 0.5; border.color: 'red'; radius: 8; width: radius * 2; height: radius * 2; " +
+ "x: " + (point.position.x - 8) + "; y: " + (point.position.y - 8) + "}",
+ rect3, "touchpoint" + point.id);
+ }
+ }
+ }
+ TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect3.z = rect2.z + 1 }
+ MomentumAnimation { id: anim; target: rect3 }
+ }
+ }
+ }
+ Rectangle {
+ id: centroidIndicator
+ property QtObject pincher: activePincher()
+ x: pincher.centroid.scenePosition.x - radius
+ y: pincher.centroid.scenePosition.y - radius
+ z: 1
+ visible: pincher.active
+ radius: width / 2
+ width: 10
+ height: width
+ color: "red"
+ }
+}
diff --git a/examples/quick/pointerhandlers/pointerhandlers.qml b/examples/quick/pointerhandlers/pointerhandlers.qml
new file mode 100644
index 0000000000..ba3eb27132
--- /dev/null
+++ b/examples/quick/pointerhandlers/pointerhandlers.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+import QtQuick.Layouts
+import shared as Examples
+import "components"
+
+Rectangle {
+ id: window
+ width: 800
+ height: 800
+ visible: true
+ Examples.LauncherList {
+ id: ll
+ objectName: "LauncherList"
+ anchors.fill: parent
+ Component.onCompleted: {
+ 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("single point handler", "PointHandler: properties such as seat, device, modifiers, velocity, pressure", Qt.resolvedUrl("singlePointHandlerProperties.qml"))
+ addExample("hover sidebar", "HoverHandler: a hierarchy of items sharing the hover state", Qt.resolvedUrl("sidebar.qml"))
+ addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml"))
+ addExample("mixer", "DragHandler: drag multiple sliders with multiple fingers", Qt.resolvedUrl("mixer.qml"))
+ addExample("fling animation", "DragHandler: after dragging, use an animation to simulate momentum", Qt.resolvedUrl("flingAnimation.qml"))
+ addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml"))
+ addExample("map", "scale, pan, re-render at different resolutions", Qt.resolvedUrl("map.qml"))
+ addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml"))
+ addExample("tablet canvas", "PointHandler and HoverHandler with a tablet: detect the stylus, and draw", Qt.resolvedUrl("tabletCanvasDrawing.qml"))
+ }
+ }
+ Item {
+ id: glassPane
+ objectName: "glassPane"
+ z: 10000
+ anchors.fill: parent
+
+ // TODO use Instantiator to create these... but we need to be able to set their parents to glassPane somehow (QTBUG-64546)
+ TouchpointFeedbackSprite { }
+ TouchpointFeedbackSprite { }
+ TouchpointFeedbackSprite { }
+ TouchpointFeedbackSprite { }
+ TouchpointFeedbackSprite { }
+ TouchpointFeedbackSprite { }
+
+ MouseFeedbackSprite { }
+ }
+}
diff --git a/examples/quick/pointerhandlers/qml.qrc b/examples/quick/pointerhandlers/qml.qrc
new file mode 100644
index 0000000000..39164527de
--- /dev/null
+++ b/examples/quick/pointerhandlers/qml.qrc
@@ -0,0 +1,47 @@
+<RCC>
+ <qresource prefix="/pointerhandlers">
+ <file>flingAnimation.qml</file>
+ <file>fakeFlickable.qml</file>
+ <file>flickablesWithHandlers.qml</file>
+ <file>joystick.qml</file>
+ <file>map.qml</file>
+ <file>mixer.qml</file>
+ <file>multibuttons.qml</file>
+ <file>photosurface.qml</file>
+ <file>pinchHandler.qml</file>
+ <file>pointerDrag.qml</file>
+ <file>pointerhandlers.qml</file>
+ <file>singlePointHandlerProperties.qml</file>
+ <file>sidebar.qml</file>
+ <file>tabletCanvasDrawing.qml</file>
+ <file>tapHandler.qml</file>
+ <file>components/Button.qml</file>
+ <file>components/CheckBox.qml</file>
+ <file>components/FakeFlickable.qml</file>
+ <file>components/FlashAnimation.qml</file>
+ <file>components/LeftDrawer.qml</file>
+ <file>components/MomentumAnimation.qml</file>
+ <file>components/ScrollBar.qml</file>
+ <file>components/Slider.qml</file>
+ <file>components/TouchpointFeedbackSprite.qml</file>
+ <file>images/arrowhead.png</file>
+ <file>images/balloon.png</file>
+ <file>components/images/checkmark.png</file>
+ <file>images/cursor-airbrush.png</file>
+ <file>images/cursor-eraser.png</file>
+ <file>images/cursor-felt-marker.png</file>
+ <file>images/cursor-pencil.png</file>
+ <file>images/fighter.png</file>
+ <file>components/images/fingersprite.png</file>
+ <file>images/grabbing-location.svg</file>
+ <file>images/joystick-outer-case-pov.jpg</file>
+ <file>images/map.svgz</file>
+ <file>images/missile.png</file>
+ <file>components/images/mixer-knob.png</file>
+ <file>components/images/mouse.png</file>
+ <file>components/images/mouse_left.png</file>
+ <file>components/images/mouse_middle.png</file>
+ <file>components/images/mouse_right.png</file>
+ <file>images/redball.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/pointerhandlers/sidebar.qml b/examples/quick/pointerhandlers/sidebar.qml
new file mode 100644
index 0000000000..60c781d46f
--- /dev/null
+++ b/examples/quick/pointerhandlers/sidebar.qml
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.15
+import "components"
+
+Rectangle {
+ id: root
+ width: 640
+ height: 480
+ color: "#444"
+
+ Component {
+ id: buttonsAndStuff
+ Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ Rectangle {
+ objectName: "buttonWithMA"
+ width: parent.width
+ height: 30
+ color: buttonMA.pressed ? "lightsteelblue" : "#999"
+ border.color: buttonMA.containsMouse ? "cyan" : "transparent"
+
+ MouseArea {
+ id: buttonMA
+ objectName: "buttonMA"
+ hoverEnabled: true
+ cursorShape: Qt.UpArrowCursor
+ anchors.fill: parent
+ onClicked: console.log("clicked MA")
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
+
+ Rectangle {
+ objectName: "buttonWithHH"
+ width: parent.width
+ height: 30
+ color: flash ? "#999" : "white"
+ border.color: buttonHH.hovered ? "cyan" : "transparent"
+ property bool flash: true
+
+ HoverHandler {
+ id: buttonHH
+ objectName: "buttonHH"
+ acceptedDevices: PointerDevice.AllDevices
+ cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
+ }
+
+ TapHandler {
+ id: tapHandler
+ onTapped: tapFlash.start()
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
+ }
+
+ FlashAnimation on flash {
+ id: tapFlash
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: paddle
+ width: 100
+ height: 40
+ color: paddleHH.hovered ? "indianred" : "#888"
+ y: parent.height - 100
+ radius: 10
+
+ HoverHandler {
+ id: paddleHH
+ objectName: "paddleHH"
+ }
+
+ SequentialAnimation on x {
+ NumberAnimation {
+ to: root.width - paddle.width
+ duration: 2000
+ easing { type: Easing.InOutQuad }
+ }
+ PauseAnimation { duration: 100 }
+ NumberAnimation {
+ to: 0
+ duration: 2000
+ easing { type: Easing.InOutQuad }
+ }
+ PauseAnimation { duration: 100 }
+ loops: Animation.Infinite
+ }
+ }
+
+ Rectangle {
+ objectName: "topSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ y: -radius
+ width: 120
+ height: 200
+ border.color: topSidebarHH.hovered ? "cyan" : "black"
+ color: "#777"
+
+ Rectangle {
+ color: "cyan"
+ width: 10
+ height: width
+ radius: width / 2
+ visible: topSidebarHH.hovered
+ x: topSidebarHH.point.position.x - width / 2
+ y: topSidebarHH.point.position.y - height / 2
+ z: 100
+ }
+
+ HoverHandler {
+ id: topSidebarHH
+ objectName: "topSidebarHH"
+ cursorShape: Qt.OpenHandCursor
+ }
+
+ Loader {
+ objectName: "topSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+
+ Rectangle {
+ objectName: "bottomSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: -radius
+ width: 120
+ height: 200
+ border.color: bottomSidebarMA.containsMouse ? "cyan" : "black"
+ color: "#777"
+
+ MouseArea {
+ id: bottomSidebarMA
+ objectName: "bottomSidebarMA"
+ hoverEnabled: true
+ cursorShape: Qt.ClosedHandCursor
+ anchors.fill: parent
+ }
+
+ Loader {
+ objectName: "bottomSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+
+ HoverHandler {
+ id: rootHover
+ }
+
+ Text {
+ anchors.right: parent.right
+ color: "cyan"
+ text: "scene " + rootHover.point.scenePosition.x.toFixed(1) + ", " + rootHover.point.scenePosition.y.toFixed(1)
+ }
+}
diff --git a/examples/quick/pointerhandlers/singlePointHandlerProperties.qml b/examples/quick/pointerhandlers/singlePointHandlerProperties.qml
new file mode 100644
index 0000000000..177e8eaaf5
--- /dev/null
+++ b/examples/quick/pointerhandlers/singlePointHandlerProperties.qml
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+Rectangle {
+ id: root
+ width: 480
+ height: 480
+ color: "black"
+
+ Item {
+ id: crosshairs
+ x: pointHandler.point.position.x - width / 2
+ y: pointHandler.point.position.y - height / 2
+ width: parent.width / 2; height: parent.height / 2
+ visible: pointHandler.active
+ rotation: pointHandler.point.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 * pointHandler.point.pressure)
+ height: width
+ radius: width / 2
+ anchors.centerIn: parent
+ antialiasing: true
+ Rectangle {
+ y: -56
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "lightsteelblue"
+ implicitWidth: label.implicitWidth
+ implicitHeight: label.implicitHeight
+ Text {
+ id: label
+ text: 'seat: ' + pointHandler.point.device.seatName + '\ndevice: ' + pointHandler.point.device.name +
+ '\nid: ' + pointHandler.point.id.toString(16) + " uid: " + pointHandler.point.uniqueId.numericId +
+ '\npos: (' + pointHandler.point.position.x.toFixed(2) + ', ' + pointHandler.point.position.y.toFixed(2) + ')' +
+ '\nmodifiers: ' + pointHandler.point.modifiers.toString(16)
+ }
+ }
+ }
+ Rectangle {
+ color: "transparent"
+ border.color: "white"
+ antialiasing: true
+ width: pointHandler.point.ellipseDiameters.width
+ height: pointHandler.point.ellipseDiameters.height
+ radius: Math.min(width / 2, height / 2)
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: velocityVector
+ visible: width > 0
+ width: pointHandler.point.velocity.length() / 10
+ height: 2
+ x: pointHandler.point.position.x
+ y: pointHandler.point.position.y
+ rotation: Math.atan2(pointHandler.point.velocity.y, pointHandler.point.velocity.x) * 180 / Math.PI
+ transformOrigin: Item.BottomLeft
+ antialiasing: true
+
+ Image {
+ source: "images/arrowhead.png"
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ width: 16
+ height: 12
+ antialiasing: true
+ }
+ }
+
+ Component {
+ id: grabbingLocationIndicator
+ Image {
+ source: "components/images/grabbing-location.svg"
+ sourceSize.width: 32
+ sourceSize.height: 32
+ }
+ }
+
+ Component {
+ id: mouseButtonIndicator
+ Image {
+ property int buttons
+ source: "components/images/mouse.png"
+ Image {
+ source: "components/images/mouse_left.png"
+ visible: buttons & Qt.LeftButton
+ }
+ Image {
+ source: "components/images/mouse_middle.png"
+ visible: buttons & Qt.MiddleButton
+ }
+ Image {
+ source: "components/images/mouse_right.png"
+ visible: buttons & Qt.RightButton
+ }
+ }
+ }
+
+ PointHandler {
+ id: pointHandler
+ target: null
+ acceptedButtons: Qt.AllButtons
+ onGrabChanged: function(transition, point) {
+ if (active) {
+ console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos)
+ grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16})
+ }
+ }
+ onPointChanged: {
+ if (point.pressedButtons)
+ mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons})
+ }
+ }
+
+ Text {
+ color: "white"
+ text: "drag to see feedback"
+ anchors {
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ margins: 6
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/tabletCanvasDrawing.qml b/examples/quick/pointerhandlers/tabletCanvasDrawing.qml
new file mode 100644
index 0000000000..5c19bab31a
--- /dev/null
+++ b/examples/quick/pointerhandlers/tabletCanvasDrawing.qml
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.15
+import QtQuick.Layouts 1.15
+import "components"
+
+Rectangle {
+ width: 1024
+ height: 1024
+ color: "#444"
+
+ ColumnLayout {
+ x: -15; width: 80
+ height: parent.height
+ Slider {
+ id: hueSlider
+ width: 80; height: 200
+ Layout.fillHeight: true
+ label: "hue"
+ Rectangle {
+ color: "beige"
+ width: 30
+ height: 25
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 2
+ anchors.horizontalCenter: parent.horizontalCenter
+ Rectangle {
+ border.color: "white"
+ color: canvas.drawingColor
+ anchors.fill: parent
+ }
+ }
+ }
+ Slider {
+ id: saturationSlider
+ width: 80; height: 200
+ Layout.fillHeight: true
+ label: "sat"
+ }
+ Slider {
+ id: lightnessSlider
+ width: 80; height: 200
+ Layout.fillHeight: true
+ label: "light"
+ }
+ }
+
+ ColumnLayout {
+ x: parent.width - 65; width: 80
+ height: parent.height
+ Slider {
+ id: widthSlider
+ width: 80; height: 200
+ Layout.fillHeight: true
+ label: "width"
+ }
+ Slider {
+ id: alphaSlider
+ width: 80; height: 200
+ Layout.fillHeight: true
+ label: "alpha"
+ }
+ }
+
+ Rectangle {
+ id: rect
+ width: 640
+ height: 480
+ color: "beige"
+ anchors {
+ fill: parent
+ margins: 10
+ leftMargin: 50
+ rightMargin: 50
+ }
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ antialiasing: true
+ renderTarget: Canvas.FramebufferObject
+ property color drawingColor: Qt.hsla(hueSlider.value / 100.0,
+ saturationSlider.value / 100.0,
+ lightnessSlider.value / 100.0,
+ alphaSlider.value / 100.0)
+ property var points: []
+ property var pressures: []
+ property var pointerType: PointerDevice.Pen
+ onPaint: {
+ if (points.length < 2)
+ return
+ var ctx = canvas.getContext('2d');
+ ctx.save()
+ ctx.strokeStyle = pointerType === PointerDevice.Pen ? drawingColor : "beige"
+ ctx.lineCap = "round"
+ if (pressures.length === points.length) {
+ for (var i = 1; i < points.length; i++) {
+ ctx.lineWidth = pressures[i] * widthSlider.value
+ ctx.beginPath()
+ ctx.moveTo(points[i - 1].x, points[i - 1].y)
+ ctx.lineTo(points[i].x, points[i].y)
+ ctx.stroke()
+ }
+ points = points.slice(points.length - 2, 1)
+ pressures = pressures.slice(pressures.length - 2, 1)
+ } else {
+ ctx.beginPath()
+ ctx.moveTo(points[0].x, points[0].y)
+ for (var i = 1; i < points.length; i++)
+ ctx.lineTo(points[i].x, points[i].y)
+ ctx.lineWidth = widthSlider
+ ctx.stroke()
+ points = points.slice(points.length - 2, 1)
+ pressures = []
+ }
+ ctx.restore()
+ }
+ }
+
+ Text {
+ text: "draw with a drawing-tablet stylus"
+ anchors {
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ margins: 6
+ }
+ }
+
+ PointHandler {
+ acceptedPointerTypes: PointerDevice.Pen
+ onActiveChanged:
+ if (active) {
+ canvas.pointerType = PointerDevice.Pen
+ } else {
+ canvas.points = []
+ canvas.pressures = []
+ }
+ onPointChanged:
+ if (active) {
+ canvas.points.push(point.position)
+ canvas.pressures.push(point.pressure)
+ canvas.requestPaint()
+ }
+ }
+
+ PointHandler {
+ acceptedPointerTypes: PointerDevice.Eraser
+ onActiveChanged:
+ if (active) {
+ canvas.pointerType = PointerDevice.Eraser
+ } else {
+ canvas.points = []
+ canvas.pressures = []
+ }
+ onPointChanged:
+ if (active) {
+ canvas.points.push(point.position)
+ canvas.pressures.push(point.pressure)
+ canvas.requestPaint()
+ }
+ }
+
+ HoverHandler {
+ id: stylusHandler
+ acceptedDevices: PointerDevice.Stylus
+ acceptedPointerTypes: PointerDevice.Pen
+ target: Image {
+ parent: rect
+ source: stylusHandler.point.rotation === 0 ?
+ "images/cursor-pencil.png" : "images/cursor-felt-marker.png"
+ visible: stylusHandler.hovered
+ rotation: stylusHandler.point.rotation
+ x: stylusHandler.point.position.x
+ y: stylusHandler.point.position.y
+ }
+ }
+
+ HoverHandler {
+ id: airbrushHandler
+ acceptedDevices: PointerDevice.Airbrush
+ acceptedPointerTypes: PointerDevice.Pen
+ target: Image {
+ parent: rect
+ source: "images/cursor-airbrush.png"
+ visible: airbrushHandler.hovered
+ x: airbrushHandler.point.position.x
+ y: airbrushHandler.point.position.y
+ }
+ }
+
+ HoverHandler {
+ id: eraserHandler
+ acceptedPointerTypes: PointerDevice.Eraser
+ target: Image {
+ parent: rect
+ source: "images/cursor-eraser.png"
+ visible: eraserHandler.hovered
+ x: eraserHandler.point.position.x
+ y: eraserHandler.point.position.y - 32
+ }
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/tapHandler.qml b/examples/quick/pointerhandlers/tapHandler.qml
new file mode 100644
index 0000000000..90cf778ede
--- /dev/null
+++ b/examples/quick/pointerhandlers/tapHandler.qml
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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
+import "components"
+
+Item {
+ width: 800
+ height: 480
+
+ Rectangle {
+ id: rect
+ anchors.fill: parent; anchors.margins: 40
+ border.width: 3; border.color: "transparent"
+ color: handler.pressed ? "lightsteelblue" : "darkgrey"
+
+ TapHandler {
+ id: handler
+ 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)
+
+ onCanceled: {
+ console.log("canceled @ " + point.position)
+ borderBlink.blinkColor = "red"
+ borderBlink.start()
+ }
+ onTapped: function(point, button) {
+ console.log("tapped button " + button + " @ " + point.scenePosition +
+ " on device '" + point.device.name + "' with modifiers " + handler.point.modifiers +
+ " " + (tapCount > 1 ? (tapCount + " times") : "for the first time"))
+ if (tapCount > 1) {
+ tapCountLabel.text = tapCount
+ flashAnimation.start()
+ } else {
+ borderBlink.tapFeedback(button)
+ }
+ }
+ onLongPressed: longPressFeedback.createObject(rect,
+ {"x": point.position.x, "y": point.position.y,
+ "text": "long press after\n" + handler.timeHeld.toFixed(3) + " sec",
+ "color": buttonToBlinkColor(point.pressedButtons)})
+ }
+
+ 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
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: expandingCircle
+ radius: handler.timeHeld * 100
+ visible: radius > 0 && handler.pressed
+ border.width: 3
+ border.color: buttonToBlinkColor(handler.point.pressedButtons)
+ color: "transparent"
+ width: radius * 2
+ height: radius * 2
+ x: handler.point.pressPosition.x - radius
+ y: handler.point.pressPosition.y - radius
+ opacity: 0.25
+ }
+
+ Component {
+ id: longPressFeedback
+ Text { }
+ }
+
+ SequentialAnimation {
+ id: borderBlink
+ property color blinkColor: "red"
+ function tapFeedback(button) {
+ blinkColor = buttonToBlinkColor(button);
+ start();
+ }
+ loops: 3
+ ScriptAction { script: rect.border.color = borderBlink.blinkColor }
+ PauseAnimation { duration: 100 }
+ ScriptAction { script: rect.border.color = "transparent" }
+ PauseAnimation { duration: 100 }
+ }
+
+ Text {
+ text: "tap, click with different buttons, double-click, long press in this area"
+ anchors {
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ margins: 6
+ }
+ }
+ }
+
+ function buttonToBlinkColor(button) {
+ switch (button) {
+ case Qt.MiddleButton: return "orange";
+ case Qt.RightButton: return "magenta";
+ default: return "green";
+ }
+ }
+
+ Row {
+ spacing: 6
+ Text {
+ text: "accepted mouse clicks:"
+ anchors.verticalCenter: leftAllowedCB.verticalCenter
+ }
+ CheckBox {
+ id: leftAllowedCB
+ checked: true
+ text: "left"
+ }
+ CheckBox {
+ id: middleAllowedCB
+ text: "middle"
+ }
+ CheckBox {
+ id: rightAllowedCB
+ text: "right"
+ }
+ Text {
+ text: " gesture policy:"
+ anchors.verticalCenter: leftAllowedCB.verticalCenter
+ }
+ CheckBox {
+ id: policyDragThresholdCB
+ text: "drag threshold"
+ onCheckedChanged: if (checked) {
+ policyWithinBoundsCB.checked = false;
+ policyReleaseWithinBoundsCB.checked = false;
+ }
+ }
+ CheckBox {
+ id: policyWithinBoundsCB
+ text: "within bounds"
+ onCheckedChanged: if (checked) {
+ policyDragThresholdCB.checked = false;
+ policyReleaseWithinBoundsCB.checked = false;
+ }
+ }
+ CheckBox {
+ id: policyReleaseWithinBoundsCB
+ checked: true
+ text: "release within bounds"
+ onCheckedChanged: if (checked) {
+ policyDragThresholdCB.checked = false;
+ policyWithinBoundsCB.checked = false;
+ }
+ }
+ }
+}
diff --git a/examples/quick/pointerhandlers/tapWithModifiers.qml b/examples/quick/pointerhandlers/tapWithModifiers.qml
new file mode 100644
index 0000000000..86b66512da
--- /dev/null
+++ b/examples/quick/pointerhandlers/tapWithModifiers.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.12
+
+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:
+ switch (point.modifiers) {
+ case Qt.ControlModifier | Qt.AltModifier:
+ console.log("CTRL+ALT");
+ break;
+ case Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier:
+ console.log("CTRL+META+ALT");
+ break;
+ default:
+ console.log("other modifiers", point.modifiers)
+ }
+ }
+}