2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2017-11-14 15:56:55 +00:00
|
|
|
|
2021-10-26 18:11:41 +00:00
|
|
|
import QtQuick
|
2017-11-14 15:56:55 +00:00
|
|
|
|
2021-09-06 19:40:18 +00:00
|
|
|
Item {
|
|
|
|
width: image.implicitWidth; height: image.implicitHeight
|
|
|
|
Image {
|
|
|
|
id: image
|
|
|
|
anchors.centerIn: parent
|
|
|
|
source: "images/joystick-outer-case-pov.jpg"
|
|
|
|
property real margin: 50
|
|
|
|
|
2017-11-14 15:56:55 +00:00
|
|
|
Image {
|
2021-09-06 19:40:18 +00:00
|
|
|
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 }
|
|
|
|
}
|
|
|
|
]
|
2017-11-14 15:56:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|