blob: c2c7e620ee174953bb3c417a3f485fd181086946 (
plain)
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
155
156
157
|
/*
* Copyright 2011 Josef Holzmayr, holzmayr@rsi-elektrotechnik.de
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
import QtQuick 1.0
Rectangle {
id: page
color: "grey"
width: 320
height: 240
property int boxsize: 50
property int markersize: 30
property int borderoffset: 10
property int boxoffset: (boxsize - markersize) / 2
Rectangle {
id: rectTL
width: boxsize
height: boxsize
color: "#00000000"
anchors.left: parent.left
anchors.leftMargin: borderoffset
anchors.top: parent.top
anchors.topMargin: borderoffset
border.color: "#000000"
MouseArea {
anchors.fill: parent
onClicked: page.state = 'TL'
}
}
Rectangle {
id: rectTR
width: boxsize
height: boxsize
color: "#00000000"
anchors.top: parent.top
anchors.topMargin: borderoffset
anchors.right: parent.right
anchors.rightMargin: borderoffset
border.color: "#000000"
MouseArea {
anchors.fill: parent
onClicked: page.state = 'TR'
}
}
Rectangle {
id: rectBL
width: boxsize
height: boxsize
color: "#00000000"
anchors.left: parent.left
anchors.leftMargin: borderoffset
anchors.bottom: parent.bottom
anchors.bottomMargin: borderoffset
border.color: "#000000"
MouseArea {
anchors.fill: parent
onClicked: page.state = 'BL'
}
}
Rectangle {
id: rectBR
width: boxsize
height: boxsize
color: "#00000000"
anchors.bottom: parent.bottom
anchors.bottomMargin: borderoffset
anchors.right: parent.right
anchors.rightMargin: borderoffset
border.color: "#000000"
MouseArea {
anchors.fill: parent
onClicked: page.state = 'BR'
}
}
Rectangle {
id: marker
x: (page.width / 2) - (marker.width / 2)
y: (page.height / 2) - (marker.height / 2)
width: markersize
height: markersize
color: "#ff0000"
}
Text {
id: text1
text: qsTr("Touch the black squares to move the red marker.")
anchors.right: parent.right
anchors.rightMargin: borderoffset
anchors.left: parent.left
anchors.leftMargin: borderoffset
anchors.bottom: parent.bottom
anchors.bottomMargin: (borderoffset * 2) + boxsize
anchors.top: parent.top
anchors.topMargin: (borderoffset * 2) + boxsize
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
font.family: "Arial Black"
font.underline: true
font.pixelSize: 12
}
states: [
State {
name: "TL"
PropertyChanges {
target: marker
x: rectTL.x + boxoffset
y: rectTL.y + boxoffset
}
},
State {
name: "TR"
PropertyChanges {
target: marker
x: rectTR.x + boxoffset
y: rectTR.y + boxoffset
}
},
State {
name: "BL"
PropertyChanges {
target: marker
x: rectBL.x + boxoffset
y: rectBL.y + boxoffset
}
},
State {
name: "BR"
PropertyChanges {
target: marker
x: rectBR.x + boxoffset
y: rectBR.y + boxoffset
}
}
]
transitions: Transition {
NumberAnimation { properties: "x, y"; easing.type: Easing.InOutQuad; duration: 500 }
}
}
|