mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-21 05:49:45 +00:00
ref #86 "added mouse area for default qml control"
This commit is contained in:
parent
1065198edf
commit
eeb757fd8e
@ -8,8 +8,13 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls.Material 2.15
|
import QtQuick.Controls.Material 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
AbstractMenuView {
|
AbstractMenuView {
|
||||||
|
|
||||||
|
columns: 2
|
||||||
|
rows: 2
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Back to menu.")
|
text: qsTr("Back to menu.")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -18,4 +23,21 @@ AbstractMenuView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
property bool track: false
|
||||||
|
property real oldX: 0
|
||||||
|
property real oldY: 0
|
||||||
|
cursorShape: Qt.DragMoveCursor
|
||||||
|
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.rowSpan: 2
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
model.userTap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,67 +8,65 @@ DefaultMenu {
|
|||||||
columns: 2
|
columns: 2
|
||||||
rows: 2
|
rows: 2
|
||||||
|
|
||||||
Button {
|
Rectangle {
|
||||||
text: "🌀"
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
model.userTap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
property bool track: false
|
|
||||||
property real oldX: 0
|
|
||||||
property real oldY: 0
|
|
||||||
cursorShape: Qt.DragMoveCursor
|
|
||||||
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
Layout.rowSpan: 2
|
Layout.rowSpan: 2
|
||||||
|
|
||||||
onPressed: {
|
color: "#22000000"
|
||||||
track = true
|
|
||||||
oldX = mouse.x
|
|
||||||
oldY = mouse.y
|
|
||||||
|
|
||||||
}
|
MouseArea {
|
||||||
|
property bool track: false
|
||||||
|
property real oldX: 0
|
||||||
|
property real oldY: 0
|
||||||
|
cursorShape: Qt.DragMoveCursor
|
||||||
|
onPressed: {
|
||||||
|
track = true
|
||||||
|
oldX = mouse.x
|
||||||
|
oldY = mouse.y
|
||||||
|
|
||||||
onReleased: {
|
|
||||||
track = false
|
|
||||||
}
|
|
||||||
|
|
||||||
onMouseXChanged: {
|
|
||||||
if (!model) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!track) {
|
onReleased: {
|
||||||
return;
|
track = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const delta = mouse.x - oldX;
|
onMouseXChanged: {
|
||||||
const radianDelta = (delta / (parent.width / 2)) * 45
|
if (!model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
model.xChanged(radianDelta)
|
if (!track) {
|
||||||
oldX = mouse.x;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseYChanged: {
|
const delta = mouse.x - oldX;
|
||||||
if (!model) {
|
const radianDelta = (delta / (parent.width / 2)) * 45
|
||||||
return;
|
|
||||||
|
model.xChanged(radianDelta)
|
||||||
|
oldX = mouse.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!track) {
|
onMouseYChanged: {
|
||||||
return;
|
if (!model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!track) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delta = mouse.y - oldY;
|
||||||
|
const radianDelta = (delta / (parent.height / 2)) * 45
|
||||||
|
|
||||||
|
model.yChanged(radianDelta)
|
||||||
|
oldY = mouse.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
const delta = mouse.y - oldY;
|
anchors.fill: parent
|
||||||
const radianDelta = (delta / (parent.height / 2)) * 45
|
|
||||||
|
|
||||||
model.yChanged(radianDelta)
|
|
||||||
oldY = mouse.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user