Make coordinates float based where it makes sense.

Mouse and Hover events already use FP corrdinates. They
also make sense for tablet and drop events.

Task-number: QTBUG-20115
Change-Id: Iff35d1f468567bd5a37236853dbc7725a37d87f2
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Lars Knoll 2011-08-11 16:23:10 +02:00 committed by Qt by Nokia
parent e30fdcf683
commit 0fb5c7e71d
5 changed files with 33 additions and 29 deletions

3
dist/changes-5.0.0 vendored
View File

@ -102,6 +102,9 @@ information about a particular change.
- QSound has been moved from QtGui to QtMultimedia - QSound has been moved from QtGui to QtMultimedia
- QTabletEvent::QTabletEvent does not take a hiResGlobalPos argument anymore,
as all coordinates are floating point based now.
- QTouchEvent: - QTouchEvent:
* The DeviceType enum and deviceType() have been deprecated due to * The DeviceType enum and deviceType() have been deprecated due to

View File

@ -1872,14 +1872,13 @@ QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
\sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z() \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
*/ */
QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos, QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
const QPointF &hiResGlobalPos, int device, int pointerType, int device, int pointerType,
qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID) qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
: QInputEvent(type, keyState), : QInputEvent(type, keyState),
mPos(pos), mPos(pos),
mGPos(globalPos), mGPos(globalPos),
mHiResGlobalPos(hiResGlobalPos),
mDev(device), mDev(device),
mPointerType(pointerType), mPointerType(pointerType),
mXT(xTilt), mXT(xTilt),
@ -2208,7 +2207,7 @@ QDragMoveEvent::~QDragMoveEvent()
The states of the mouse buttons and keyboard modifiers at the time of The states of the mouse buttons and keyboard modifiers at the time of
the drop are specified by \a buttons and \a modifiers. the drop are specified by \a buttons and \a modifiers.
*/ // ### pos is in which coordinate system? */ // ### pos is in which coordinate system?
QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type) Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
: QEvent(type), p(pos), mouseState(buttons), : QEvent(type), p(pos), mouseState(buttons),
modState(modifiers), act(actions), modState(modifiers), act(actions),

View File

@ -183,21 +183,27 @@ public:
enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse, enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
XFreeEraser /*internal*/, RotationStylus }; XFreeEraser /*internal*/, RotationStylus };
enum PointerType { UnknownPointer, Pen, Cursor, Eraser }; enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
QTabletEvent(Type t, const QPoint &pos, const QPoint &globalPos, const QPointF &hiResGlobalPos, QTabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
int device, int pointerType, qreal pressure, int xTilt, int yTilt, int device, int pointerType, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z, qreal tangentialPressure, qreal rotation, int z,
Qt::KeyboardModifiers keyState, qint64 uniqueID); Qt::KeyboardModifiers keyState, qint64 uniqueID);
~QTabletEvent(); ~QTabletEvent();
inline const QPoint &pos() const { return mPos; } inline const QPoint pos() const { return mPos.toPoint(); }
inline const QPoint &globalPos() const { return mGPos; } inline const QPoint globalPos() const { return mGPos.toPoint(); }
inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; } #if QT_DEPRECATED_SINCE(5,0)
inline int x() const { return mPos.x(); } QT_DEPRECATED inline const QPointF &hiResGlobalPos() const { return mPos; }
inline int y() const { return mPos.y(); } #endif
inline int globalX() const { return mGPos.x(); }
inline int globalY() const { return mGPos.y(); } inline const QPointF &posF() const { return mPos; }
inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); } inline const QPointF &globalPosF() const { return mGPos; }
inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); }
inline int x() const { return qRound(mPos.x()); }
inline int y() const { return qRound(mPos.y()); }
inline int globalX() const { return qRound(mGPos.x()); }
inline int globalY() const { return qRound(mGPos.y()); }
inline qreal hiResGlobalX() const { return mGPos.x(); }
inline qreal hiResGlobalY() const { return mGPos.y(); }
inline TabletDevice device() const { return TabletDevice(mDev); } inline TabletDevice device() const { return TabletDevice(mDev); }
inline PointerType pointerType() const { return PointerType(mPointerType); } inline PointerType pointerType() const { return PointerType(mPointerType); }
inline qint64 uniqueId() const { return mUnique; } inline qint64 uniqueId() const { return mUnique; }
@ -209,8 +215,7 @@ public:
inline int yTilt() const { return mYT; } inline int yTilt() const { return mYT; }
protected: protected:
QPoint mPos, mGPos; QPointF mPos, mGPos;
QPointF mHiResGlobalPos;
int mDev, mPointerType, mXT, mYT, mZ; int mDev, mPointerType, mXT, mYT, mZ;
qreal mPress, mTangential, mRot; qreal mPress, mTangential, mRot;
qint64 mUnique; qint64 mUnique;
@ -477,11 +482,12 @@ class QMimeData;
class Q_GUI_EXPORT QDropEvent : public QEvent class Q_GUI_EXPORT QDropEvent : public QEvent
{ {
public: public:
QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop); Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
~QDropEvent(); ~QDropEvent();
inline const QPoint &pos() const { return p; } inline const QPoint pos() const { return p.toPoint(); }
inline const QPointF &posF() const { return p; }
inline Qt::MouseButtons mouseButtons() const { return mouseState; } inline Qt::MouseButtons mouseButtons() const { return mouseState; }
inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; } inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
@ -497,7 +503,7 @@ public:
protected: protected:
friend class QApplication; friend class QApplication;
QPoint p; QPointF p;
Qt::MouseButtons mouseState; Qt::MouseButtons mouseState;
Qt::KeyboardModifiers modState; Qt::KeyboardModifiers modState;
Qt::DropActions act; Qt::DropActions act;

