1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the Declarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQUICKSPRITE_P_H
43 #define QQUICKSPRITE_P_H
47 #include <QVariantMap>
48 #include <QDeclarativeListProperty>
49 #include "qquickspriteengine_p.h"
55 class QQuickSprite : public QQuickStochasticState
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)
76 explicit QQuickSprite(QObject *parent = 0);
83 int frameHeight() const
88 int frameWidth() const
114 void resetFrameRate()
119 qreal frameRate() const
124 qreal frameRateVariation() const
126 return m_frameRateVariation;
129 void resetFrameDuration()
131 setFrameDuration(-1);
134 int frameDuration() const
136 return m_frameDuration;
139 int frameDurationVariation() const
141 return m_frameDurationVariation;
144 int variedDuration() const;
146 bool frameSync() const
153 void sourceChanged(QUrl arg);
155 void frameHeightChanged(int arg);
157 void frameWidthChanged(int arg);
159 void reverseChanged(bool arg);
161 void framesChanged(int arg);
163 void frameXChanged(int arg);
165 void frameYChanged(int arg);
167 void frameRateChanged(qreal arg);
169 void frameRateVariationChanged(qreal arg);
171 void frameDurationChanged(int arg);
173 void frameDurationVariationChanged(int arg);
175 void frameSyncChanged(bool arg);
179 void setSource(QUrl arg)
181 if (m_source != arg) {
183 emit sourceChanged(arg);
187 void setFrameHeight(int arg)
189 if (m_frameHeight != arg) {
191 emit frameHeightChanged(arg);
195 void setFrameWidth(int arg)
197 if (m_frameWidth != arg) {
199 emit frameWidthChanged(arg);
204 void setReverse(bool arg)
206 if (m_reverse != arg) {
208 emit reverseChanged(arg);
212 void setFrames(int arg)
214 if (m_frames != arg) {
216 emit framesChanged(arg);
220 void setFrameX(int arg)
222 if (m_frameX != arg) {
224 emit frameXChanged(arg);
228 void setFrameY(int arg)
230 if (m_frameY != arg) {
232 emit frameYChanged(arg);
236 void setFrameRate(qreal arg)
238 if (m_frameRate != arg) {
240 emit frameRateChanged(arg);
244 void setFrameRateVariation(qreal arg)
246 if (m_frameRateVariation != arg) {
247 m_frameRateVariation = arg;
248 emit frameRateVariationChanged(arg);
252 void setFrameDuration(int arg)
254 if (m_frameDuration != arg) {
255 m_frameDuration = arg;
256 emit frameDurationChanged(arg);
260 void setFrameDurationVariation(int arg)
262 if (m_frameDurationVariation != arg) {
263 m_frameDurationVariation = arg;
264 emit frameDurationVariationChanged(arg);
268 void setFrameSync(bool arg)
270 if (m_frameSync != arg) {
272 emit frameSyncChanged(arg);
277 friend class QQuickImageParticle;
278 friend class QQuickSpriteImage;
279 friend class QQuickSpriteEngine;
280 friend class QQuickStochasticEngine;
281 int m_generatedCount;
294 qreal m_frameRateVariation;
296 int m_frameDurationVariation;
302 #endif // QQUICKSPRITE_P_H