summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-03-23 22:26:08 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2016-12-07 08:33:35 +0000
commit3c159957f863cf8d367a9261e7016e52cd0348c1 (patch)
tree1a56cb165b674dd49170de88b4254cd4ad0d51a4 /src/gui/kernel/qevent_p.h
parentf7253b25684eabf68973cc4486b32f0dc346b70c (diff)
TouchPoint: add horizontalDiameter, verticalDiameter; deprecate rects
The contact patch of a finger on a touchscreen tends to be roughly elliptical. If we model it as a QRectF, it's not clear whether the ellipse should be considered to be inscribed in the rectangle and then rotated, or whether the rectangle represents the outer bounds of the rotated ellipse. In practice, since most touchscreens can't measure rotation, it is effectively the latter. But modeling it that way means information is lost if the touchscreen can measure rotation: you can determine the bounds of a rotated ellipse, but you cannot derive the rotated ellipse from its bounds. So it's better to model the axes of the ellipse explicitly. This has the added benefit of saving a little storage space: we replace 3 QRectF instances, whose width and height will normally be the same, with 3 positions (bringing the total to 12 QPointF's) and one set of axes. Further, most applications only care about the center of each contact patch, so it's better to store that explicitly instead of calculating QRectF::center() repeatedly. In the past there may have been an assumption that the width of the rect is the same as the horizontalDiameter of the ellipse, so the rect could be considered to be rotated, and the ellipse to be inscribed. But in d0b1c646b4a351f7eea2137c68993ae63b2b6bab and 40e4949674eaf7ceb09f6d18479ead1a36b384fd the point was made that the rect is actually the bounding box of the rotated ellipse. [ChangeLog][QtGui][QTouchEvent] TouchPoint::rect(), sceneRect() and screenRect() are deprecated; a touchpoint is now modeled as an ellipse, so please use pos(), scenePos(), screenPos(), horizontalDiameter() and verticalDiameter() instead. Change-Id: Ic06f6165e2d90fc9d4cc19cf4938d4faf5766bb4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent_p.h')
-rw-r--r--src/gui/kernel/qevent_p.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 7e82b9c654..a8b4d520d4 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -66,7 +66,9 @@ public:
id(id),
state(Qt::TouchPointReleased),
pressure(qreal(-1.)),
- rotation(qreal(0.))
+ rotation(qreal(0.)),
+ verticalDiameter(0),
+ horizontalDiameter(0)
{ }
inline QTouchEventTouchPointPrivate *detach()
@@ -82,12 +84,13 @@ public:
int id;
QPointerUniqueId uniqueId;
Qt::TouchPointStates state;
- QRectF rect, sceneRect, screenRect;
- QPointF normalizedPos,
+ QPointF pos, scenePos, screenPos, normalizedPos,
startPos, startScenePos, startScreenPos, startNormalizedPos,
lastPos, lastScenePos, lastScreenPos, lastNormalizedPos;
qreal pressure;
qreal rotation;
+ qreal verticalDiameter;
+ qreal horizontalDiameter;
QVector2D velocity;
QTouchEvent::TouchPoint::InfoFlags flags;
QVector<QPointF> rawScreenPositions;