c0ccd91696fd743cf9614cc710bd706f9efa21e6
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / ShapeElement.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: shapeelementtest
47     anchors.fill: parent
48     property string testtext: ""
49
50     ParticleSystem {
51         id: particlesystem
52         anchors.horizontalCenter: parent.horizontalCenter
53         anchors.bottom: parent.bottom
54         anchors.bottomMargin: 20
55         height: 300
56         width: 300
57
58         ImageParticle {
59             id: imageparticle
60             source: "pics/star.png"
61             color: "red"
62         }
63
64         Emitter {
65             id: emitter
66             property real magn: 0.1
67             anchors.fill: parent
68             emitRate: 500
69             lifeSpan: 2000
70             speed: TargetDirection {
71                 targetX: particlesystem.width/2
72                 targetY: particlesystem.height/2
73                 proportionalMagnitude: true
74                 magnitude: emitter.magn
75                 magnitudeVariation: emitter.magn
76             }
77             shape: rectangleshapeelement
78         }
79         Emitter {
80             id: emitter2
81             enabled: false
82             anchors.fill: parent
83             emitRate: 200
84             lifeSpan: 1000
85             speed: TargetDirection {
86                 targetX: particlesystem.width/2
87                 targetY: particlesystem.height/2
88                 proportionalMagnitude: true
89                 magnitude: 0
90                 magnitudeVariation: 0
91             }
92             shape: lineshapeelement2
93         }
94         // Shapes
95         EllipseShape {
96             id: ellipseshapeelement
97             fill: false
98         }
99         RectangleShape {
100             id: rectangleshapeelement
101             fill: false
102         }
103         LineShape {
104             id: lineshapeelement
105         }
106         LineShape {
107             id: lineshapeelement2
108             mirrored: true
109         }
110         MaskShape {
111             id: maskshapeelement
112             source: "pics/logo-hollowed.png"
113         }
114     }
115
116
117     SystemTestHelp { id: helpbubble; visible: statenum != 0
118         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
119     }
120     BugPanel { id: bugpanel }
121
122     states: [
123         State { name: "start"; when: statenum == 1
124             PropertyChanges { target: shapeelementtest
125                 testtext: "This is an Shape element, used by Emitter. There should be a rectangle "+
126                 "shape emitting into its center.\n"+
127                 "Next, let's change the shape to an ellipse." }
128         },
129         State { name: "ellipse"; when: statenum == 2
130             PropertyChanges { target: emitter; shape: ellipseshapeelement }
131             PropertyChanges { target: shapeelementtest
132                 testtext: "The particles should now be emitted in a circular shape.\n"+
133                 "Next, let's change the shape to a line." }
134         },
135         State { name: "line"; when: statenum == 3
136             PropertyChanges { target: emitter; shape: lineshapeelement; lifeSpan: 1000; emitRate: 200; }
137             PropertyChanges { target: emitter2; enabled: true }
138             PropertyChanges { target: shapeelementtest
139             testtext: "The particles should now be emitted from two lines, creating an X shape.\n"+
140                 "Next, let's change the shape to an image." }
141         },
142         State { name: "enduring"; when: statenum == 4
143             PropertyChanges { target: emitter; shape: maskshapeelement; lifeSpan: 1000; emitRate: 1000; magn: 0 }
144             PropertyChanges { target: shapeelementtest
145                 testtext: "The particles should now be sparkling, stationary within a 'Qt' text image.\n"+
146                 "Advance to restart the test." }
147         }
148     ]
149 }