Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquicksprite_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKSPRITE_P_H
5#define QQUICKSPRITE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qtquickglobal_p.h>
19
20QT_REQUIRE_CONFIG(quick_sprite);
21
22#include <QObject>
23#include <QUrl>
24#include <QVariantMap>
25#include <QQmlListProperty>
26#include <QtQuick/private/qquickpixmap_p.h>
28#include <QDebug>
29
31
32// exported, since it's used in QtQuickParticles
33class Q_QUICK_EXPORT QQuickSprite : public QQuickStochasticState
34{
36 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
37 //Renderers have to query this hint when advancing frames
38 Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
39 Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
40 Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged)
41 Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
42 //If frame height or width is not specified, it is assumed to be a single long row of square frames.
43 //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
44 Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
45 Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
46 Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged)
47 Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged)
48 //Precedence order: frameRate, frameDuration, duration
49 Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate)
50 Q_PROPERTY(qreal frameRateVariation READ frameRateVariation WRITE setFrameRateVariation NOTIFY frameRateVariationChanged)
51 Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
52 Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged)
53 QML_NAMED_ELEMENT(Sprite)
55
56public:
57 explicit QQuickSprite(QObject *parent = nullptr);
58 ~QQuickSprite() override;
59
60 QUrl source() const
61 {
62 return m_source;
63 }
64
65 int frameHeight() const
66 {
67 return m_frameHeight;
68 }
69
70 int frameWidth() const
71 {
72 return m_frameWidth;
73 }
74
75 bool reverse() const
76 {
77 return m_reverse;
78 }
79
80 int frames() const
81 {
82 return m_frames;
83 }
84
85 int frameCount() const
86 {
87 return m_frames;
88 }
89
90 int frameX() const
91 {
92 return m_frameX;
93 }
94
95 int frameY() const
96 {
97 return m_frameY;
98 }
99
101 {
102 setFrameRate(-1);
103 }
104
106 {
107 return m_frameRate;
108 }
109
111 {
112 return m_frameRateVariation;
113 }
114
116 {
117 setFrameDuration(-1);
118 }
119
120 int frameDuration() const
121 {
122 return m_frameDuration;
123 }
124
126 {
127 return m_frameDurationVariation;
128 }
129
130 int variedDuration() const override;
131
132 bool frameSync() const
133 {
134 return m_frameSync;
135 }
136
138 {
139 m_devicePixelRatio = dpr;
140 }
141
143 {
144 return m_devicePixelRatio;
145 }
146
148
150
152
154
155 void reverseChanged(bool arg);
156
158
160
162
164
166
168
170
172
173public Q_SLOTS:
174
176 {
177 if (m_source != arg) {
178 m_source = arg;
179 Q_EMIT sourceChanged(arg);
180 startImageLoading();
181 }
182 }
183
185 {
186 if (m_frameHeight != arg) {
187 m_frameHeight = arg;
188 Q_EMIT frameHeightChanged(arg);
189 }
190 }
191
193 {
194 if (m_frameWidth != arg) {
195 m_frameWidth = arg;
196 Q_EMIT frameWidthChanged(arg);
197 }
198 }
199
200 void setReverse(bool arg)
201 {
202 if (m_reverse != arg) {
203 m_reverse = arg;
204 Q_EMIT reverseChanged(arg);
205 }
206 }
207
208 void setFrames(int arg)
209 {
210 qWarning() << "Sprite::frames has been renamed Sprite::frameCount";
211 setFrameCount(arg);
212 }
213
215 {
216 if (m_frames != arg) {
217 m_frames = arg;
218 Q_EMIT frameCountChanged(arg);
219 }
220 }
221
222 void setFrameX(int arg)
223 {
224 if (m_frameX != arg) {
225 m_frameX = arg;
226 Q_EMIT frameXChanged(arg);
227 }
228 }
229
230 void setFrameY(int arg)
231 {
232 if (m_frameY != arg) {
233 m_frameY = arg;
234 Q_EMIT frameYChanged(arg);
235 }
236 }
237
239 {
240 if (m_frameRate != arg) {
241 m_frameRate = arg;
242 Q_EMIT frameRateChanged(arg);
243 }
244 }
245
247 {
248 if (m_frameRateVariation != arg) {
249 m_frameRateVariation = arg;
250 Q_EMIT frameRateVariationChanged(arg);
251 }
252 }
253
255 {
256 if (m_frameDuration != arg) {
257 m_frameDuration = arg;
258 Q_EMIT frameDurationChanged(arg);
259 }
260 }
261
263 {
264 if (m_frameDurationVariation != arg) {
265 m_frameDurationVariation = arg;
266 Q_EMIT frameDurationVariationChanged(arg);
267 }
268 }
269
270 void setFrameSync(bool arg)
271 {
272 if (m_frameSync != arg) {
273 m_frameSync = arg;
274 Q_EMIT frameSyncChanged(arg);
275 }
276 }
277
278private Q_SLOTS:
279 void startImageLoading();
280
281private:
283 //friend class QQuickSpriteSequence;
285 friend class QQuickSpriteEngine;
287
288 int m_generatedCount;
289 int m_framesPerRow;
290 int m_rowY;
291 int m_rowStartX;
292
293 QUrl m_source;
294 bool m_reverse;
295 int m_frameHeight;
296 int m_frameWidth;
297 int m_frames;
298 int m_frameX;
299 int m_frameY;
300 qreal m_frameRate;
301 qreal m_frameRateVariation;
302 int m_frameDuration;
303 int m_frameDurationVariation;
304 bool m_frameSync;
305 qreal m_devicePixelRatio;
306 QQuickPixmap m_pix;
307};
308
310
311#endif // QQUICKSPRITE_P_H
\inmodule QtCore
Definition qobject.h:103
void setReverse(bool arg)
int frameDurationVariation() const
int frames() const
void setFrames(int arg)
void frameCountChanged(int arg)
void frameWidthChanged(int arg)
void setFrameHeight(int arg)
qreal devicePixelRatio() const
void resetFrameRate()
bool frameSync() const
void setFrameY(int arg)
void setFrameWidth(int arg)
int frameHeight() const
qreal frameRate() const
void resetFrameDuration()
int frameCount() const
void setFrameRate(qreal arg)
void frameRateChanged(qreal arg)
void frameDurationChanged(int arg)
void setFrameCount(int arg)
void frameDurationVariationChanged(int arg)
bool reverse() const
void setFrameX(int arg)
void frameSyncChanged(bool arg)
void setFrameSync(bool arg)
void sourceChanged(QUrl arg)
void frameXChanged(int arg)
void reverseChanged(bool arg)
void frameHeightChanged(int arg)
void frameYChanged(int arg)
void setSource(QUrl arg)
void frameRateVariationChanged(qreal arg)
int frameY() const
void setFrameDurationVariation(int arg)
int frameWidth() const
qreal frameRateVariation() const
void setFrameDuration(int arg)
void setDevicePixelRatio(qreal dpr)
int frameX() const
int frameDuration() const
void setFrameRateVariation(qreal arg)
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
#define qWarning
Definition qlogging.h:166
GLsizei GLsizei GLchar * source
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
SSL_CTX int void * arg
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit