diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-08-23 20:03:43 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-24 12:27:43 +0200 |
commit | 1253db60ee2586b1546cbaeeacb7b8c3d77ab255 (patch) | |
tree | 3566db4d1038b6b628fd73fba21ce4251385da56 /src/declarative/particles/qsgparticleaffector.cpp | |
parent | b9a16a039692327a9f6975456667b5bd36afb4c8 (diff) |
Absorb CustomEmitter/Affector
The signal is now on the Emitter/Affector base type, but only
emitted if connected to (to save creating the v8 object)
Change-Id: Ib5522e0f760caa17a6ad731b2dfbce9994a7664e
Reviewed-on: http://codereview.qt.nokia.com/3393
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/particles/qsgparticleaffector.cpp')
-rw-r--r-- | src/declarative/particles/qsgparticleaffector.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/declarative/particles/qsgparticleaffector.cpp b/src/declarative/particles/qsgparticleaffector.cpp index 222af3dfdc..4cb3e49403 100644 --- a/src/declarative/particles/qsgparticleaffector.cpp +++ b/src/declarative/particles/qsgparticleaffector.cpp @@ -94,11 +94,24 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty bool QtQuick.Particles2::Affector::signal If this is set to true, then an affected(x,y) signal will be emitted each - time this affector affects a particle. + time this affector would affect a particle. + + For Affector only, this will happen irrespective of whether any changes + are made to the particle, for other Affectors the signal will only fire + if the particle is actually affected. Default value is false. */ +//TODO: Document particle 'type' +/*! + \qmlsignal QtQuick.Particles2::Affector::affectParticle(particle, dt) + + This handler is called when a particle is selected to be affected. + + dt is the time since the last time it was affected. Use dt to normalize + trajectory manipulations to real time. +*/ QSGParticleAffector::QSGParticleAffector(QSGItem *parent) : QSGItem(parent), m_needsReset(false), m_system(0), m_active(true) , m_updateIntSet(false), m_shape(new QSGParticleExtruder(this)), m_signal(false) @@ -111,6 +124,12 @@ QSGParticleAffector::QSGParticleAffector(QSGItem *parent) : this, SLOT(updateOffsets()));//TODO: in componentComplete and all relevant signals } +bool QSGParticleAffector::isAffectConnected() +{ + static int idx = QObjectPrivate::get(this)->signalIndex("affectParticle(QDeclarativeV8Handle, qreal)"); + return QObjectPrivate::get(this)->isSignalConnected(idx); +} + void QSGParticleAffector::componentComplete() { if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem())) @@ -161,8 +180,10 @@ void QSGParticleAffector::affectSystem(qreal dt) bool QSGParticleAffector::affectParticle(QSGParticleData *d, qreal dt) { - Q_UNUSED(d); - Q_UNUSED(dt); + if (isAffectConnected()){ + emit affectParticle(d->v8Value(), dt); + return true; + } return m_signal;//If signalling, then we always 'null affect' it. } |