Newer
Older
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/*
This file is part of Gabriel's Qt/QML CardBoard Sample (or short GQQCS)
GQQCS 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 3 of the License, or
(at your option) any later version.
GQQCS 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.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
Updated: 07/08/2015 by: Gabriel F.
*/
import QtQuick 2.4
Item {
id: root
anchors.fill: parent
opacity: 0.0
visible: false
property var fadeInEndCallback: function() { console.log("Menu fadeInEndCallback()") }
property var fadeOutCallback: function() { console.log("Menu fadeOutCallback()") }
property var nextVideo: b1T
property double yScroll: 0
function showDetail() {
if (nextVideo.nome == "Logo") {
} else if (nextVideo.nome == "Inicio") {
root.hide()
} else if (nextVideo.nome == "Sobre") {
sobre.show()
} else {
if (nextVideo.video.length > 0) {
videoTitle.show()
videoTitle.titulo = nextVideo.titulo
detail.videoFile = nextVideo.video
detail.timerCount = nextVideo.videoCountdown
}
nextVideo.zero()
}
}
function fixArrows() {
arrowFor(b1T,arrowBlue)
arrowFor(b1B,arrowOrange)
arrowFor(b2T,arrowGreen)
arrowFor(b2B,arrowRed)
arrowFor(b3T,arrowWhite)
arrowFor(b3B,arrowBlack)
}
function arrowFor(target,arrow) {
var c = cursor.mapToItem(root,0,0)
var t = target.mapToItem(root,0,0)
var vX = t.x + target.width*.5 - c.x
var vY = t.y + target.height*.5 - c.y
var cA = vY/vX
var p1x, p1y, p2x, p2y, d1, d2;
// Vertical line
p1x = (vX > 0 ? 1 : -1)*leftBlock.width*0.5
p1y = cA*p1x
d1 = Math.sqrt(Math.pow(p1x,2)+Math.pow(p1y,2))
// Horizontal line
p2y = ((vY > 0 ? 1 : -1)*leftBlock.height*0.5)+(vY > 0 ? 0 : +10)
p2x = p2y/cA
d2 = Math.sqrt(Math.pow(p2x,2)+Math.pow(p2y,2))
if (d1 < d2) {
arrow.x = p1x*0.9
arrow.y = p1y*0.9
} else {
arrow.x = p2x*0.9
arrow.y = p2y*0.9
}
arrow.opacity = vX < leftBlock.width*0.5 && vX > -leftBlock.width*0.5 && vY < leftBlock.height*0.5 && vY > -leftBlock.height*0.5 ? 0.0 : 1.0
}
function testInside(pos,comp) {
var gComp = comp.mapToItem(root,0,0)
if (pos.x > gComp.x && pos.y > gComp.y) {
if (pos.x < gComp.x + comp.width && pos.y < gComp.y + comp.height) {
if (!cursorTimer.running) {
comp.border.width = comp.width*.08
nextVideo = comp
comp.loading = 0
cursorTimer.start()
}
return true
}
return false
}
return false
}
Timer {
id: cursorTimer
interval: 100
running: false
repeat: true
onTriggered: {
counter += 100
nextVideo.loading = counter/5000
if (counter > 5000) {
if (!sobre.visible && !videoTitle.visible && !detail.visible) {
showDetail()
}
cursorTimer.stop()
counter = 0
}
}
property int counter: 0
}
function testCursor() {
var gCursor = cursor.mapToItem(root, 0, 0)
if (!useGyro) { gCursor.x = currentTouch.x; gCursor.y = currentTouch.y }
var majorTest = false
fixArrows()
if (useGyro || (!useGyro && currentTouch.t)) {
if (!testInside(gCursor,b1T)) { b1T.zero() } else { majorTest = true }
if (!testInside(gCursor,b1B)) { b1B.zero() } else { majorTest = true }
if (!testInside(gCursor,b2T)) { b2T.zero() } else { majorTest = true }
if (!testInside(gCursor,b2B)) { b2B.zero() } else { majorTest = true }
if (!testInside(gCursor,b3T)) { b3T.zero() } else { majorTest = true }
if (!testInside(gCursor,b3B)) { b3B.zero() } else { majorTest = true }
}
if (!majorTest) { nextVideo.zero(); cursorTimer.counter = 0; cursorTimer.stop() }
}
function updateMenuPositionGyro() {
var vX = mainRoot.rotXY.x
var minX = -(leftImage.width - leftBlock.width)
if (vX > -20 && vX < 20) {
if (vX > -1.0 && vX < 1.0) { vX = 0 }
vX = vX * 1.5
leftImage.x = leftImage.x + vX > 0 ? 0 : leftImage.x + vX < minX ? minX : leftImage.x + vX
}
var pY = mainRoot.rotXY.y
var minY = -(leftImage.height - leftBlock.height)
leftImage.y = (1-pY)*minY
yScroll = pY
testCursor()
}
function getPosImage() {
return [leftImage.x,leftImage.y]
}
function updateMenuPositionTouch() {
var xDiff = mainRoot.accumTouch.x + mainRoot.accumTouchTemp.x
var yDiff = mainRoot.accumTouch.y + mainRoot.accumTouchTemp.y
var minX = -(leftImage.width - leftBlock.width)
var minY = -(leftImage.height - leftBlock.height)
leftImage.x = xDiff > 0 ? 0 : xDiff < minX ? minX : xDiff
leftImage.y = yDiff > 0 ? 0 : yDiff < minY ? minY : yDiff
if (yDiff > 0 || yDiff < minY) { mainRoot.hitwall() }
if (xDiff > 0 || xDiff < minX) { mainRoot.hitwall() }
yScroll = 1 - (-leftImage.y/(leftImage.height - leftBlock.height))
testCursor()
}
NumberAnimation {
id: fadeIn
target: root
property: "opacity"
duration: 1000
easing.type: Easing.InOutQuad
to: 1.0
onStarted: { root.visible = true }
onStopped: { fadeInEndCallback() }
}
NumberAnimation {
id: fadeOut
target: root
property: "opacity"
duration: 1000
easing.type: Easing.InOutQuad
to: 0.0
onStopped: {
root.visible = false
fadeOutCallback()
}
}
function show() { fadeIn.start() }
function hide() { fadeOut.start() }
Item {
id: masterStereoView
anchors.fill: parent
Item {
id: leftBlock
clip: true
width: stereo ? parent.width/2 : parent.width
height: parent.height
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
rotation: 0
Image {
id: leftImage
width: mainRoot.width*2.5
height: width*0.5625
fillMode: Image.PreserveAspectCrop
source: "qrc:/images/blender_L.jpg"
x: - (width*0.5 - parent.width*0.5)
y: - (height*0.5 - parent.height*0.5)
Item {
anchors.fill: parent
Rectangle {
anchors.centerIn: parent
width: parent.width*0.08
height: width*0.7
color: "#ccffffff"
radius: height*0.1
Image {
id: menuCenterLogo
width: parent.width
height: width
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
source: "qrc:/images/logo.svg"
}
}
}
}
Item {
id: leftHotspots
width: leftImage.width
height: leftImage.height
x: leftImage.x
y: leftImage.y
Item {
anchors.fill: parent
FloatButton {
id: b1T
x: parent.width*0.132
y: parent.height*0.200
imageFile: "qrc:/images/Icon_interrogacao.svg"
descricao: localeHelper.getSymbol("Option1Label")
video: "templateVideo"
nome: "Option1"
titulo: localeHelper.getSymbol("Option1Title")
videoCountdown: 28
}
FloatButton {
id: b1B
x: parent.width*0.132
y: parent.height*0.698
imageFile: "qrc:/images/Icon_interrogacao.svg"
descricao: localeHelper.getSymbol("Option2Label")
nome: "Option2"
video: "templateVideo"
titulo: localeHelper.getSymbol("Option2Title")
videoCountdown: 12
useTop: true
}
FloatButton {
id: b2T
x: parent.width*0.466
y: parent.height*0.200
imageFile: "qrc:/images/Icon_interrogacao.svg"
descricao: localeHelper.getSymbol("Option3Label")
nome: "Option3"
video: "templateVideo"
titulo: localeHelper.getSymbol("Option3Title")
videoCountdown: 62
}
FloatButton {
id: b2B
x: parent.width*0.466
y: parent.height*0.698
imageFile: "qrc:/images/Icon_interrogacao.svg"
descricao: localeHelper.getSymbol("Option4Label")
nome: "Option4"
video: "templateVideo"
titulo: localeHelper.getSymbol("Option4Title")
videoCountdown: 30
useTop: true
}
FloatButton {
id: b3T
x: parent.width*0.784
y: parent.height*0.200
imageFile: "qrc:/images/Icon_home.svg"
descricao: localeHelper.getSymbol("AboutTitle")
nome: "Sobre"
video: ""
}
FloatButton {
id: b3B
x: parent.width*0.787
y: parent.height*0.699
imageFile: "qrc:/images/Icon_home.svg"
descricao: localeHelper.getSymbol("StartTitle")
nome: "Inicio"
video: ""
useTop: true
}
}
}
Rectangle {
id: cursor
width: 10
opacity: 0.7
height: width
radius: 5
color: useGyro ? "white" : "#00000000"
anchors.centerIn: parent
Rectangle { id: arrowBlue; width: 20; height: 20; radius: 10; color: "steelblue" }
Rectangle { id: arrowRed; width: 20; height: 20; radius: 10; color: "red" }
Rectangle { id: arrowOrange; width: 20; height: 20; radius: 10; color: "orange" }
Rectangle { id: arrowBlack; width: 20; height: 20; radius: 10; color: "black" }
Rectangle { id: arrowWhite; width: 20; height: 20; radius: 10; color: "white" }
Rectangle { id: arrowGreen; width: 20; height: 20; radius: 10; color: "green" }
}
}
Item {
id: rightBlock
visible: stereo
clip: true
width: parent.width/2
height: parent.height
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
rotation: leftBlock.rotation
Image {
id: rightImage
width: leftImage.width
height: leftImage.height
fillMode: Image.PreserveAspectCrop
source: "qrc:/images/blender_R.jpg"
x: leftImage.x
y: leftImage.y
Item {
anchors.fill: parent
Rectangle {
anchors.centerIn: parent
width: parent.width*0.08
height: width*0.7
color: "#ccffffff"
radius: height*0.1
Image {
width: parent.width
height: width
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
source: menuCenterLogo.source
}
}
}
}
Item {
id: rightHotspots
width: rightImage.width
height: rightImage.height
x: rightImage.x
y: rightImage.y
Item {
anchors.fill: parent
FloatButton {
id: b1TR
x: b1T.x
y: b1T.y
imageFile: b1T.imageFile
descricao: b1T.descricao
border.width: b1T.border.width
loading: b1T.loading
}
FloatButton {
id: b1BR
x: b1B.x
y: b1B.y
imageFile: b1B.imageFile
descricao: b1B.descricao
border.width: b1B.border.width
useTop: true
loading: b1B.loading
}
FloatButton {
id: b2TR
x: b2T.x
y: b2T.y
imageFile: b2T.imageFile
descricao: b2T.descricao
border.width: b2T.border.width
loading: b2T.loading
}
FloatButton {
id: b2BR
x: b2B.x
y: b2B.y
imageFile: b2B.imageFile
descricao: b2B.descricao
border.width: b2B.border.width
useTop: true
loading: b2B.loading
}
FloatButton {
id: b3TR
x: b3T.x
y: b3T.y
imageFile: b3T.imageFile
descricao: b3T.descricao
border.width: b3T.border.width
loading: b3T.loading
}
FloatButton {
id: b3BR
x: b3B.x
y: b3B.y
imageFile: b3B.imageFile
descricao: b3B.descricao
border.width: b3B.border.width
useTop: true
loading: b3B.loading
}
}
}
}
}
Text {
id: rotUpdate
font.pixelSize: parent.height*0.05
text: "0"
opacity: 0.5
color: "white"
visible: false
}
}