aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/pointer/content
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-24 17:03:19 +0200
commit8503f884bbdb50c4bebc8f8a9fce05275b0612b1 (patch)
treec4a28a0df334841a49d6653ffd02c38aca54b68a /tests/manual/pointer/content
parent11b358a82cd4b1570f32c53808ef974bf11ffb9d (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. Pick-to: 6.2 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>
Diffstat (limited to 'tests/manual/pointer/content')
-rw-r--r--tests/manual/pointer/content/FakeFlickable.qml127
-rw-r--r--tests/manual/pointer/content/LeftDrawer.qml101
-rw-r--r--tests/manual/pointer/content/MouseFeedbackSprite.qml78
-rw-r--r--tests/manual/pointer/content/MultiButton.qml73
-rw-r--r--tests/manual/pointer/content/ScrollBar.qml147
5 files changed, 0 insertions, 526 deletions
diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml
deleted file mode 100644
index 636399ba2c..0000000000
--- a/tests/manual/pointer/content/FakeFlickable.qml
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the manual tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $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/tests/manual/pointer/content/LeftDrawer.qml b/tests/manual/pointer/content/LeftDrawer.qml
deleted file mode 100644
index 7e43e5a2bd..0000000000
--- a/tests/manual/pointer/content/LeftDrawer.qml
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the manual tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $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/tests/manual/pointer/content/MouseFeedbackSprite.qml b/tests/manual/pointer/content/MouseFeedbackSprite.qml
deleted file mode 100644
index d3068ff503..0000000000
--- a/tests/manual/pointer/content/MouseFeedbackSprite.qml
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the manual tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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: "../resources/mouse.png"
- visible: handler.active
- x: handler.point.position.x - width / 2
- y: handler.point.position.y - height / 2
- parent: handler.parent
- Image {
- source: "../resources/mouse_left.png"
- visible: handler.point.pressedButtons & Qt.LeftButton
- }
- Image {
- source: "../resources/mouse_middle.png"
- visible: handler.point.pressedButtons & Qt.MiddleButton
- }
- Image {
- source: "../resources/mouse_right.png"
- visible: handler.point.pressedButtons & Qt.RightButton
- }
- }
-}
diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml
deleted file mode 100644
index 485784a875..0000000000
--- a/tests/manual/pointer/content/MultiButton.qml
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the manual tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.12
-
-Rectangle {
- id: root
- property alias label: label.text
- property alias pressed: tap.pressed
- property bool checked: false
- property alias gesturePolicy: tap.gesturePolicy
- property alias margin: tap.margin
- signal tapped
-
- width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0
- border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true
-
- gradient: Gradient {
- GradientStop { position: 0.0; color: tap.pressed ? "#b8b5b2" : "#efebe7" }
- GradientStop { position: 1.0; color: "#b8b5b2" }
- }
-
- TapHandler {
- id: tap
- objectName: label.text
- onTapped: {
- tapFlash.start()
- root.tapped()
- }
- }
-
- Text {
- id: label
- font.pointSize: 14
- text: "Button"
- anchors.centerIn: parent
- }
-
- Rectangle {
- anchors.fill: parent
- color: "transparent"
- border.width: 2; radius: root.radius; antialiasing: true
- opacity: tapFlash.running ? 1 : 0
- FlashAnimation on visible {
- id: tapFlash
- }
- }
-}
diff --git a/tests/manual/pointer/content/ScrollBar.qml b/tests/manual/pointer/content/ScrollBar.qml
deleted file mode 100644
index 9928433d1f..0000000000
--- a/tests/manual/pointer/content/ScrollBar.qml
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the manual tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $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
- }
-
- SystemPalette { id: palette }
-
- color: palette.button
- border.color: Qt.darker(palette.button, 1.5)
- gradient: Gradient {
- GradientStop { position: 0; color: Qt.darker(palette.button, 1.3) }
- GradientStop { position: 1; color: palette.button }
- }
- antialiasing: true
- radius: Math.min(width, height) / 6
- width: 20
- height: 20
-
- TapHandler {
- id: tap
- onTapped: {
- if (knob.state === "horizontal")
- knob.x = 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
- }
- }
-}