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 FOLLOWEMITTER_H
5#define FOLLOWEMITTER_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#include "qquickparticleemitter_p.h"
18#include "qquickparticleaffector_p.h"
19
20QT_BEGIN_NAMESPACE
21
22class Q_QUICKPARTICLES_EXPORT QQuickTrailEmitter : public QQuickParticleEmitter
23{
24 Q_OBJECT
25 Q_PROPERTY(QString follow READ follow WRITE setFollow NOTIFY followChanged)
26 Q_PROPERTY(int emitRatePerParticle READ particlesPerParticlePerSecond WRITE setParticlesPerParticlePerSecond NOTIFY particlesPerParticlePerSecondChanged)
27
28 Q_PROPERTY(QQuickParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged)
29 Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged)
30 Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged)
31 QML_NAMED_ELEMENT(TrailEmitter)
32 QML_ADDED_IN_VERSION(2, 0)
33
34public:
35 enum EmitSize {
36 ParticleSize = -2//Anything less than 0 will do
37 };
38 Q_ENUM(EmitSize)
39 explicit QQuickTrailEmitter(QQuickItem *parent = nullptr);
40 void emitWindow(int timeStamp) override;
41 void reset() override;
42
43 int particlesPerParticlePerSecond() const
44 {
45 return m_particlesPerParticlePerSecond;
46 }
47
48 qreal emitterXVariation() const
49 {
50 return m_emitterXVariation;
51 }
52
53 qreal emitterYVariation() const
54 {
55 return m_emitterYVariation;
56 }
57
58 QString follow() const
59 {
60 return m_follow;
61 }
62
63 QQuickParticleExtruder* emissonShape() const
64 {
65 return m_emissionExtruder;
66 }
67
68Q_SIGNALS:
69 void emitFollowParticles(
70 const QList<QQuickV4ParticleData> &particles,
71 const QQuickV4ParticleData &followed);
72
73 void particlesPerParticlePerSecondChanged(int arg);
74
75 void emitterXVariationChanged(qreal arg);
76
77 void emitterYVariationChanged(qreal arg);
78
79 void followChanged(const QString &arg);
80
81 void emissionShapeChanged(QQuickParticleExtruder* arg);
82
83public Q_SLOTS:
84
85 void setParticlesPerParticlePerSecond(int arg)
86 {
87 if (m_particlesPerParticlePerSecond != arg) {
88 m_particlesPerParticlePerSecond = arg;
89 Q_EMIT particlesPerParticlePerSecondChanged(arg);
90 }
91 }
92 void setEmitterXVariation(qreal arg)
93 {
94 if (m_emitterXVariation != arg) {
95 m_emitterXVariation = arg;
96 Q_EMIT emitterXVariationChanged(arg);
97 }
98 }
99
100 void setEmitterYVariation(qreal arg)
101 {
102 if (m_emitterYVariation != arg) {
103 m_emitterYVariation = arg;
104 Q_EMIT emitterYVariationChanged(arg);
105 }
106 }
107
108 void setFollow(const QString &arg)
109 {
110 if (m_follow != arg) {
111 m_follow = arg;
112 Q_EMIT followChanged(arg);
113 }
114 }
115
116 void setEmissionShape(QQuickParticleExtruder* arg)
117 {
118 if (m_emissionExtruder != arg) {
119 m_emissionExtruder = arg;
120 Q_EMIT emissionShapeChanged(arg);
121 }
122 }
123
124private Q_SLOTS:
125 void recalcParticlesPerSecond();
126
127private:
128 QVector<qreal> m_lastEmission;
129 int m_particlesPerParticlePerSecond;
130 qreal m_lastTimeStamp;
131 qreal m_emitterXVariation;
132 qreal m_emitterYVariation;
133 QString m_follow;
134 int m_followCount;
135 QQuickParticleExtruder* m_emissionExtruder;
136 QQuickParticleExtruder* m_defaultEmissionExtruder;
137 bool isEmitFollowConnected();
138};
139
140QT_END_NAMESPACE
141#endif // FOLLOWEMITTER_H
142

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/particles/qquicktrailemitter_p.h