1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the test suite of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:BSD$
9
** You may use this file under the terms of the BSD license as follows:
11
** "Redistribution and use in source and binary forms, with or without
12
** modification, are permitted provided that the following conditions are
14
** * Redistributions of source code must retain the above copyright
15
** notice, this list of conditions and the following disclaimer.
16
** * Redistributions in binary form must reproduce the above copyright
17
** notice, this list of conditions and the following disclaimer in
18
** the documentation and/or other materials provided with the
20
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21
** of its contributors may be used to endorse or promote products derived
22
** from this software without specific prior written permission.
25
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39
****************************************************************************/
42
import QtQuick.Particles 2.0
45
width: 450; height: 600
47
property int currentSet: 0
48
property bool useStock: false
55
property bool movn: false
58
width: 225; height: 40
59
border.width: ListView.isCurrentItem ? 3 : 1
60
z: ListView.isCurrentItem ? 100 : 1
61
color: original ? "lightsteelblue" : "yellow"
63
Text { x: 10; text: name; font.pixelSize: 20 }
64
MouseArea { anchors.fill: parent; onClicked: listview.currentIndex = index }
71
velocity: AngleDirection {
75
magnitudeVariation: 50
84
velocity: AngleDirection {
96
width: 225; height: 500
97
anchors.centerIn: parent
98
delegate: viewDelegate
100
height: 50; width: 225
102
Text { anchors.centerIn: parent; text: "Transitions!"; color: "goldenrod" }
106
ListElement { name: "Item A"; original: true }
107
ListElement { name: "Item B"; original: true }
108
ListElement { name: "Item C"; original: true }
109
ListElement { name: "Item D"; original: true }
110
ListElement { name: "Item E"; original: true }
111
ListElement { name: "Item F"; original: true }
116
border.color: "black"
131
/* States (Selected operation Transitions) */
135
when: currentSet == 0
141
displaced: a_displaced
146
when: currentSet == 1
152
displaced: b_displaced
157
when: currentSet == 2
163
addDisplaced: c_addDisplaced
164
moveDisplaced: c_moveDisplaced
165
removeDisplaced: c_removeDisplaced
170
when: currentSet == 3
174
moveDisplaced: d_moveDisplaced
187
NumberAnimation { target: a_add.ViewTransition.item; properties: "opacity"; from: 0; to: 1; duration: 1000 }
192
SequentialAnimation {
193
NumberAnimation { target: a_remove.ViewTransition.item; properties: "opacity"; from: 1; to: 0; duration: 1000 }
198
ColorAnimation { target: a_move.ViewTransition.item; properties: "color"; to: "lightsteelblue"; duration: 1000 }
201
target: a_move.ViewTransition.item
203
PathCurve { x: a_move.ViewTransition.destination.x + 150; y: a_move.ViewTransition.destination.y + 100 }
204
PathCurve { x: a_move.ViewTransition.destination.x + 150; y: a_move.ViewTransition.destination.y }
205
PathCurve { x: a_move.ViewTransition.destination.x; y: a_move.ViewTransition.destination.y }
211
PropertyAction { target: a_displaced.ViewTransition.item; property: "color"; value: "lightsteelblue" }
213
NumberAnimation { target: a_displaced.ViewTransition.item; property: "opacity"; to: 1; duration: 250 }
214
SequentialAnimation {
215
PauseAnimation { duration: a_displaced.ViewTransition.index * 200 }
216
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutQuad }
224
SequentialAnimation {
225
NumberAnimation { target: b_add.ViewTransition.item; properties: "scale"; from: 1; to: 1.3; duration: 100 }
226
NumberAnimation { target: b_add.ViewTransition.item; properties: "scale"; from: 1.3; to: 1; duration: 500; easing.type: Easing.OutBounce }
231
SequentialAnimation {
232
PauseAnimation { duration: b_move.ViewTransition.index * 100 }
234
ColorAnimation { target: b_move.ViewTransition.item; properties: "color"; from: "red"; to: "lightsteelblue"; duration: 2000 }
235
SequentialAnimation {
238
target: b_move.ViewTransition.item
240
PathCurve { x: b_move.ViewTransition.destination.x + 150; y: b_move.ViewTransition.destination.y + 100 }
241
PathCurve { relativeX: 30; relativeY: -100 }
244
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutBounce }
251
SequentialAnimation {
252
NumberAnimation { target: b_remove.ViewTransition.item; properties: "opacity"; from: 1; to: 0; duration: 1000 }
257
PropertyAction { target: b_displaced.ViewTransition.item; property: "color"; value: "lightsteelblue" }
258
SequentialAnimation {
259
PauseAnimation { duration: b_displaced.ViewTransition.item.x == 0 ? b_displaced.ViewTransition.index * 200 : 0 }
260
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutBounce }
267
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 }
268
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 }
270
xoff: c_add.ViewTransition.index % 2 == 0 ? 200 : -200
274
startX: c_add.ViewTransition.destination.x + c_add.xoff
275
startY: c_add.ViewTransition.destination.y + 200
276
PathCurve { relativeX: -100; relativeY: -50 }
277
PathCurve { relativeX: 50; relativeY: -150 }
279
x: c_add.ViewTransition.destination.x
280
y: c_add.ViewTransition.destination.y
287
ColorAnimation { target: c_move.ViewTransition.item; properties: "color"; from: "red"; to: "lightsteelblue"; duration: 1000 }
290
target: c_move.ViewTransition.item
292
PathCurve { x: c_move.ViewTransition.destination.x + 150; y: c_move.ViewTransition.destination.y + 100 }
293
PathCurve { x: c_move.ViewTransition.destination.x + 150; y: c_move.ViewTransition.destination.y }
294
PathCurve { x: c_move.ViewTransition.destination.x; y: c_move.ViewTransition.destination.y }
300
PropertyAnimation { target: c_remove.ViewTransition.item; properties: "opacity"; to: 0; duration: 3000; easing.type: Easing.OutInBounce }
305
PropertyAction { property: "color"; value: "lightsteelblue" }
306
PropertyAction { property: "opacity"; value: 1.0 }
307
PropertyAction { property: "scale"; value: 1.0 }
308
SequentialAnimation {
309
PauseAnimation { duration: c_addDisplaced.ViewTransition.index * 200 }
310
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutElastic }
317
PropertyAction { property: "color"; value: "lightsteelblue" }
318
PropertyAction { property: "opacity"; value: 1.0 }
319
PropertyAction { property: "scale"; value: 1.0 }
320
SequentialAnimation {
321
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutBounce }
326
id: c_removeDisplaced
328
PropertyAction { property: "color"; value: "lightsteelblue" }
329
PropertyAction { property: "opacity"; value: 1.0 }
330
PropertyAction { property: "scale"; value: 1.0 }
331
SequentialAnimation {
332
PauseAnimation { duration: (c_removeDisplaced.ViewTransition.index * 200) + 3000 }
333
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutElastic }
339
SequentialAnimation {
340
PropertyAction { target: d_move.ViewTransition.item; property: "movn"; value: true }
342
NumberAnimation { target: d_move.ViewTransition.item; properties: "opacity"; to: 0; duration: 2000 }
343
NumberAnimation { target: d_move.ViewTransition.item; properties: "parts"; to: 500; duration: 2000 }
345
NumberAnimation { properties: "x,y"; duration: 1000*(d_move.ViewTransition.index+1) }
347
NumberAnimation { target: d_move.ViewTransition.item; properties: "opacity"; to: 1; duration: 2000 }
348
NumberAnimation { target: d_move.ViewTransition.item; properties: "parts"; to: 0; duration: 2000 }
350
PropertyAction { target: d_move.ViewTransition.item; property: "movn"; value: false }
356
PropertyAction { target: d_moveDisplaced.ViewTransition.item; property: "color"; value: "lightsteelblue" }
357
SequentialAnimation {
358
PauseAnimation { duration: 500*(d_moveDisplaced.ViewTransition.index+1) }
359
NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutQuad }
368
GradientStop { position: 0.0; color: "darkgray" }
369
GradientStop { position: 0.5; color: "lightgray" }
370
GradientStop { position: 1.0; color: "darkgray" }
373
border.color: "black"
374
height: 50; width: 80
375
Text { anchors.centerIn: parent; text: "To Top" }
376
MouseArea { anchors.fill: parent; onClicked: listview.model.move(listview.currentIndex, 0, 1) }
380
GradientStop { position: 0.0; color: "darkgray" }
381
GradientStop { position: 0.5; color: "lightgray" }
382
GradientStop { position: 1.0; color: "darkgray" }
385
border.color: "black"
386
height: 50; width: 80
387
Text { anchors.centerIn: parent; text: "Add" }
390
onClicked: listview.model.insert(listview.currentIndex+1, {"name": "New item", "original": false } )
395
GradientStop { position: 0.0; color: "darkgray" }
396
GradientStop { position: 0.5; color: "lightgray" }
397
GradientStop { position: 1.0; color: "darkgray" }
400
border.color: "black"
401
height: 50; width: 80
402
Text { anchors.centerIn: parent; text: "Remove" }
405
onClicked: listview.model.remove(listview.currentIndex)
410
GradientStop { position: 0.0; color: "darkgray" }
411
GradientStop { position: 0.5; color: "lightgray" }
412
GradientStop { position: 1.0; color: "darkgray" }
415
border.color: "black"
416
height: 50; width: 80
417
Text { anchors.centerIn: parent; text: "Append" }
420
onClicked: listview.model.append({"name": "New item", "original": false })
426
anchors.right: parent.right
427
anchors.rightMargin: 2
430
GradientStop { position: 0.0; color: "darkgray" }
431
GradientStop { position: 0.5; color: currentSet == 0 ? "green" : "lightgray"
432
ColorAnimation on color { duration: 1000 }
434
GradientStop { position: 1.0; color: "darkgray" }
437
border.color: "black"
438
height: 50; width: 80
439
Text { anchors.centerIn: parent; text: "Set A" }
440
MouseArea { anchors.fill: parent; onClicked: { currentSet = 0 } }
444
GradientStop { position: 0.0; color: "darkgray" }
445
GradientStop { position: 0.5; color: currentSet == 1 ? "green" : "lightgray" }
446
GradientStop { position: 1.0; color: "darkgray" }
449
border.color: "black"
450
height: 50; width: 80
451
Text { anchors.centerIn: parent; text: "Set B" }
452
MouseArea { anchors.fill: parent; onClicked: { currentSet = 1 } }
456
GradientStop { position: 0.0; color: "darkgray" }
457
GradientStop { position: 0.5; color: currentSet == 2 ? "green" : "lightgray" }
458
GradientStop { position: 1.0; color: "darkgray" }
461
border.color: "black"
462
height: 50; width: 80
463
Text { anchors.centerIn: parent; text: "Set C" }
464
MouseArea { anchors.fill: parent; onClicked: { currentSet = 2 } }
468
GradientStop { position: 0.0; color: "darkgray" }
469
GradientStop { position: 0.5; color: currentSet == 3 ? "green" : "lightgray" }
470
GradientStop { position: 1.0; color: "darkgray" }
473
border.color: "black"
474
height: 50; width: 80
475
Text { anchors.centerIn: parent; text: "Set D" }
476
MouseArea { anchors.fill: parent; onClicked: { currentSet = 3 } }