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_PRIVATE_EXPORT QQuickTrailEmitter : public QQuickParticleEmitter
23{
24 Q_OBJECT
25 Q_PROPERTY(QString follow READ follow WRITE setFollow NOTIFY followChanged FINAL)
26 Q_PROPERTY(int emitRatePerParticle READ particlesPerParticlePerSecond WRITE setParticlesPerParticlePerSecond NOTIFY particlesPerParticlePerSecondChanged FINAL)
27
28 Q_PROPERTY(QQuickParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged FINAL)
29 Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged FINAL)
30 Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged FINAL)
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(const QJSValue &particles, const QJSValue &followed);
70
71 void particlesPerParticlePerSecondChanged(int arg);
72
73 void emitterXVariationChanged(qreal arg);
74
75 void emitterYVariationChanged(qreal arg);
76
77 void followChanged(const QString &arg);
78
79 void emissionShapeChanged(QQuickParticleExtruder* arg);
80
81public Q_SLOTS:
82
83 void setParticlesPerParticlePerSecond(int arg)
84 {
85 if (m_particlesPerParticlePerSecond != arg) {
86 m_particlesPerParticlePerSecond = arg;
87 Q_EMIT particlesPerParticlePerSecondChanged(arg);
88 }
89 }
90 void setEmitterXVariation(qreal arg)
91 {
92 if (m_emitterXVariation != arg) {
93 m_emitterXVariation = arg;
94 Q_EMIT emitterXVariationChanged(arg);
95 }
96 }
97
98 void setEmitterYVariation(qreal arg)
99 {
100 if (m_emitterYVariation != arg) {
101 m_emitterYVariation = arg;
102 Q_EMIT emitterYVariationChanged(arg);
103 }
104 }
105
106 void setFollow(const QString &arg)
107 {
108 if (m_follow != arg) {
109 m_follow = arg;
110 Q_EMIT followChanged(arg);
111 }
112 }
113
114 void setEmissionShape(QQuickParticleExtruder* arg)
115 {
116 if (m_emissionExtruder != arg) {
117 m_emissionExtruder = arg;
118 Q_EMIT emissionShapeChanged(arg);
119 }
120 }
121
122private Q_SLOTS:
123 void recalcParticlesPerSecond();
124
125private:
126 QVector<qreal> m_lastEmission;
127 int m_particlesPerParticlePerSecond;
128 qreal m_lastTimeStamp;
129 qreal m_emitterXVariation;
130 qreal m_emitterYVariation;
131 QString m_follow;
132 int m_followCount;
133 QQuickParticleExtruder* m_emissionExtruder;
134 QQuickParticleExtruder* m_defaultEmissionExtruder;
135 bool isEmitFollowConnected();
136};
137
138QT_END_NAMESPACE
139#endif // FOLLOWEMITTER_H
140

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