diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-30 01:51:42 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-30 01:51:42 (GMT) |
commit | ab625efe61c4bd4c59064648d75da6d46acdc762 (patch) | |
tree | ef5fa293904ed68b4701d572c648c1d9cd6c139b /src | |
parent | 8b9104bbe05a6314501cb3e833b2e2c096df892a (diff) | |
download | Qt-ab625efe61c4bd4c59064648d75da6d46acdc762.zip Qt-ab625efe61c4bd4c59064648d75da6d46acdc762.tar.gz Qt-ab625efe61c4bd4c59064648d75da6d46acdc762.tar.bz2 |
Move paint margin functionality to QFxRect.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 11 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.h | 1 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem_p.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.h | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect_p.h | 16 |
6 files changed, 24 insertions, 21 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index bb001c5..7eaaf8e 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1836,19 +1836,10 @@ void QFxItem::childrenChanged() { } -void QFxItem::setPaintMargin(qreal margin) -{ - Q_D(QFxItem); - if (margin == d->paintmargin) - return; - prepareGeometryChange(); - d->paintmargin = margin; -} - QRectF QFxItem::boundingRect() const { Q_D(const QFxItem); - return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2); + return QRectF(0, 0, d->width, d->height); } void QFxItem::paintContents(QPainter &) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 221f057..932d44c 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -217,7 +217,6 @@ public: TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); - void setPaintMargin(qreal margin); QRectF boundingRect() const; virtual void paintContents(QPainter &); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 33200e4..a013897 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -79,8 +79,7 @@ public: _anchorLines(0), _stateGroup(0), canvas(0), origin(QFxItem::TopLeft), options(QFxItem::NoOption), - widthValid(false), heightValid(false), width(0), height(0), - paintmargin(0) + widthValid(false), heightValid(false), width(0), height(0) {} ~QFxItemPrivate() { delete _anchors; } @@ -194,7 +193,6 @@ public: qreal width; qreal height; - qreal paintmargin; QPointF computeTransformOrigin() const; diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 58bd50c..c43e034 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -255,7 +255,7 @@ void QFxRect::doUpdate() Q_D(QFxRect); d->rectImage = QPixmap(); const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - setPaintMargin((pw+1)/2); + d->setPaintMargin((pw+1)/2); update(); } @@ -605,4 +605,10 @@ void QFxRect::drawRect(QPainter &p) } } +QRectF QFxRect::boundingRect() const +{ + Q_D(const QFxRect); + return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index 7790af1..d438459 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -157,6 +157,8 @@ public: qreal radius() const; void setRadius(qreal radius); + QRectF boundingRect() const; + void paintContents(QPainter &painter); private Q_SLOTS: @@ -165,9 +167,8 @@ private Q_SLOTS: private: void generateRoundedRect(); void generateBorderedRect(); -#if defined(QFX_RENDER_QPAINTER) void drawRect(QPainter &painter); -#endif + protected: QFxRect(QFxRectPrivate &dd, QFxItem *parent); diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h index 3544d36..25fa38d 100644 --- a/src/declarative/fx/qfxrect_p.h +++ b/src/declarative/fx/qfxrect_p.h @@ -58,14 +58,14 @@ QT_BEGIN_NAMESPACE class QFxGradient; - +class QFxRect; class QFxRectPrivate : public QFxItemPrivate { Q_DECLARE_PUBLIC(QFxRect) public: QFxRectPrivate() : - color(Qt::white), gradient(0), pen(0), radius(0) + color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0) { } @@ -92,9 +92,17 @@ public: } QFxPen *pen; qreal radius; -#if defined(QFX_RENDER_QPAINTER) + qreal paintmargin; QPixmap rectImage; -#endif + + void setPaintMargin(qreal margin) + { + Q_Q(QFxRect); + if (margin == paintmargin) + return; + q->prepareGeometryChange(); + paintmargin = margin; + } }; QT_END_NAMESPACE |