Avoid dynamic lookup of signal handler arguments
[profile/ivi/qtdeclarative.git] / tests / testapplications / animatedsprite / animatedspriteadvance.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:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
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
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
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."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 2.0
42
43 Rectangle {
44     id: main
45
46     width: 320
47     height: 480
48     color: "lightgray"
49     Column {
50         Text { text: "Current frame: "+s1.currentFrame }
51         Text { text: "Delay: " + animcontroller.interval + "msec" }
52     }
53
54     Row {
55         height: parent.height / 3
56         anchors.horizontalCenter: parent.horizontalCenter
57         anchors.bottom: parent.bottom
58         spacing: 5
59         Column {
60             height: parent.height
61             width: 80
62             Text { id: bodytxt; width: parent.width; text: "Body"; horizontalAlignment: Text.AlignHCenter }
63             Rectangle {
64                 height: 30
65                 width: parent.width
66                 color: "white"
67                 MouseArea {
68                     anchors.fill: parent
69                     onClicked: { s1.source = "bear_polar.png" }
70                 }
71             }
72             Rectangle {
73                 height: 30
74                 width: parent.width
75                 color: "black"
76                 MouseArea {
77                     anchors.fill: parent
78                     onClicked: { s1.source = "bear_black.png" }
79                 }
80             }
81             Rectangle {
82                 height: 30
83                 width: parent.width
84                 color: "brown"
85                 MouseArea {
86                     anchors.fill: parent
87                     onClicked: { s1.source = "bear_brown.png" }
88                 }
89             }
90         }
91         Column {
92             height: parent.height
93             width: 80
94             Text { id: eyestxt; width: parent.width; text: "Eyes"; horizontalAlignment: Text.AlignHCenter }
95             Rectangle {
96                 height: 30
97                 width: parent.width
98                 color: "brown"
99                 MouseArea {
100                     anchors.fill: parent
101                     onClicked: { s2.source = "bear_eyes_brown.png" }
102                 }
103             }
104             Rectangle {
105                 height: 30
106                 width: parent.width
107                 color: "blue"
108                 MouseArea {
109                     anchors.fill: parent
110                     onClicked: { s2.source = "bear_eyes_blue.png" }
111                 }
112             }
113             Rectangle {
114                 height: 30
115                 width: parent.width
116                 color: "green"
117                 MouseArea {
118                     anchors.fill: parent
119                     onClicked: { s2.source = "bear_eyes_green.png" }
120                 }
121             }
122         }
123         Column {
124             height: parent.height
125             width: 80
126             Text { id: furtxt; width: parent.width; text: "Fur"; horizontalAlignment: Text.AlignHCenter }
127             Rectangle {
128                 height: 30
129                 width: parent.width
130                 color: "orange"
131                 MouseArea {
132                     anchors.fill: parent
133                     onClicked: { s3.source = "bear_fur_orange.png" }
134                 }
135             }
136             Rectangle {
137                 height: 30
138                 width: parent.width
139                 color: "gray"
140                 MouseArea {
141                     anchors.fill: parent
142                     onClicked: { s3.source = "bear_fur_gray.png" }
143                 }
144             }
145             Rectangle {
146                 height: 30
147                 width: parent.width
148                 color: "magenta"
149                 MouseArea {
150                     anchors.fill: parent
151                     onClicked: { s3.source = "bear_fur_pink.png" }
152                 }
153             }
154         }
155     }
156
157     function advanceall() {
158         s1.advance();
159         s2.advance();
160         s3.advance();
161         if (s2.currentFrame!=s1.currentFrame || s3.currentFrame!=s1.currentFrame)
162             console.log("Frames out of sync!")
163     }
164
165     AnimatedSprite {
166         id: s1
167         x: 100
168         y: 100
169         running: true
170         paused: true
171         height: 125
172         width: 125
173         frameCount: 13
174         interpolate: false
175         source: "bear_brown.png"
176     }
177
178     AnimatedSprite {
179         id: s2
180         anchors.fill: s1
181         running: true
182         paused: s1.paused
183         frameCount: 13
184         interpolate: false
185         source: "bear_eyes_brown.png"
186         onSourceChanged: { currentFrame = s1.currentFrame }
187     }
188
189     AnimatedSprite {
190         id: s3
191         anchors.fill: s1
192         running: true
193         paused: s1.paused
194         frameCount: 13
195         interpolate: false
196         source: "bear_fur_orange.png"
197         onSourceChanged: { currentFrame = s1.currentFrame }
198     }
199
200     Timer { id: animcontroller; interval: 75; running: true; repeat: true; onTriggered: { advanceall(); } }
201 }