12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "qdeclarativesparticlespainter.h"
- #include "qdeclarativesparticles.h"
- QDeclarativeSParticlesPainter::QDeclarativeSParticlesPainter(QDeclarativeSParticlesPrivate *p, QDeclarativeItem* parent)
- : QDeclarativeItem(parent), d(p)
- {
- setFlag(QGraphicsItem::ItemHasNoContents, false);
- // maxX = minX = maxY = minY = 0;
- }
- void QDeclarativeSParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
- {
- // if (d->image.isNull() || d->particles.isEmpty())
- // return;
- // const int myX = x() + parentItem()->x();
- // const int myY = y() + parentItem()->y();
- // QVarLengthArray<QPainter::PixmapFragment, 256> pixmapData;
- // pixmapData.resize(d->particles.count());
- // const QRectF sourceRect = d->image.rect();
- // qreal halfPWidth = sourceRect.width()/2.;
- // qreal halfPHeight = sourceRect.height()/2.;
- // for (int i = 0; i < d->particles.count(); ++i) {
- // const QDeclarativeParticle &particle = d->particles.at(i);
- // pixmapData[i].x = particle.x - myX + halfPWidth;
- // pixmapData[i].y = particle.y - myY + halfPHeight;
- // pixmapData[i].opacity = particle.opacity;
- // //these never change
- // pixmapData[i].rotation = 0;
- // pixmapData[i].scaleX = 1;
- // pixmapData[i].scaleY = 1;
- // pixmapData[i].sourceLeft = sourceRect.left();
- // pixmapData[i].sourceTop = sourceRect.top();
- // pixmapData[i].width = sourceRect.width();
- // pixmapData[i].height = sourceRect.height();
- // }
- // p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image);
- }
- void QDeclarativeSParticlesPainter::updateSize()
- {
- if (!d->componentComplete)
- return;
- // const int parentX = parentItem()->x();
- // const int parentY = parentItem()->y();
- // for (int i = 0; i < d->particles.count(); ++i) {
- // const QDeclarativeParticle &particle = d->particles.at(i);
- // if(particle.x > maxX)
- // maxX = particle.x;
- // if(particle.x < minX)
- // minX = particle.x;
- // if(particle.y > maxY)
- // maxY = particle.y;
- // if(particle.y < minY)
- // minY = particle.y;
- // }
- // int myWidth = (int)(maxX-minX+0.5)+d->image.width();
- // int myX = (int)(minX - parentX);
- // int myHeight = (int)(maxY-minY+0.5)+d->image.height();
- // int myY = (int)(minY - parentY);
- // setWidth(myWidth);
- // setHeight(myHeight);
- // setX(myX);
- // setY(myY);
- }
|