Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicksprite_p.h
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 Declarative module 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 #ifndef QQUICKSPRITE_P_H
43 #define QQUICKSPRITE_P_H
44
45 #include <QObject>
46 #include <QUrl>
47 #include <QVariantMap>
48 #include <QDeclarativeListProperty>
49 #include "qquickspriteengine_p.h"
50
51 QT_BEGIN_HEADER
52
53 QT_BEGIN_NAMESPACE
54
55 class QQuickSprite : public QQuickStochasticState
56 {
57     Q_OBJECT
58     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
59     //Renderers have to query this hint when advancing frames
60     Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
61     Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
62     Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
63     //If frame height or width is not specified, it is assumed to be a single long row of square frames.
64     //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
65     Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
66     Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
67     Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged)
68     Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged)
69     //Precedence order: frameRate, frameDuration, duration
70     Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate)
71     Q_PROPERTY(qreal frameRateVariation READ frameRateVariation WRITE setFrameRateVariation NOTIFY frameRateVariationChanged)
72     Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
73     Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged)
74
75 public:
76     explicit QQuickSprite(QObject *parent = 0);
77
78     QUrl source() const
79     {
80         return m_source;
81     }
82
83     int frameHeight() const
84     {
85         return m_frameHeight;
86     }
87
88     int frameWidth() const
89     {
90         return m_frameWidth;
91     }
92
93
94     bool reverse() const
95     {
96         return m_reverse;
97     }
98
99     int frames() const
100     {
101         return m_frames;
102     }
103
104     int frameX() const
105     {
106         return m_frameX;
107     }
108
109     int frameY() const
110     {
111         return m_frameY;
112     }
113
114     void resetFrameRate()
115     {
116         setFrameRate(-1);
117     }
118
119     qreal frameRate() const
120     {
121         return m_frameRate;
122     }
123
124     qreal frameRateVariation() const
125     {
126         return m_frameRateVariation;
127     }
128
129     void resetFrameDuration()
130     {
131         setFrameDuration(-1);
132     }
133
134     int frameDuration() const
135     {
136         return m_frameDuration;
137     }
138
139     int frameDurationVariation() const
140     {
141         return m_frameDurationVariation;
142     }
143
144     int variedDuration() const;
145
146     bool frameSync() const
147     {
148         return m_frameSync;
149     }
150
151 signals:
152
153     void sourceChanged(QUrl arg);
154
155     void frameHeightChanged(int arg);
156
157     void frameWidthChanged(int arg);
158
159     void reverseChanged(bool arg);
160
161     void framesChanged(int arg);
162
163     void frameXChanged(int arg);
164
165     void frameYChanged(int arg);
166
167     void frameRateChanged(qreal arg);
168
169     void frameRateVariationChanged(qreal arg);
170
171     void frameDurationChanged(int arg);
172
173     void frameDurationVariationChanged(int arg);
174
175     void frameSyncChanged(bool arg);
176
177 public slots:
178
179     void setSource(QUrl arg)
180     {
181         if (m_source != arg) {
182             m_source = arg;
183             emit sourceChanged(arg);
184         }
185     }
186
187     void setFrameHeight(int arg)
188     {
189         if (m_frameHeight != arg) {
190             m_frameHeight = arg;
191             emit frameHeightChanged(arg);
192         }
193     }
194
195     void setFrameWidth(int arg)
196     {
197         if (m_frameWidth != arg) {
198             m_frameWidth = arg;
199             emit frameWidthChanged(arg);
200         }
201     }
202
203
204     void setReverse(bool arg)
205     {
206         if (m_reverse != arg) {
207             m_reverse = arg;
208             emit reverseChanged(arg);
209         }
210     }
211
212     void setFrames(int arg)
213     {
214         if (m_frames != arg) {
215             m_frames = arg;
216             emit framesChanged(arg);
217         }
218     }
219
220     void setFrameX(int arg)
221     {
222         if (m_frameX != arg) {
223             m_frameX = arg;
224             emit frameXChanged(arg);
225         }
226     }
227
228     void setFrameY(int arg)
229     {
230         if (m_frameY != arg) {
231             m_frameY = arg;
232             emit frameYChanged(arg);
233         }
234     }
235
236     void setFrameRate(qreal arg)
237     {
238         if (m_frameRate != arg) {
239             m_frameRate = arg;
240             emit frameRateChanged(arg);
241         }
242     }
243
244     void setFrameRateVariation(qreal arg)
245     {
246         if (m_frameRateVariation != arg) {
247             m_frameRateVariation = arg;
248             emit frameRateVariationChanged(arg);
249         }
250     }
251
252     void setFrameDuration(int arg)
253     {
254         if (m_frameDuration != arg) {
255             m_frameDuration = arg;
256             emit frameDurationChanged(arg);
257         }
258     }
259
260     void setFrameDurationVariation(int arg)
261     {
262         if (m_frameDurationVariation != arg) {
263             m_frameDurationVariation = arg;
264             emit frameDurationVariationChanged(arg);
265         }
266     }
267
268     void setFrameSync(bool arg)
269     {
270         if (m_frameSync != arg) {
271             m_frameSync = arg;
272             emit frameSyncChanged(arg);
273         }
274     }
275
276 private:
277     friend class QQuickImageParticle;
278     friend class QQuickSpriteImage;
279     friend class QQuickSpriteEngine;
280     friend class QQuickStochasticEngine;
281     int m_generatedCount;
282     int m_framesPerRow;
283     int m_rowY;
284     int m_rowStartX;
285
286     QUrl m_source;
287     bool m_reverse;
288     int m_frameHeight;
289     int m_frameWidth;
290     int m_frames;
291     int m_frameX;
292     int m_frameY;
293     qreal m_frameRate;
294     qreal m_frameRateVariation;
295     int m_frameDuration;
296     int m_frameDurationVariation;
297     bool m_frameSync;
298 };
299
300 QT_END_NAMESPACE
301 QT_END_HEADER
302 #endif // QQUICKSPRITE_P_H