Rename speed -> velocity in the particle system
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / AffectorElement.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 2.0
43 import QtQuick.Particles 2.0
44
45 Item {
46     id: affectorelementtest
47     anchors.fill: parent
48     property string testtext: ""
49
50     ParticleSystem {
51         id: particlesystem
52         anchors.fill: parent
53
54         ImageParticle {
55             id: imageparticle
56             source: "pics/star.png"
57             color: "blue"
58             entryEffect: ImageParticle.None
59             anchors.fill: parent
60         }
61
62         // Pipe
63         Rectangle {
64             id: pipe
65             x: 0; y: 300
66             border.color: "black"
67             gradient: Gradient {
68                 GradientStop { position: 0.0; color: "lightgray" }
69                 GradientStop { position: 1.0; color: "gray" }
70             }
71             height: 40; width: 40
72         }
73         Rectangle {
74             id: pipehead
75             anchors.left: pipe.right
76             anchors.verticalCenter: pipe.verticalCenter
77             border.color: "black"
78             gradient: Gradient {
79                 GradientStop { position: 0.0; color: "lightgray" }
80                 GradientStop { position: 1.0; color: "gray" }
81             }
82             height: 50; width: 10
83         }
84
85         Emitter {
86             id: emitterelement
87             anchors.left: pipe.left
88             anchors.leftMargin: 10
89             anchors.bottom: pipe.bottom
90             anchors.bottomMargin: 8
91             height: 5
92             emitRate: 100
93             lifeSpan: 10000
94             velocity: AngleDirection { angle: 0; magnitude: 30 }
95         }
96
97         // Affectors
98         Gravity {
99             id: gravity
100             x: pipe.width; y: pipe.y-100
101             enabled: false
102             height: 200
103             width: parent.width - pipe.width
104             angle: 90
105             acceleration: 30
106         }
107         Wander {
108             id: wander
109             enabled: false
110             anchors.verticalCenter: pipe.verticalCenter
111             anchors.left: pipe.right
112             height: pipe.height
113             width: 5
114             xVariance: 50
115             yVariance: 100
116             pace: 200
117         }
118         Turbulence {
119             id: turbulence
120             enabled: false
121             strength: 40
122             anchors.bottom: parent.bottom
123             anchors.bottomMargin: 100
124             width: parent.width; height: 100
125         }
126         Friction {
127             id: friction
128             anchors.bottom: parent.bottom; width: parent.width; height: 100
129             enabled: false
130             factor: 2
131         }
132         Age {
133             id: age
134             anchors.bottom: parent.bottom; width: 360; height: 5
135         }
136
137     }
138
139     SystemTestHelp { id: helpbubble; visible: statenum != 0
140         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
141     }
142     BugPanel { id: bugpanel }
143
144     states: [
145         State { name: "start"; when: statenum == 1
146             PropertyChanges { target: affectorelementtest
147                 testtext: "This is a group of currently disabled Affector elements. "+
148                 "A blue stream of particles should be flowing from a block to the left.\n"+
149                 "Next, let's add some variance in direction when the particles leave the block." }
150         },
151         State { name: "spread"; when: statenum == 2
152             PropertyChanges { target: wander; enabled: true }
153             PropertyChanges { target: affectorelementtest
154                 testtext: "The particles should be spreading out as they progress.\n"+
155                 "Next, let's introduce gravity." }
156         },
157         State { name: "gravity"; when: statenum == 3
158             PropertyChanges { target: wander; enabled: true }
159             PropertyChanges { target: gravity; enabled: true }
160             PropertyChanges { target: affectorelementtest
161             testtext: "The particles should now be dropping.\n"+
162                 "Also, no particles should be visible below the bounds of the application, "+
163                 "i.e. the white panel.\n"+
164                 "Next, let's introduce some friction at the bottom of the display." }
165         },
166         State { name: "friction"; when: statenum == 4
167             PropertyChanges { target: wander; enabled: true }
168             PropertyChanges { target: gravity; enabled: true }
169             PropertyChanges { target: friction; enabled: true }
170             PropertyChanges { target: affectorelementtest
171                 testtext: "The particles should now be decelerating suddenly at the bottom.\n"+
172                 "Next, let's add some turbulence to the flow." }
173         },
174         State { name: "turbulence"; when: statenum == 5
175             PropertyChanges { target: wander; enabled: true }
176             PropertyChanges { target: gravity; enabled: true }
177             PropertyChanges { target: friction; enabled: true }
178             PropertyChanges { target: turbulence; enabled: true }
179             PropertyChanges { target: affectorelementtest
180                 testtext: "The particles should now be turbulent.\n"+
181                 "Advance to restart the test." }
182         }
183     ]
184 }