diff options
Diffstat (limited to 'examples/quick/pointerhandlers/components')
-rw-r--r-- | examples/quick/pointerhandlers/components/CorkPanel.qml | 118 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/components/FlashAnimation.qml | 8 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml | 13 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/components/QuadPieMenu.qml | 7 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/components/ScrollBar.qml | 4 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/components/images/cork.jpg | bin | 0 -> 149337 bytes | |||
-rw-r--r-- | examples/quick/pointerhandlers/components/images/note-yellow.png | bin | 0 -> 54283 bytes | |||
-rw-r--r-- | examples/quick/pointerhandlers/components/images/tack.png | bin | 0 -> 7282 bytes |
8 files changed, 136 insertions, 14 deletions
diff --git a/examples/quick/pointerhandlers/components/CorkPanel.qml b/examples/quick/pointerhandlers/components/CorkPanel.qml new file mode 100644 index 0000000000..4aec2b5c7c --- /dev/null +++ b/examples/quick/pointerhandlers/components/CorkPanel.qml @@ -0,0 +1,118 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick + +Image { + id: corkPanel + source: Qt.resolvedUrl("images/cork.jpg") + width: ListView.view.width + height: ListView.view.height + fillMode: Image.PreserveAspectCrop + + required property string name + required property var notes + + TapHandler { + objectName: corkPanel.name + onTapped: corkPanel.Window.activeFocusItem.focus = false + } + + Text { + text: corkPanel.name + x: 15 + y: 8 + height: 40 + width: 370 + font.pixelSize: 18 + font.bold: true + color: "white" + style: Text.Outline + styleColor: "black" + wrapMode: Text.Wrap + } + + Repeater { + model: corkPanel.notes + Item { + id: fulcrum + + x: 100 + Math.random() * (corkPanel.width - 0.5 * paper.width) + y: 50 + Math.random() * (corkPanel.height - 0.5 * paper.height) + + Item { + id: note + scale: 0.7 + + Image { + id: paper + x: 8 + -width * 0.6 / 2 + y: -20 + source: "images/note-yellow.png" + scale: 0.6 + transformOrigin: Item.TopLeft + antialiasing: true + + DragHandler { + target: fulcrum + xAxis.minimum: 100 + xAxis.maximum: corkPanel.width - 80 + yAxis.minimum: 0 + yAxis.maximum: corkPanel.height - 80 + } + } + + TextEdit { + id: text + x: -104 + y: 36 + width: 215 + height: 24 + font.pixelSize: 24 + readOnly: false + selectByMouse: activeFocus + rotation: -8 + text: noteText + wrapMode: Text.Wrap + } + + rotation: -flickable.horizontalVelocity / 100 + Behavior on rotation { + SpringAnimation { + spring: 2.0 + damping: 0.15 + } + } + } + + Image { + x: -width / 2 + y: -height * 0.5 / 2 + source: "images/tack.png" + scale: 0.7 + transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: text.activeFocus + PropertyChanges { + target: note + rotation: 8 + scale: 1 + } + PropertyChanges { + target: fulcrum + z: 8 + } + } + + transitions: Transition { + NumberAnimation { + properties: "rotation,scale" + duration: 200 + } + } + } + } +} diff --git a/examples/quick/pointerhandlers/components/FlashAnimation.qml b/examples/quick/pointerhandlers/components/FlashAnimation.qml index e369282470..bdbcaecdfa 100644 --- a/examples/quick/pointerhandlers/components/FlashAnimation.qml +++ b/examples/quick/pointerhandlers/components/FlashAnimation.qml @@ -6,15 +6,9 @@ import QtQuick SequentialAnimation { id: tapFlash running: false + loops: 3 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/MouseFeedbackSprite.qml b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml index 1de4de8e48..57c58d826f 100644 --- a/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml +++ b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml @@ -10,22 +10,27 @@ HoverHandler { target: Image { objectName: "mouse sprite" source: "images/mouse.png" - opacity: (handler.point.pressedButtons || wheelAnimationTimer.running) ? 1 : 0 + opacity: (phandler.point.pressedButtons || wheelAnimationTimer.running) ? 1 : 0 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 + visible: phandler.point.pressedButtons & Qt.LeftButton } Image { source: "images/mouse_middle.png" - visible: handler.point.pressedButtons & Qt.MiddleButton + visible: phandler.point.pressedButtons & Qt.MiddleButton } Image { source: "images/mouse_right.png" - visible: handler.point.pressedButtons & Qt.RightButton + visible: phandler.point.pressedButtons & Qt.RightButton } + PointHandler { + id: phandler + acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton + } + WheelHandler { blocking: false onWheel: (event)=> { diff --git a/examples/quick/pointerhandlers/components/QuadPieMenu.qml b/examples/quick/pointerhandlers/components/QuadPieMenu.qml index 9c2364fea2..eae268eccb 100644 --- a/examples/quick/pointerhandlers/components/QuadPieMenu.qml +++ b/examples/quick/pointerhandlers/components/QuadPieMenu.qml @@ -9,6 +9,7 @@ TapHandler { signal triggered(string text) id: menuTap + acceptedButtons: Qt.RightButton gesturePolicy: TapHandler.DragWithinBounds onPressedChanged: if (pressed) { impl.x = point.position.x - impl.width / 2 @@ -22,7 +23,10 @@ TapHandler { parent: menuTap.parent width: 100 height: 100 - scale: Math.min(1, Math.max(0, menuTap.timeHeld * 4)) + // with touchscreen or stylus, long-press slowly expands the menu to size + // with mouse or touchpad right-click, it opens instantly + scale: menuTap.point.device.pointerType === PointerDevice.Generic ? + 1 : Math.min(1, Math.max(0, menuTap.timeHeld * 4)) opacity: scale * 2 visible: menuTap.pressed property Shape highlightedShape: null @@ -35,6 +39,7 @@ TapHandler { width: 100 height: 100 containsMode: Shape.FillContains + preferredRendererType: Shape.CurveRenderer property bool highlighted: menuTap.pressed && shape.contains(shape.mapFromItem(menuTap.parent, menuTap.point.position)) diff --git a/examples/quick/pointerhandlers/components/ScrollBar.qml b/examples/quick/pointerhandlers/components/ScrollBar.qml index d78ee56140..6b13c03305 100644 --- a/examples/quick/pointerhandlers/components/ScrollBar.qml +++ b/examples/quick/pointerhandlers/components/ScrollBar.qml @@ -70,7 +70,7 @@ Rectangle { PropertyChanges { knob { max: root.width - knob.width - scrolledX: Math.min(max, Math.max(0, max * flick.contentX / (flick.width - flick.contentWidth))) + scrolledX: Math.min(knob.max, Math.max(0, knob.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 @@ -91,7 +91,7 @@ Rectangle { knob { max: root.height - knob.height scrolledX: 1 - scrolledY: Math.min(max, Math.max(0, max * flick.contentY / (flick.height - flick.contentHeight))) + scrolledY: Math.min(knob.max, Math.max(0, knob.max * flick.contentY / (flick.height - flick.contentHeight))) scrollDistance: flick.height - flick.contentHeight width: root.width - 2 height: root.width - 2 diff --git a/examples/quick/pointerhandlers/components/images/cork.jpg b/examples/quick/pointerhandlers/components/images/cork.jpg Binary files differnew file mode 100644 index 0000000000..160bc002bf --- /dev/null +++ b/examples/quick/pointerhandlers/components/images/cork.jpg diff --git a/examples/quick/pointerhandlers/components/images/note-yellow.png b/examples/quick/pointerhandlers/components/images/note-yellow.png Binary files differnew file mode 100644 index 0000000000..3195952ad2 --- /dev/null +++ b/examples/quick/pointerhandlers/components/images/note-yellow.png diff --git a/examples/quick/pointerhandlers/components/images/tack.png b/examples/quick/pointerhandlers/components/images/tack.png Binary files differnew file mode 100644 index 0000000000..cef2d1cd23 --- /dev/null +++ b/examples/quick/pointerhandlers/components/images/tack.png |