c6c1dbc545c05bd9678d2dbb8ee554d4d55065ff
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / DirectionElement.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: directionelementtest
47     anchors.fill: parent
48     property string testtext: ""
49
50     ParticleSystem {
51         id: particlesystem
52         anchors.fill: parent
53         Item {
54             id: targetbox
55             x: 50
56             y: 300
57             Rectangle {
58                 id: targeticon
59                 color: "brown"
60                 height: 0; width: 0; radius: 20
61                 anchors.centerIn: parent
62                 Behavior on height { NumberAnimation { duration: 500; easing.type: Easing.OutBounce } }
63                 Behavior on width { NumberAnimation { duration: 500; easing.type: Easing.OutBounce } }
64             }
65         }
66         ImageParticle {
67             id: imgparticle
68             source: "pics/star.png"
69             color: "red"
70             entryEffect: ImageParticle.None
71         }
72         Emitter {
73             id: emitter
74             anchors.bottom: parent.bottom
75             anchors.bottomMargin: 5
76             anchors.horizontalCenter: parent.horizontalCenter
77             emitRate: 50
78             lifeSpan: 4000
79             size: 20
80             speed: angledirectionelement
81             AngleDirection { id: angledirectionelement; angle: -75; angleVariation: 5; magnitude: 150 }
82             TargetDirection { id: targetdirectionelement; targetItem: targetbox; targetVariation: 10; magnitude: 150 }
83             PointDirection { id: pointdirectionelement; y: -100; xVariation: 10; yVariation: 10; }
84             PointDirection { id: pointdirectionelementdownward; y: 200 }
85             CumulativeDirection {
86                 id: cumulativedirectionelement
87                 PointDirection { y: -200 }
88                 AngleDirection { angle: 270; angleVariation: 45; magnitude: 100; magnitudeVariation: 10; }
89             }
90         }
91     }
92
93     SystemTestHelp { id: helpbubble; visible: statenum != 0
94         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
95     }
96     BugPanel { id: bugpanel }
97
98     states: [
99         State { name: "start"; when: statenum == 1
100             PropertyChanges { target: directionelementtest
101                 testtext: "This is an Emitter with the direction set by an AngleDirection.\n"+
102                 "The particles should be firing at a -75 degree (to the top right) .\n"+
103                 "Next, let's change the Emitter to target an item." }
104         },
105         State { name: "ontarget"; when: statenum == 2
106             PropertyChanges { target: emitter; speed: targetdirectionelement }
107             PropertyChanges { target: targeticon; height: 50; width: 50 }
108             PropertyChanges { target: directionelementtest
109                 testtext: "The particles should be directed at the rectangle.\n"+
110                 "Next, let's set an arbritary point to direct the particles to." }
111         },
112         State { name: "onpoint"; when: statenum == 3
113             PropertyChanges { target: emitter; speed: pointdirectionelement }
114             PropertyChanges { target: directionelementtest
115                 testtext: "The particles should be directed upwards with a small amount of spread.\n"+
116                 "Next, let's create a fountain with CumulativeDirection and a downward PointDirection" }
117         },
118         State { name: "cumulative"; when: statenum == 4
119             PropertyChanges { target: emitter; emitRate: 200; speed: cumulativedirectionelement
120                 acceleration: pointdirectionelementdownward }
121             PropertyChanges { target: imgparticle; color: "aqua"; colorVariation: .2 }
122             PropertyChanges { target: directionelementtest
123                 testtext: "The particles should be flowing upwards and falling in a fountain effect.\n"+
124                 "Advance to restart the test." }
125         }
126     ]
127 }