diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-29 02:56:22 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-29 06:43:34 (GMT) |
commit | 1cff081464744774d9d3e76704c03209fca280c2 (patch) | |
tree | 6811faac0d75f4fc75c970ec95f60034a0a0d0ab | |
parent | f0ed432d55ef6da7223ee3d58e45391e3f88be86 (diff) | |
download | Qt-1cff081464744774d9d3e76704c03209fca280c2.zip Qt-1cff081464744774d9d3e76704c03209fca280c2.tar.gz Qt-1cff081464744774d9d3e76704c03209fca280c2.tar.bz2 |
Add new enum to global namespace: Qt::CoordinateSystem
-rw-r--r-- | src/corelib/global/qnamespace.h | 5 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicseffect.cpp | 20 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicseffect.h | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicseffect_p.h | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 9 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 4 |
6 files changed, 26 insertions, 20 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 7770fd6..834ad1a 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1552,6 +1552,11 @@ public: Uninitialized }; + enum CoordinateSystem { + DeviceCoordinates, + LogicalCoordinates + }; + enum TouchPointState { TouchPointPressed = 0x01, TouchPointMoved = 0x02, diff --git a/src/gui/graphicsview/qgraphicseffect.cpp b/src/gui/graphicsview/qgraphicseffect.cpp index 26dc35c..63cf975 100644 --- a/src/gui/graphicsview/qgraphicseffect.cpp +++ b/src/gui/graphicsview/qgraphicseffect.cpp @@ -109,8 +109,8 @@ QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, Q QGraphicsEffectSource::~QGraphicsEffectSource() {} -QRectF QGraphicsEffectSource::boundingRect(bool deviceCoordinates) const -{ return d_func()->boundingRect(deviceCoordinates); } +QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const +{ return d_func()->boundingRect(system); } const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const { return d_func()->graphicsItem(); } @@ -121,8 +121,8 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const void QGraphicsEffectSource::draw(QPainter *painter) { d_func()->draw(painter); } -QPixmap QGraphicsEffectSource::pixmap(bool deviceCoordinates, QPoint *offset) const -{ return d_func()->pixmap(deviceCoordinates, offset); } +QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset) const +{ return d_func()->pixmap(system, offset); } QGraphicsEffect::QGraphicsEffect() : QObject(*new QGraphicsEffectPrivate, 0) @@ -185,7 +185,7 @@ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *so { Q_D(QGraphicsGrayscaleEffect); QPoint offset; - const QPixmap pixmap = source->pixmap(true, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); // Draw the pixmap with the filter using an untransformed painter. QTransform restoreTransform = painter->worldTransform(); @@ -218,7 +218,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou { Q_D(QGraphicsColorizeEffect); QPoint offset; - const QPixmap pixmap = source->pixmap(true, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); // Draw the pixmap with the filter using an untransformed painter. QTransform restoreTransform = painter->worldTransform(); @@ -252,7 +252,7 @@ void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou { Q_D(QGraphicsPixelizeEffect); QPoint offset; - const QPixmap pixmap = source->pixmap(true, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); // pixelize routine QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); @@ -380,7 +380,7 @@ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsBlurEffect); QPoint offset; - const QPixmap pixmap = source->pixmap(true, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); // Draw the pixmap with the filter using an untransformed painter. QTransform restoreTransform = painter->worldTransform(); @@ -464,7 +464,7 @@ void QGraphicsBloomEffect::draw(QPainter *painter, QGraphicsEffectSource *source { Q_D(QGraphicsBloomEffect); QPoint offset; - const QPixmap pixmap = source->pixmap(true, &offset); + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); // bloom routine const int radius = d->blurRadius; @@ -603,7 +603,7 @@ QRectF QGraphicsShadowEffect::boundingRectFor(const QRectF &rect) const void QGraphicsShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsShadowEffect); - const QRectF sourceRect = source->boundingRect(/*deviceCoordinates=*/true); + const QRectF sourceRect = source->boundingRect(Qt::DeviceCoordinates); const QRectF shadowRect = sourceRect.translated(d->offset); QRectF blurRect = shadowRect; qreal delta = d->radius * 3; diff --git a/src/gui/graphicsview/qgraphicseffect.h b/src/gui/graphicsview/qgraphicseffect.h index 175541f..397651f 100644 --- a/src/gui/graphicsview/qgraphicseffect.h +++ b/src/gui/graphicsview/qgraphicseffect.h @@ -71,11 +71,11 @@ class Q_GUI_EXPORT QGraphicsEffectSource : public QObject Q_OBJECT public: ~QGraphicsEffectSource(); - QRectF boundingRect(bool deviceCoordinates = false) const; + QRectF boundingRect(Qt::CoordinateSystem s = Qt::LogicalCoordinates) const; const QGraphicsItem *graphicsItem() const; const QStyleOption *styleOption() const; void draw(QPainter *painter); - QPixmap pixmap(bool deviceCoordinates, QPoint *offset = 0) const; + QPixmap pixmap(Qt::CoordinateSystem coordinateSystem, QPoint *offset = 0) const; protected: QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); diff --git a/src/gui/graphicsview/qgraphicseffect_p.h b/src/gui/graphicsview/qgraphicseffect_p.h index ddf65e9..b106e8e 100644 --- a/src/gui/graphicsview/qgraphicseffect_p.h +++ b/src/gui/graphicsview/qgraphicseffect_p.h @@ -68,11 +68,11 @@ public: QGraphicsEffectSourcePrivate() : QObjectPrivate() {} virtual ~QGraphicsEffectSourcePrivate() {} virtual void detach() = 0; - virtual QRectF boundingRect(bool deviceCoordinates = false) const = 0; + virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0; virtual const QGraphicsItem *graphicsItem() const = 0; virtual const QStyleOption *styleOption() const = 0; virtual void draw(QPainter *p) = 0; - virtual QPixmap pixmap(bool deviceCoordinates, QPoint *offset = 0) const = 0; + virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; friend class QGraphicsScenePrivate; friend class QGraphicsItem; friend class QGraphicsItemPrivate; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c0fa271..bb3258d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9926,11 +9926,11 @@ int QGraphicsItemGroup::type() const return Type; } -QRectF QGraphicsItemEffectSourcePrivate::boundingRect(bool deviceCoordinates) const +QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const { QRectF rect = item->boundingRect(); rect |= item->childrenBoundingRect(); - if (deviceCoordinates && info) { + if (info && system == Qt::DeviceCoordinates) { Q_ASSERT(info->transformPtr); return info->transformPtr->mapRect(rect); } @@ -9954,15 +9954,16 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) } } -QPixmap QGraphicsItemEffectSourcePrivate::pixmap(bool deviceCoordinates, QPoint *offset) const +QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset) const { - const QRectF sourceRect = boundingRect(deviceCoordinates); + const QRectF sourceRect = boundingRect(system); const QRect effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); if (offset) *offset = sourceRect.toAlignedRect().topLeft(); const QTransform translateTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y()); + const bool deviceCoordinates = (system == Qt::DeviceCoordinates); QTransform effectTransform = deviceCoordinates ? translateTransform : info->transformPtr->inverted(); if (!deviceCoordinates) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index f8b2ebc..de8b0a5 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -546,9 +546,9 @@ public: inline const QStyleOption *styleOption() const { return info ? info->option : 0; } - QRectF boundingRect(bool deviceCoordinates) const; + QRectF boundingRect(Qt::CoordinateSystem system) const; void draw(QPainter *); - QPixmap pixmap(bool deviceCoordinates, QPoint *offset) const; + QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; |