Qt 4.8
qdeclarativeparticles_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVEPARTICLES_H
43 #define QDECLARATIVEPARTICLES_H
44 
45 #include <QtDeclarative/qdeclarativeitem.h>
46 
48 
50 
51 QT_MODULE(Declarative)
52 
56 {
57  Q_OBJECT
58 public:
60 
61  virtual void advance(QDeclarativeParticle &, int interval);
62  virtual void created(QDeclarativeParticle &);
63  virtual void destroy(QDeclarativeParticle &);
64 };
65 
67 {
68  Q_OBJECT
69 public:
72 
73  virtual void advance(QDeclarativeParticle &, int interval);
74 };
75 
77 {
78  Q_OBJECT
79 
83 public:
85  : QDeclarativeParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {}
86 
87  qreal xAttractor() const { return _xAttr; }
88  void setXAttractor(qreal x);
89 
90  qreal yAttractor() const { return _yAttr; }
91  void setYAttractor(qreal y);
92 
93  qreal acceleration() const { return _accel * 1000000; }
94  void setAcceleration(qreal accel);
95 
96  virtual void advance(QDeclarativeParticle &, int interval);
97 
98 Q_SIGNALS:
99  void xattractorChanged();
100  void yattractorChanged();
101  void accelerationChanged();
102 
103 private:
107 };
108 
110 {
111  Q_OBJECT
112 public:
114  : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0), _pace(100) {}
115 
116  virtual void advance(QDeclarativeParticle &, int interval);
117  virtual void created(QDeclarativeParticle &);
118  virtual void destroy(QDeclarativeParticle &);
119 
120  struct Data {
127  };
128 
130  qreal xVariance() const { return _xvariance * 1000.0; }
131  void setXVariance(qreal var);
132 
134  qreal yVariance() const { return _yvariance * 1000.0; }
135  void setYVariance(qreal var);
136 
138  qreal pace() const { return _pace * 1000.0; }
139  void setPace(qreal pace);
140 
141 Q_SIGNALS:
142  void xvarianceChanged();
143  void yvarianceChanged();
144  void paceChanged();
145 
146 private:
151 };
152 
155 {
156  Q_OBJECT
157 
159  int count;
162  int lifeSpan;
171  Q_CLASSINFO("DefaultProperty", "motion")
172 
173 public:
176 
177  QUrl source() const;
178  void setSource(const QUrl &);
179 
180  int count() const;
181  void setCount(int cnt);
182 
183  int emissionRate() const;
184  void setEmissionRate(int);
185 
186  qreal emissionVariance() const;
187  void setEmissionVariance(qreal);
188 
189  int lifeSpan() const;
190  void setLifeSpan(int);
191 
192  int lifeSpanDeviation() const;
193  void setLifeSpanDeviation(int);
194 
195  int fadeInDuration() const;
196  void setFadeInDuration(int);
197 
198  int fadeOutDuration() const;
199  void setFadeOutDuration(int);
200 
201  qreal angle() const;
202  void setAngle(qreal);
203 
204  qreal angleDeviation() const;
205  void setAngleDeviation(qreal);
206 
207  qreal velocity() const;
208  void setVelocity(qreal);
209 
210  qreal velocityDeviation() const;
211  void setVelocityDeviation(qreal);
212 
213  QDeclarativeParticleMotion *motion() const;
214  void setMotion(QDeclarativeParticleMotion *);
215 
216  void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
217 
218 public Q_SLOTS:
219  void burst(int count, int emissionRate=-1);
220 
221 protected:
222  virtual void componentComplete();
223 
224 Q_SIGNALS:
225  void sourceChanged();
226  void countChanged();
227  void emissionRateChanged();
228  void emissionVarianceChanged();
229  void lifeSpanChanged();
230  void lifeSpanDeviationChanged();
231  void fadeInDurationChanged();
232  void fadeOutDurationChanged();
233  void angleChanged();
234  void angleDeviationChanged();
235  void velocityChanged();
236  void velocityDeviationChanged();
237  void emittingChanged();
238  void motionChanged();
239 
241  void imageLoaded();
242 
243 private:
246 };
247 
249 
250 QML_DECLARE_TYPE(QDeclarativeParticleMotion)
254 QML_DECLARE_TYPE(QDeclarativeParticles)
255 
257 
258 #endif
QDeclarativeParticleMotion(QObject *parent=0)
Constructs a QDeclarativeParticleMotion with parent object parent.
int count
the maximum number of particles
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QUrl source
the URL of the particle image.
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
The QDeclarativeParticleMotion class is the base class for particle motion.
int fadeOutDuration
the time taken to fade out the particles.
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
qreal emissionVariance
how much the particle emission amounts vary per tick
int fadeInDuration
the time taken to fade in the particles.
qreal acceleration
the acceleration to apply to the particles.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int lifeSpan
the life span of each particle.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
qreal velocity
the initial velocity of the particles.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QDeclarativeParticleMotion * motion
sets the type of motion to apply to the particles.
qreal xattractor
the x coordinate of the point attracting the particles.
The QDeclarativeItem class provides the most basic of all visual items in QML.
static const char * data(const QByteArray &arr)
qreal angleDeviation
the maximum possible deviation from the set angle.
virtual void destroy(QDeclarativeParticle &)
The particle is about to be destroyed.
qreal velocityDeviation
the maximum possible deviation from the set velocity.
#define Q_OBJECT
Definition: qobjectdefs.h:157
QDeclarativeParticleMotionGravity(QObject *parent=0)
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
int emissionRate
the emission rate of particles
virtual void created(QDeclarativeParticle &)
The particle has just been created.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
int lifeSpanDeviation
the maximum possible deviation from the set lifeSpan.
qreal angle
the initial angle of direction.
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320
virtual void advance(QDeclarativeParticle &, int interval)
Move the particle to its new position.
#define QT_END_HEADER
Definition: qglobal.h:137
#define private
Definition: qregion_qws.cpp:43
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
Definition: qstyleoption.h:867
QDeclarativeParticleMotionLinear(QObject *parent=0)
qreal yattractor
the y coordinate of the point attracting the particles.