2016-11-25 14:38:42 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2018-08-21 20:20:50 +00:00
|
|
|
** Copyright (C) 2017 The Qt Company Ltd.
|
2016-11-25 14:38:42 +00:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of the manual tests of the Qt Toolkit.
|
|
|
|
**
|
2017-11-15 15:29:18 +00:00
|
|
|
** $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.
|
2016-11-25 14:38:42 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2018-06-25 16:12:29 +00:00
|
|
|
import QtQuick 2.12
|
2016-11-25 14:38:42 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
width: 480
|
|
|
|
height: 480
|
|
|
|
color: "black"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: crosshairs
|
2018-08-21 20:20:50 +00:00
|
|
|
x: pointHandler.point.position.x - width / 2
|
|
|
|
y: pointHandler.point.position.y - height / 2
|
2016-11-25 14:38:42 +00:00
|
|
|
width: parent.width / 2; height: parent.height / 2
|
2018-08-21 20:20:50 +00:00
|
|
|
visible: pointHandler.active
|
|
|
|
rotation: pointHandler.point.rotation
|
2016-11-25 14:38:42 +00:00
|
|
|
|
|
|
|
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"
|
2018-08-21 20:20:50 +00:00
|
|
|
width: Math.max(2, 50 * pointHandler.point.pressure)
|
2016-11-25 14:38:42 +00:00
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
anchors.centerIn: parent
|
|
|
|
antialiasing: true
|
|
|
|
Rectangle {
|
2018-05-16 11:05:23 +00:00
|
|
|
y: -56
|
2016-11-25 14:38:42 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
color: "lightsteelblue"
|
|
|
|
implicitWidth: label.implicitWidth
|
|
|
|
implicitHeight: label.implicitHeight
|
|
|
|
Text {
|
|
|
|
id: label
|
2018-08-21 20:20:50 +00:00
|
|
|
text: 'id: ' + 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)
|
2016-11-25 14:38:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
border.color: "white"
|
|
|
|
antialiasing: true
|
2018-08-21 20:20:50 +00:00
|
|
|
width: pointHandler.point.ellipseDiameters.width
|
|
|
|
height: pointHandler.point.ellipseDiameters.height
|
2016-11-25 14:38:42 +00:00
|
|
|
radius: Math.min(width / 2, height / 2)
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
id: velocityVector
|
|
|
|
visible: width > 0
|
2018-08-21 20:20:50 +00:00
|
|
|
width: pointHandler.point.velocity.length() * 100
|
2016-11-25 14:38:42 +00:00
|
|
|
height: 2
|
2018-08-21 20:20:50 +00:00
|
|
|
x: pointHandler.point.position.x
|
|
|
|
y: pointHandler.point.position.y
|
|
|
|
rotation: Math.atan2(pointHandler.point.velocity.y, pointHandler.point.velocity.x) * 180 / Math.PI
|
2016-11-25 14:38:42 +00:00
|
|
|
transformOrigin: Item.BottomLeft
|
|
|
|
antialiasing: true
|
|
|
|
|
|
|
|
Image {
|
|
|
|
source: "resources/arrowhead.png"
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: 12
|
|
|
|
antialiasing: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: grabbingLocationIndicator
|
|
|
|
Image {
|
|
|
|
source: "resources/grabbing-location.svg"
|
|
|
|
sourceSize.width: 32
|
|
|
|
sourceSize.height: 32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mouseButtonIndicator
|
|
|
|
Image {
|
|
|
|
property int buttons
|
|
|
|
source: "resources/mouse.png"
|
|
|
|
Image {
|
|
|
|
source: "resources/mouse_left.png"
|
|
|
|
visible: buttons & Qt.LeftButton
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
source: "resources/mouse_middle.png"
|
|
|
|
visible: buttons & Qt.MidButton
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
source: "resources/mouse_right.png"
|
|
|
|
visible: buttons & Qt.RightButton
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-21 20:20:50 +00:00
|
|
|
PointHandler {
|
|
|
|
id: pointHandler
|
2016-11-25 14:38:42 +00:00
|
|
|
target: null
|
2018-08-21 20:20:50 +00:00
|
|
|
acceptedButtons: Qt.AllButtons
|
|
|
|
onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance
|
|
|
|
console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos)
|
|
|
|
grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16})
|
2016-11-25 14:38:42 +00:00
|
|
|
}
|
2018-08-21 20:20:50 +00:00
|
|
|
onPointChanged: {
|
|
|
|
// Here, 'point' is referring to the property of the PointHandler
|
|
|
|
if (point.pressedButtons)
|
|
|
|
mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons})
|
2016-11-25 14:38:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|