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:
parent
e30fdcf683
commit
0fb5c7e71d
3
dist/changes-5.0.0
vendored
3
dist/changes-5.0.0
vendored
@ -102,6 +102,9 @@ information about a particular change.
|
||||
|
||||
- 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:
|
||||
|
||||
* The DeviceType enum and deviceType() have been deprecated due to
|
||||
|
@ -1872,14 +1872,13 @@ QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
|
||||
\sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
|
||||
*/
|
||||
|
||||
QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
||||
const QPointF &hiResGlobalPos, int device, int pointerType,
|
||||
QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
|
||||
int device, int pointerType,
|
||||
qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
|
||||
qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
|
||||
: QInputEvent(type, keyState),
|
||||
mPos(pos),
|
||||
mGPos(globalPos),
|
||||
mHiResGlobalPos(hiResGlobalPos),
|
||||
mDev(device),
|
||||
mPointerType(pointerType),
|
||||
mXT(xTilt),
|
||||
@ -2208,7 +2207,7 @@ QDragMoveEvent::~QDragMoveEvent()
|
||||
The states of the mouse buttons and keyboard modifiers at the time of
|
||||
the drop are specified by \a buttons and \a modifiers.
|
||||
*/ // ### 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)
|
||||
: QEvent(type), p(pos), mouseState(buttons),
|
||||
modState(modifiers), act(actions),
|
||||
|
@ -183,21 +183,27 @@ public:
|
||||
enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
|
||||
XFreeEraser /*internal*/, RotationStylus };
|
||||
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,
|
||||
qreal tangentialPressure, qreal rotation, int z,
|
||||
Qt::KeyboardModifiers keyState, qint64 uniqueID);
|
||||
~QTabletEvent();
|
||||
|
||||
inline const QPoint &pos() const { return mPos; }
|
||||
inline const QPoint &globalPos() const { return mGPos; }
|
||||
inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; }
|
||||
inline int x() const { return mPos.x(); }
|
||||
inline int y() const { return mPos.y(); }
|
||||
inline int globalX() const { return mGPos.x(); }
|
||||
inline int globalY() const { return mGPos.y(); }
|
||||
inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); }
|
||||
inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); }
|
||||
inline const QPoint pos() const { return mPos.toPoint(); }
|
||||
inline const QPoint globalPos() const { return mGPos.toPoint(); }
|
||||
#if QT_DEPRECATED_SINCE(5,0)
|
||||
QT_DEPRECATED inline const QPointF &hiResGlobalPos() const { return mPos; }
|
||||
#endif
|
||||
|
||||
inline const QPointF &posF() const { return mPos; }
|
||||
inline const QPointF &globalPosF() const { return mGPos; }
|
||||
|
||||
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 PointerType pointerType() const { return PointerType(mPointerType); }
|
||||
inline qint64 uniqueId() const { return mUnique; }
|
||||
@ -209,8 +215,7 @@ public:
|
||||
inline int yTilt() const { return mYT; }
|
||||
|
||||
protected:
|
||||
QPoint mPos, mGPos;
|
||||
QPointF mHiResGlobalPos;
|
||||
QPointF mPos, mGPos;
|
||||
int mDev, mPointerType, mXT, mYT, mZ;
|
||||
qreal mPress, mTangential, mRot;
|
||||
qint64 mUnique;
|
||||
@ -477,11 +482,12 @@ class QMimeData;
|
||||
class Q_GUI_EXPORT QDropEvent : public QEvent
|
||||
{
|
||||
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);
|
||||
~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::KeyboardModifiers keyboardModifiers() const { return modState; }
|
||||
|
||||
@ -497,7 +503,7 @@ public:
|
||||
|
||||
protected:
|
||||
friend class QApplication;
|
||||
QPoint p;
|
||||
QPointF p;
|
||||
Qt::MouseButtons mouseState;
|
||||
Qt::KeyboardModifiers modState;
|
||||
Qt::DropActions act;
|
||||
|
@ -3700,11 +3700,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
{
|
||||
QWidget *w = static_cast<QWidget *>(receiver);
|
||||
QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
|
||||
QPoint relpos = tablet->pos();
|
||||
QPointF relpos = tablet->posF();
|
||||
bool eventAccepted = tablet->isAccepted();
|
||||
while (w) {
|
||||
QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
|
||||
tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
|
||||
QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(),
|
||||
tablet->device(), tablet->pointerType(),
|
||||
tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
|
||||
tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
|
||||
tablet->modifiers(), tablet->uniqueId());
|
||||
@ -3799,7 +3799,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
}
|
||||
if (w->isWindow())
|
||||
break;
|
||||
dragEvent->p = w->mapToParent(dragEvent->p);
|
||||
dragEvent->p = w->mapToParent(dragEvent->p.toPoint());
|
||||
w = w->parentWidget();
|
||||
}
|
||||
}
|
||||
@ -3838,7 +3838,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
|
||||
QWidget *origReciver = static_cast<QWidget *>(receiver);
|
||||
while (origReciver && w != origReciver) {
|
||||
dragEvent->p = origReciver->mapToParent(dragEvent->p);
|
||||
dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint());
|
||||
origReciver = origReciver->parentWidget();
|
||||
}
|
||||
}
|
||||
|
@ -183,10 +183,6 @@ static QEvent *cloneEvent(QEvent *e)
|
||||
return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
|
||||
case QEvent::AccessibilityPrepare:
|
||||
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:
|
||||
return new QEvent(*e);
|
||||
case QEvent::LanguageChange:
|
||||
@ -196,8 +192,8 @@ static QEvent *cloneEvent(QEvent *e)
|
||||
case QEvent::Style:
|
||||
return new QEvent(*e);
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
case QEvent::TabletMove:
|
||||
case QEvent::TabletPress:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
case QEvent::TabletRelease:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
#endif //QT_NO_TABLETEVENT
|
||||
|
Loading…
Reference in New Issue
Block a user