View File

@ -3700,11 +3700,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
{ {
QWidget *w = static_cast<QWidget *>(receiver); QWidget *w = static_cast<QWidget *>(receiver);
QTabletEvent *tablet = static_cast<QTabletEvent*>(e); QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
QPoint relpos = tablet->pos(); QPointF relpos = tablet->posF();
bool eventAccepted = tablet->isAccepted(); bool eventAccepted = tablet->isAccepted();
while (w) { while (w) {
QTabletEvent te(tablet->type(), relpos, tablet->globalPos(), QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(),
tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(), tablet->device(), tablet->pointerType(),
tablet->pressure(), tablet->xTilt(), tablet->yTilt(), tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
tablet->tangentialPressure(), tablet->rotation(), tablet->z(), tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
tablet->modifiers(), tablet->uniqueId()); tablet->modifiers(), tablet->uniqueId());
@ -3799,7 +3799,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
} }
if (w->isWindow()) if (w->isWindow())
break; break;
dragEvent->p = w->mapToParent(dragEvent->p); dragEvent->p = w->mapToParent(dragEvent->p.toPoint());
w = w->parentWidget(); w = w->parentWidget();
} }
} }
@ -3838,7 +3838,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QDropEvent *dragEvent = static_cast<QDropEvent *>(e); QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
QWidget *origReciver = static_cast<QWidget *>(receiver); QWidget *origReciver = static_cast<QWidget *>(receiver);
while (origReciver && w != origReciver) { while (origReciver && w != origReciver) {
dragEvent->p = origReciver->mapToParent(dragEvent->p); dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint());
origReciver = origReciver->parentWidget(); origReciver = origReciver->parentWidget();
} }
} }

View File

@ -183,10 +183,6 @@ static QEvent *cloneEvent(QEvent *e)
return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e)); return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
case QEvent::AccessibilityPrepare: case QEvent::AccessibilityPrepare:
return new QEvent(*e); return new QEvent(*e);
#ifndef QT_NO_TABLETEVENT
case QEvent::TabletMove:
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
#endif //QT_NO_TABLETEVENT
case QEvent::LocaleChange: case QEvent::LocaleChange:
return new QEvent(*e); return new QEvent(*e);
case QEvent::LanguageChange: case QEvent::LanguageChange:
@ -196,8 +192,8 @@ static QEvent *cloneEvent(QEvent *e)
case QEvent::Style: case QEvent::Style:
return new QEvent(*e); return new QEvent(*e);
#ifndef QT_NO_TABLETEVENT #ifndef QT_NO_TABLETEVENT
case QEvent::TabletMove:
case QEvent::TabletPress: case QEvent::TabletPress:
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
case QEvent::TabletRelease: case QEvent::TabletRelease:
return new QTabletEvent(*static_cast<QTabletEvent*>(e)); return new QTabletEvent(*static_cast<QTabletEvent*>(e));
#endif //QT_NO_TABLETEVENT #endif //QT_NO_TABLETEVENT