diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-10-11 14:16:33 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-17 01:05:23 +0200 |
commit | 576e7ae3360632a981177800e758679ee4105950 (patch) | |
tree | 2f54e8ae5de338108998c2210b172ac96e0dbe1b /src/declarative/particles | |
parent | 761145dacd43954087d543e8fac1f5e958c81733 (diff) |
Allow sizing of TrailEmitter emit area based on particle size
Change-Id: I7ce2ba29459b9a66e62933f9bfb9e066baedaaef
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/particles')
-rw-r--r-- | src/declarative/particles/qsgtrailemitter.cpp | 30 | ||||
-rw-r--r-- | src/declarative/particles/qsgtrailemitter_p.h | 6 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/declarative/particles/qsgtrailemitter.cpp b/src/declarative/particles/qsgtrailemitter.cpp index 9fbd13b4aa..4298908c89 100644 --- a/src/declarative/particles/qsgtrailemitter.cpp +++ b/src/declarative/particles/qsgtrailemitter.cpp @@ -91,13 +91,26 @@ QSGTrailEmitter::QSGTrailEmitter(QSGItem *parent) : \qmlproperty Shape QtQuick.Particles2::TrailEmitter::emitShape As the area of a TrailEmitter is the area it follows, a separate shape can be provided - to be the shape it emits out of. + to be the shape it emits out of. This shape has width and height specified by emitWidth + and emitHeight, and is centered on the followed particle's position. + + The default shape is a filled Rectangle. */ /*! \qmlproperty real QtQuick.Particles2::TrailEmitter::emitWidth + + The width in pixels the emitShape is scaled to. If set to TrailEmitter.ParticleSize, + the width will be the current size of the particle being followed. + + Default is 0. */ /*! \qmlproperty real QtQuick.Particles2::TrailEmitter::emitHeight + + The height in pixels the emitShape is scaled to. If set to TrailEmitter.ParticleSize, + the height will be the current size of the particle being followed. + + Default is 0. */ /*! \qmlproperty real QtQuick.Particles2::TrailEmitter::emitRatePerParticle @@ -202,17 +215,12 @@ void QSGTrailEmitter::emitWindow(int timeStamp) // Note that burst location doesn't get used for follow emitter qreal followT = pt - d->t; qreal followT2 = followT * followT * 0.5; - //qreal sizeOffset = d->size/2;//TODO: Current size? As an option - //TODO: Set variations + qreal eW = m_emitterXVariation < 0 ? d->curSize() : m_emitterXVariation; + qreal eH = m_emitterYVariation < 0 ? d->curSize() : m_emitterYVariation; //Subtract offset, because PS expects this in emitter coordinates - QRectF boundsRect(d->x - offset.x() + d->vx * followT + d->ax * followT2 - m_emitterXVariation/2, - d->y - offset.y() + d->vy * followT + d->ay * followT2 - m_emitterYVariation/2, - m_emitterXVariation, - m_emitterYVariation); - // QRectF boundsRect(d->x + d->vx * followT + d->ax * followT2 + offset.x() - sizeOffset, - // d->y + d->vy * followT + d->ay * followT2 + offset.y() - sizeOffset, - // sizeOffset*2, - // sizeOffset*2); + QRectF boundsRect(d->x - offset.x() + d->vx * followT + d->ax * followT2 - eW/2, + d->y - offset.y() + d->vy * followT + d->ay * followT2 - eH/2, + eW, eH); QSGParticleExtruder* effectiveEmissionExtruder = m_emissionExtruder ? m_emissionExtruder : m_defaultEmissionExtruder; const QPointF &newPos = effectiveEmissionExtruder->extrude(boundsRect); diff --git a/src/declarative/particles/qsgtrailemitter_p.h b/src/declarative/particles/qsgtrailemitter_p.h index e0103afdc0..255dd85cef 100644 --- a/src/declarative/particles/qsgtrailemitter_p.h +++ b/src/declarative/particles/qsgtrailemitter_p.h @@ -57,13 +57,15 @@ class QSGTrailEmitter : public QSGParticleEmitter Q_PROPERTY(QString follow READ follow WRITE setFollow NOTIFY followChanged) Q_PROPERTY(int emitRatePerParticle READ particlesPerParticlePerSecond WRITE setParticlesPerParticlePerSecond NOTIFY particlesPerParticlePerSecondChanged) - //TODO: Document that TrailEmitter's box is where it follows. It emits in a rect centered on the followed particle - //TODO: A set of properties that can involve the particle size of the followed Q_PROPERTY(QSGParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged) Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged) Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged) + Q_ENUMS(EmitSize) public: + enum EmitSize { + ParticleSize = -2//Anything less than 0 will do + }; explicit QSGTrailEmitter(QSGItem *parent = 0); virtual void emitWindow(int timeStamp); virtual void reset(); |