-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrowPad.qml
154 lines (146 loc) · 3.85 KB
/
ArrowPad.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import QtQuick 2.12
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.12
Item{
id: arrowPad
property var type: "translation"
width: map.width/10
height: width
property var imageNameRight: "arrow"
property var imageNameLeft: imageNameRight
property var imageNameUp: imageNameLeft
property var imageNameDown: imageNameLeft
property var rotRight: 180
property var rotLeft: 180
property var rotUp: 90
property var rotDown: 90
property var mirrorRight: true
property var mirrorLeft: false
property var mirrorUp: true
property var mirrorDown: false
property var scaleX: .05
property var scaleY: .05
Component.onCompleted: {
if(type === "rotation"){
imageNameRight="rotArrow"
scaleX = -Math.PI/16
scaleY = Math.PI/16
}
if(type === "other"){
imageNameRight="rotArrow"
scaleX = -.05
scaleY = -Math.PI/16
imageNameRight= "skip"
imageNameLeft= imageNameRight
imageNameUp= "zoom_in"
imageNameDown= "zoom_out"
rotRight = 90
rotLeft = -90
rotUp = 0
rotDown = 0
mirrorUp = false
mirrorDown = false
}
}
function publish(x,y){
moving = true
x*=scaleX
y*=scaleY
if(type === "translation"){
pubCommand("mouse;"+x+":"+y+":0:0:0:0")
}
if(type === "rotation"){
pubCommand("mouse;0:0:0:"+y+":"+x+":0")
}
if(type === "other"){
pubCommand("mouse;0:0:"+x+":0:0:"+y)
}
}
GuiButton{
id:center
visible: type !== "translation"
width: parent.width/5
height: width
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
color: "steelblue"
rotation: 45
mirror: false
name: "center"
onClicked: {
if(type === "rotation"){
pubCommand("center;x,y")
}
if(type === "other"){
pubCommand("center;z")
}
}
}
GuiButton{
id:right
width: parent.width/2.5
height: width
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
color: "steelblue"
rotation: rotRight
mirror: mirrorRight
name: imageNameRight
onClicked: {
publish(0,-1)
}
}
GuiButton{
id:left
width: parent.width/2.5
height: width
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
rotation: rotLeft
mirror: mirrorLeft
color: "steelblue"
name: imageNameLeft
onClicked: {
publish(0,1)
}
}
GuiButton{
id:up
width: parent.width/2.5
height: width
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
rotation: rotUp
mirror: mirrorUp
color: "steelblue"
name: imageNameUp
onClicked: {
publish(1,0)
}
}
GuiButton{
id:down
width: parent.width/2.5
height: width
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
rotation: rotDown
mirror: mirrorDown
color: "steelblue"
name: imageNameDown
onClicked: {
publish(-1,0)
}
}
function setEnabled(button, value){
if(button === "up")
up.enabled = value
if(button === "down")
down.enabled = value
if(button === "left")
left.enabled = value
if(button === "right")
right.enabled = value
}
}