1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQuick module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #ifndef QQUICKSPRITE_P_H
43 #define QQUICKSPRITE_P_H
47 #include <QVariantMap>
48 #include <QQmlListProperty>
49 #include <QtQuick/private/qquickpixmapcache_p.h>
50 #include "qquickspriteengine_p.h"
57 class QQuickSprite : public QQuickStochasticState
60 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
61 //Renderers have to query this hint when advancing frames
62 Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
63 Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
64 Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged)
65 Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
66 //If frame height or width is not specified, it is assumed to be a single long row of square frames.
67 //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
68 Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
69 Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
70 Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged)
71 Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged)
72 //Precedence order: frameRate, frameDuration, duration
73 Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate)
74 Q_PROPERTY(qreal frameRateVariation READ frameRateVariation WRITE setFrameRateVariation NOTIFY frameRateVariationChanged)
75 Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
76 Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged)
79 explicit QQuickSprite(QObject *parent = 0);
86 int frameHeight() const
91 int frameWidth() const
106 int frameCount() const
121 void resetFrameRate()
126 qreal frameRate() const
131 qreal frameRateVariation() const
133 return m_frameRateVariation;
136 void resetFrameDuration()
138 setFrameDuration(-1);
141 int frameDuration() const
143 return m_frameDuration;
146 int frameDurationVariation() const
148 return m_frameDurationVariation;
151 int variedDuration() const;
153 bool frameSync() const
160 void sourceChanged(QUrl arg);
162 void frameHeightChanged(int arg);
164 void frameWidthChanged(int arg);
166 void reverseChanged(bool arg);
168 void frameCountChanged(int arg);
170 void frameXChanged(int arg);
172 void frameYChanged(int arg);
174 void frameRateChanged(qreal arg);
176 void frameRateVariationChanged(qreal arg);
178 void frameDurationChanged(int arg);
180 void frameDurationVariationChanged(int arg);
182 void frameSyncChanged(bool arg);
186 void setSource(QUrl arg)
188 if (m_source != arg) {
190 emit sourceChanged(arg);
195 void setFrameHeight(int arg)
197 if (m_frameHeight != arg) {
199 emit frameHeightChanged(arg);
203 void setFrameWidth(int arg)
205 if (m_frameWidth != arg) {
207 emit frameWidthChanged(arg);
211 void setReverse(bool arg)
213 if (m_reverse != arg) {
215 emit reverseChanged(arg);
219 void setFrames(int arg)
221 qWarning() << "Sprite::frames has been renamed Sprite::frameCount";
225 void setFrameCount(int arg)
227 if (m_frames != arg) {
229 emit frameCountChanged(arg);
233 void setFrameX(int arg)
235 if (m_frameX != arg) {
237 emit frameXChanged(arg);
241 void setFrameY(int arg)
243 if (m_frameY != arg) {
245 emit frameYChanged(arg);
249 void setFrameRate(qreal arg)
251 if (m_frameRate != arg) {
253 emit frameRateChanged(arg);
257 void setFrameRateVariation(qreal arg)
259 if (m_frameRateVariation != arg) {
260 m_frameRateVariation = arg;
261 emit frameRateVariationChanged(arg);
265 void setFrameDuration(int arg)
267 if (m_frameDuration != arg) {
268 m_frameDuration = arg;
269 emit frameDurationChanged(arg);
273 void setFrameDurationVariation(int arg)
275 if (m_frameDurationVariation != arg) {
276 m_frameDurationVariation = arg;
277 emit frameDurationVariationChanged(arg);
281 void setFrameSync(bool arg)
283 if (m_frameSync != arg) {
285 emit frameSyncChanged(arg);
290 void startImageLoading();
293 friend class QQuickImageParticle;
294 friend class QQuickSpriteSequence;
295 friend class QQuickAnimatedSprite;
296 friend class QQuickSpriteEngine;
297 friend class QQuickStochasticEngine;
298 int m_generatedCount;
311 qreal m_frameRateVariation;
313 int m_frameDurationVariation;
320 #endif // QQUICKSPRITE_P_H