summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-11 09:12:43 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-11 09:14:43 (GMT)
commit666299f9074235185aa7372729c84a2639224601 (patch)
tree2928f7299077d37211b78f2ae7a44e180d9e37cb /src/gui
parent1c6c353ecc23a01368d785794d130131e3fb2553 (diff)
downloadQt-666299f9074235185aa7372729c84a2639224601.zip
Qt-666299f9074235185aa7372729c84a2639224601.tar.gz
Qt-666299f9074235185aa7372729c84a2639224601.tar.bz2
another API review round: change Q*TouchEvent size() functions to return rects instead
these are more useful, as already shown in the fingerpaint example
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp30
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h13
-rw-r--r--src/gui/kernel/qapplication_win.cpp15
-rw-r--r--src/gui/kernel/qevent.cpp11
-rw-r--r--src/gui/kernel/qevent.h4
-rw-r--r--src/gui/kernel/qevent_p.h2
6 files changed, 39 insertions, 36 deletions
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index c1052e3..1be8d0d 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -2249,51 +2249,51 @@ void QGraphicsSceneTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastS
}
/*!
- Returns the size of this touch point.
+ Returns the rect for this touch point.
*/
-QSizeF QGraphicsSceneTouchEvent::TouchPoint::size() const
+QRectF QGraphicsSceneTouchEvent::TouchPoint::rect() const
{
- return d->size;
+ return d->rect;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::TouchPoint::setSize(const QSizeF &size)
+void QGraphicsSceneTouchEvent::TouchPoint::setRect(const QRectF &rect)
{
if (d->ref != 1)
d = d->detach();
- d->size = size;
+ d->rect = rect;
}
/*!
- Returns the size of this touch point in scene coordinates.
+ Returns the rect of this touch point in scene coordinates.
*/
-QSizeF QGraphicsSceneTouchEvent::TouchPoint::sceneSize() const
+QRectF QGraphicsSceneTouchEvent::TouchPoint::sceneRect() const
{
- return d->sceneSize;
+ return d->sceneRect;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::TouchPoint::setSceneSize(const QSizeF &sceneSize)
+void QGraphicsSceneTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
{
if (d->ref != 1)
d = d->detach();
- d->sceneSize = sceneSize;
+ d->sceneRect = sceneRect;
}
/*!
- Returns the size of this touch point in screen coordinates.
+ Returns the rect of this touch point in screen coordinates.
*/
-QSizeF QGraphicsSceneTouchEvent::TouchPoint::screenSize() const
+QRectF QGraphicsSceneTouchEvent::TouchPoint::screenRect() const
{
- return d->screenSize;
+ return d->screenRect;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::TouchPoint::setScreenSize(const QSizeF &screenSize)
+void QGraphicsSceneTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
{
if (d->ref != 1)
d = d->detach();
- d->screenSize = screenSize;
+ d->screenRect = screenRect;
}
/*!
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index 3c53f36..3eb5cce 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -60,6 +60,7 @@ QT_MODULE(Gui)
class QMimeData;
class QPointF;
class QSizeF;
+class QRectF;
class QWidget;
class QGraphicsSceneEventPrivate;
@@ -393,14 +394,14 @@ public:
QPointF lastScreenPos() const;
void setLastScreenPos(const QPointF &lastScreenPos);
- QSizeF size() const;
- void setSize(const QSizeF &size);
+ QRectF rect() const;
+ void setRect(const QRectF &rect);
- QSizeF sceneSize() const;
- void setSceneSize(const QSizeF &sceneSize);
+ QRectF sceneRect() const;
+ void setSceneRect(const QRectF &sceneRect);
- QSizeF screenSize() const;
- void setScreenSize(const QSizeF &screenSize);
+ QRectF screenRect() const;
+ void setScreenRect(const QRectF &screenRect);
qreal pressure() const;
void setPressure(qreal pressure);
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index ae6cadf..0c5945d 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -4041,25 +4041,26 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
// update state
QPointF globalPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
- QSizeF contactArea = (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
- ? QSizeF(qreal(touchInput.cxContact) / qreal(100.),
- qreal(touchInput.cyContact) / qreal(100.))
- : QSizeF();
+ QRectF globalRect;
+ if (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
+ globalRect.setSize(QSizeF(qreal(touchInput.cxContact) / qreal(100.),
+ qreal(touchInput.cyContact) / qreal(100.)));
+ globalRect.moveCenter(globalPos);
if (touchInput.dwFlags & TOUCHEVENTF_DOWN) {
touchPoint.setState(Qt::TouchPointPressed);
touchPoint.setGlobalPos(globalPos);
- touchPoint.setSize(contactArea);
+ touchPoint.setRect(globalRect);
} else if (touchInput.dwFlags & TOUCHEVENTF_UP) {
touchPoint.setState(Qt::TouchPointReleased);
touchPoint.setGlobalPos(globalPos);
- touchPoint.setSize(QSizeF());
+ touchPoint.setRect(globalRect);
} else {
touchPoint.setState(globalPos == touchPoint.globalPos()
? Qt::TouchPointStationary
: Qt::TouchPointMoved);
touchPoint.setGlobalPos(globalPos);
- touchPoint.setSize(contactArea);
+ touchPoint.setRect(globalRect);
}
touchPoints.append(touchPoint);
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 5b3c0fe..7a86dbf 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3933,19 +3933,20 @@ void QTouchEvent::TouchPoint::setLastGlobalPos(const QPointF &lastGlobalPos)
}
/*!
- Returns the size of this touch point.
+ Returns the rect for this touch point. The rect is centered around the point returned by pos().
+ Note this function returns an empty rect if the device does not report touch point sizes.
*/
-QSizeF QTouchEvent::TouchPoint::size() const
+QRectF QTouchEvent::TouchPoint::rect() const
{
- return d->screenSize;
+ return d->screenRect;
}
/*! \internal */
-void QTouchEvent::TouchPoint::setSize(const QSizeF &size)
+void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
{
if (d->ref != 1)
d = d->detach();
- d->screenSize = size;
+ d->screenRect = rect;
}
/*!
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 0c4bbb7..4d62958 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -792,8 +792,8 @@ public:
QPointF lastGlobalPos() const;
void setLastGlobalPos(const QPointF &lastGlobalPos);
- QSizeF size() const;
- void setSize(const QSizeF &size);
+ QRectF rect() const;
+ void setRect(const QRectF &rect);
qreal pressure() const;
void setPressure(qreal pressure);
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 573fdc8..3475d0d 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -112,7 +112,7 @@ public:
QPointF pos, startPos, lastPos;
QPointF scenePos, startScenePos, lastScenePos;
QPointF screenPos, startScreenPos, lastScreenPos;
- QSizeF size, sceneSize, screenSize;
+ QRectF rect, sceneRect, screenRect;
qreal pressure;
static QTouchEventTouchPointPrivate *get(const QTouchEvent::TouchPoint &tp);