qdeclarativesparticles.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef QDECLARATIVESPARTICLES_H
  2. #define QDECLARATIVESPARTICLES_H
  3. #include <QtCore/QAbstractAnimation>
  4. #include <QtDeclarative/qdeclarativeitem_p.h>
  5. #include "qdeclarativesparticlepainter.h"
  6. //an animation that just gives a tick
  7. template<class T, void (T::*method)(int)>
  8. class TickAnimationProxy : public QAbstractAnimation
  9. {
  10. public:
  11. TickAnimationProxy(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {}
  12. virtual int duration() const { return -1; }
  13. protected:
  14. virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); }
  15. private:
  16. T *m_p;
  17. };
  18. //---------------------------------------------------------------------------
  19. class QDeclarativeSParticlesPrivate : public QDeclarativeItemPrivate
  20. {
  21. Q_DECLARE_PUBLIC(QDeclarativeParticles)
  22. public:
  23. QDeclarativeSParticlesPrivate()
  24. :
  25. // count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000)
  26. // , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
  27. // , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.)
  28. // , addParticleTime(0), addParticleCount(0),
  29. lastAdvTime(0),
  30. // , motion(0),
  31. clock(this)
  32. {
  33. }
  34. ~QDeclarativeSParticlesPrivate()
  35. {
  36. }
  37. void init()
  38. {
  39. Q_Q(QDeclarativeSParticles);
  40. paintItem = new QDeclarativeSParticlesPainter(this, q);
  41. }
  42. void tick(int time);
  43. // void createParticle(int time);
  44. // void updateOpacity(QDeclarativeParticle &p, int age);
  45. // QUrl url;
  46. // QDeclarativePixmap image;
  47. // int count;
  48. // int emissionRate;
  49. // qreal emissionVariance;
  50. // int lifeSpan;
  51. // int lifeSpanDev;
  52. // int fadeInDur;
  53. // int fadeOutDur;
  54. // qreal angle;
  55. // qreal angleDev;
  56. // qreal velocity;
  57. // qreal velocityDev;
  58. // qreal emissionCarry;
  59. // int addParticleTime;
  60. // int addParticleCount;
  61. int lastAdvTime;
  62. // QDeclarativeParticleMotion *motion;
  63. QDeclarativeSParticlesPainter *paintItem;
  64. // QList<QPair<int, int> > bursts;//countLeft, emissionRate pairs
  65. // QList<QDeclarativeParticle> particles;
  66. TickAnimationProxy<QDeclarativeSParticlesPrivate, &QDeclarativeSParticlesPrivate::tick> clock;
  67. };
  68. #endif // QDECLARATIVESPARTICLES_H