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 PARTICLEEMITTER_H
43
#define PARTICLEEMITTER_H
45
#include <QtQuick/QQuickItem>
47
#include "qquickparticlesystem_p.h"
48
#include "qquickparticleextruder_p.h"
49
#include "qquickdirection_p.h"
58
class QQuickParticleEmitter : public QQuickItem
61
Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
62
Q_PROPERTY(QString group READ group WRITE setGroup NOTIFY groupChanged)
63
Q_PROPERTY(QQuickParticleExtruder* shape READ extruder WRITE setExtruder NOTIFY extruderChanged)
64
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
65
Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
67
Q_PROPERTY(qreal emitRate READ particlesPerSecond WRITE setParticlesPerSecond NOTIFY particlesPerSecondChanged)
68
Q_PROPERTY(int lifeSpan READ particleDuration WRITE setParticleDuration NOTIFY particleDurationChanged)
69
Q_PROPERTY(int lifeSpanVariation READ particleDurationVariation WRITE setParticleDurationVariation NOTIFY particleDurationVariationChanged)
70
Q_PROPERTY(int maximumEmitted READ maxParticleCount WRITE setMaxParticleCount NOTIFY maximumEmittedChanged)
72
Q_PROPERTY(qreal size READ particleSize WRITE setParticleSize NOTIFY particleSizeChanged)
73
Q_PROPERTY(qreal endSize READ particleEndSize WRITE setParticleEndSize NOTIFY particleEndSizeChanged)
74
Q_PROPERTY(qreal sizeVariation READ particleSizeVariation WRITE setParticleSizeVariation NOTIFY particleSizeVariationChanged)
76
Q_PROPERTY(QQuickDirection *speed READ speed WRITE setSpeed NOTIFY speedChanged)
77
Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
78
Q_PROPERTY(qreal speedFromMovement READ speedFromMovement WRITE setSpeedFromMovement NOTIFY speedFromMovementChanged)
82
explicit QQuickParticleEmitter(QQuickItem *parent = 0);
83
virtual ~QQuickParticleEmitter();
84
virtual void emitWindow(int timeStamp);
87
InfiniteLife = QQuickParticleSystem::maxLife
95
qreal particlesPerSecond() const
97
return m_particlesPerSecond;
100
int particleDuration() const
102
return m_particleDuration;
105
QQuickParticleSystem* system() const
110
QString group() const
115
int particleDurationVariation() const
117
return m_particleDurationVariation;
120
qreal speedFromMovement() const { return m_speed_from_movement; }
121
void setSpeedFromMovement(qreal s);
122
virtual void componentComplete();
124
void emitParticles(QQmlV8Handle particles);
125
void particlesPerSecondChanged(qreal);
126
void particleDurationChanged(int);
127
void enabledChanged(bool);
129
void systemChanged(QQuickParticleSystem* arg);
131
void groupChanged(QString arg);
133
void particleDurationVariationChanged(int arg);
135
void extruderChanged(QQuickParticleExtruder* arg);
137
void particleSizeChanged(qreal arg);
139
void particleEndSizeChanged(qreal arg);
141
void particleSizeVariationChanged(qreal arg);
143
void speedChanged(QQuickDirection * arg);
145
void accelerationChanged(QQuickDirection * arg);
147
void maximumEmittedChanged(int arg);
148
void particleCountChanged();
150
void speedFromMovementChanged();
152
void startTimeChanged(int arg);
155
void pulse(int milliseconds);
157
void burst(int num, qreal x, qreal y);
159
void setEnabled(bool arg);
161
void setParticlesPerSecond(qreal arg)
163
if (m_particlesPerSecond != arg) {
164
m_particlesPerSecond = arg;
165
emit particlesPerSecondChanged(arg);
169
void setParticleDuration(int arg)
171
if (m_particleDuration != arg) {
172
m_particleDuration = arg;
173
emit particleDurationChanged(arg);
177
void setSystem(QQuickParticleSystem* arg)
179
if (m_system != arg) {
182
m_system->registerParticleEmitter(this);
183
emit systemChanged(arg);
187
void setGroup(QString arg)
189
if (m_group != arg) {
191
emit groupChanged(arg);
195
void setParticleDurationVariation(int arg)
197
if (m_particleDurationVariation != arg) {
198
m_particleDurationVariation = arg;
199
emit particleDurationVariationChanged(arg);
202
void setExtruder(QQuickParticleExtruder* arg)
204
if (m_extruder != arg) {
206
emit extruderChanged(arg);
210
void setParticleSize(qreal arg)
212
if (m_particleSize != arg) {
213
m_particleSize = arg;
214
emit particleSizeChanged(arg);
218
void setParticleEndSize(qreal arg)
220
if (m_particleEndSize != arg) {
221
m_particleEndSize = arg;
222
emit particleEndSizeChanged(arg);
226
void setParticleSizeVariation(qreal arg)
228
if (m_particleSizeVariation != arg) {
229
m_particleSizeVariation = arg;
230
emit particleSizeVariationChanged(arg);
234
void setSpeed(QQuickDirection * arg)
236
if (m_speed != arg) {
238
emit speedChanged(arg);
242
void setAcceleration(QQuickDirection * arg)
244
if (m_acceleration != arg) {
245
m_acceleration = arg;
246
emit accelerationChanged(arg);
250
void setMaxParticleCount(int arg);
252
void setStartTime(int arg)
254
if (m_startTime != arg) {
256
emit startTimeChanged(arg);
260
virtual void reset();
262
int particleCount() const;
264
QQuickParticleExtruder* extruder() const
269
qreal particleSize() const
271
return m_particleSize;
274
qreal particleEndSize() const
276
return m_particleEndSize;
279
qreal particleSizeVariation() const
281
return m_particleSizeVariation;
284
QQuickDirection * speed() const
289
QQuickDirection * acceleration() const
291
return m_acceleration;
294
int maxParticleCount() const
296
return m_maxParticleCount;
299
int startTime() const
305
qreal m_particlesPerSecond;
306
int m_particleDuration;
307
int m_particleDurationVariation;
309
QQuickParticleSystem* m_system;
311
QQuickParticleExtruder* m_extruder;
312
QQuickParticleExtruder* m_defaultExtruder;
313
QQuickParticleExtruder* effectiveExtruder();
314
QQuickDirection * m_speed;
315
QQuickDirection * m_acceleration;
316
qreal m_particleSize;
317
qreal m_particleEndSize;
318
qreal m_particleSizeVariation;
320
qreal m_speedFromMovement;
325
QList<QPair<int, QPointF > > m_burstQueue;
326
int m_maxParticleCount;
328
//Used in default implementation, but might be useful
329
qreal m_speed_from_movement;
333
qreal m_last_timestamp;
334
qreal m_last_emission;
336
QPointF m_last_emitter;
337
QPointF m_last_last_emitter;
338
QPointF m_last_last_last_emitter;
340
bool isEmitConnected();
342
QQuickDirection m_nullVector;
350
#endif // PARTICLEEMITTER_H