Use floating point coordinates in events
Use FP coordinates in Mouse, Wheel and Hover events. Change-Id: I8b43ca257620b4653ae5d6b6122c516384db1e48 Reviewed-on: http://codereview.qt.nokia.com/766 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>bb10
parent
59d1278c9e
commit
e3172080a2
|
|
@ -274,12 +274,12 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
|
|||
pos = mapToReceiver(pos, receiver);
|
||||
|
||||
// Send mouse event.
|
||||
QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(type, pos,
|
||||
receiver->mapToGlobal(pos.toPoint()), event->button(),
|
||||
event->buttons(), event->modifiers());
|
||||
QMouseEvent mouseEvent(type, pos,
|
||||
receiver->mapToGlobal(pos.toPoint()), event->button(),
|
||||
event->buttons(), event->modifiers());
|
||||
|
||||
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
|
||||
QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
|
||||
QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
|
||||
&embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
|
||||
embeddedMouseGrabber = embeddedMouseGrabberPtr;
|
||||
|
||||
|
|
@ -302,8 +302,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
|
|||
#endif
|
||||
}
|
||||
|
||||
event->setAccepted(mouseEvent->isAccepted());
|
||||
delete mouseEvent;
|
||||
event->setAccepted(mouseEvent.isAccepted());
|
||||
}
|
||||
|
||||
void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event)
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ QInputEvent::~QInputEvent()
|
|||
position explicitly.
|
||||
*/
|
||||
|
||||
QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
|
||||
QMouseEvent::QMouseEvent(Type type, const QPointF &position, Qt::MouseButton button,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
|
||||
: QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
|
||||
{
|
||||
|
|
@ -228,28 +228,20 @@ QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
|||
modifiers.
|
||||
|
||||
*/
|
||||
QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
||||
QMouseEvent::QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos,
|
||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
: QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
|
||||
{}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
|
||||
const QPoint &globalPos, Qt::MouseButton button,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QMouseEvent::hasExtendedInfo() const
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QPointF QMouseEvent::posF() const
|
||||
|
||||
\since 4.4
|
||||
|
||||
Returns the position of the mouse cursor as a QPointF, relative to the
|
||||
|
|
@ -261,28 +253,6 @@ QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos
|
|||
|
||||
\sa x() y() pos() globalPos()
|
||||
*/
|
||||
QPointF QMouseEvent::posF() const
|
||||
{
|
||||
return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
|
||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
: QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
|
||||
{
|
||||
d = reinterpret_cast<QEventPrivate *>(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QMouseEventEx::~QMouseEventEx()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const QPoint &QMouseEvent::pos() const
|
||||
|
|
@ -475,7 +445,7 @@ QMouseEventEx::~QMouseEventEx()
|
|||
receiving widget, while \a oldPos is the previous mouse cursor's
|
||||
position relative to the receiving widget.
|
||||
*/
|
||||
QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
|
||||
QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos)
|
||||
: QEvent(type), p(pos), op(oldPos)
|
||||
{
|
||||
}
|
||||
|
|
@ -542,7 +512,7 @@ QHoverEvent::~QHoverEvent()
|
|||
\sa pos() delta() state()
|
||||
*/
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
|
||||
QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||
Qt::Orientation orient)
|
||||
: QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
|
||||
|
|
@ -581,7 +551,7 @@ QWheelEvent::QWheelEvent(const QPoint &pos, int delta, int state, Qt::Orientatio
|
|||
|
||||
\sa pos() globalPos() delta() state()
|
||||
*/
|
||||
QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
|
||||
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||
Qt::Orientation orient)
|
||||
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
|
||||
|
|
|
|||
|
|
@ -85,27 +85,24 @@ protected:
|
|||
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
|
||||
{
|
||||
public:
|
||||
QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
|
||||
QMouseEvent(Type type, const QPointF &pos, Qt::MouseButton button,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
||||
QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
|
||||
QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos,
|
||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers);
|
||||
~QMouseEvent();
|
||||
|
||||
inline const QPoint &pos() const { return p; }
|
||||
inline const QPoint &globalPos() const { return g; }
|
||||
inline int x() const { return p.x(); }
|
||||
inline int y() const { return p.y(); }
|
||||
inline int globalX() const { return g.x(); }
|
||||
inline int globalY() const { return g.y(); }
|
||||
inline QPoint pos() const { return p.toPoint(); }
|
||||
inline QPoint globalPos() const { return g.toPoint(); }
|
||||
inline int x() const { return qRound(p.x()); }
|
||||
inline int y() const { return qRound(p.y()); }
|
||||
inline int globalX() const { return qRound(g.x()); }
|
||||
inline int globalY() const { return qRound(g.y()); }
|
||||
inline Qt::MouseButton button() const { return b; }
|
||||
inline Qt::MouseButtons buttons() const { return mouseState; }
|
||||
|
||||
static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
|
||||
const QPoint &globalPos, Qt::MouseButton button,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
|
||||
inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
|
||||
QPointF posF() const;
|
||||
const QPointF &posF() const { return p; }
|
||||
const QPointF &globalPosF() const { return g; }
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
QT3_SUPPORT_CONSTRUCTOR QMouseEvent(Type type, const QPoint &pos, Qt::ButtonState button, int state);
|
||||
|
|
@ -117,7 +114,7 @@ public:
|
|||
{ return Qt::ButtonState(int(mouseState)|int(modifiers())); }
|
||||
#endif
|
||||
protected:
|
||||
QPoint p, g;
|
||||
QPointF p, g;
|
||||
Qt::MouseButton b;
|
||||
Qt::MouseButtons mouseState;
|
||||
};
|
||||
|
|
@ -125,31 +122,34 @@ protected:
|
|||
class Q_GUI_EXPORT QHoverEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos);
|
||||
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos);
|
||||
~QHoverEvent();
|
||||
|
||||
inline const QPoint &pos() const { return p; }
|
||||
inline const QPoint &oldPos() const { return op; }
|
||||
inline QPoint pos() const { return p.toPoint(); }
|
||||
inline QPoint oldPos() const { return op.toPoint(); }
|
||||
|
||||
inline const QPointF &posF() const { return p; }
|
||||
inline const QPointF &oldPosF() const { return op; }
|
||||
|
||||
protected:
|
||||
QPoint p, op;
|
||||
QPointF p, op;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
class Q_GUI_EXPORT QWheelEvent : public QInputEvent
|
||||
{
|
||||
public:
|
||||
QWheelEvent(const QPoint &pos, int delta,
|
||||
QWheelEvent(const QPointF &pos, int delta,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||
Qt::Orientation orient = Qt::Vertical);
|
||||
QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
|
||||
QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||
Qt::Orientation orient = Qt::Vertical);
|
||||
~QWheelEvent();
|
||||
|
||||
inline int delta() const { return d; }
|
||||
inline const QPoint &pos() const { return p; }
|
||||
inline const QPoint &globalPos() const { return g; }
|
||||
inline QPoint pos() const { return p.toPoint(); }
|
||||
inline QPoint globalPos() const { return g.toPoint(); }
|
||||
inline int x() const { return p.x(); }
|
||||
inline int y() const { return p.y(); }
|
||||
inline int globalX() const { return g.x(); }
|
||||
|
|
@ -158,6 +158,9 @@ public:
|
|||
inline Qt::MouseButtons buttons() const { return mouseState; }
|
||||
Qt::Orientation orientation() const { return o; }
|
||||
|
||||
inline const QPointF &posF() const { return p; }
|
||||
inline const QPointF &globalPosF() const { return g; }
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
QT3_SUPPORT_CONSTRUCTOR QWheelEvent(const QPoint &pos, int delta, int state,
|
||||
Qt::Orientation orient = Qt::Vertical);
|
||||
|
|
@ -167,8 +170,8 @@ public:
|
|||
{ return static_cast<Qt::ButtonState>(int(buttons())|int(modifiers())); }
|
||||
#endif
|
||||
protected:
|
||||
QPoint p;
|
||||
QPoint g;
|
||||
QPointF p;
|
||||
QPointF g;
|
||||
int d;
|
||||
Qt::MouseButtons mouseState;
|
||||
Qt::Orientation o;
|
||||
|
|
|
|||
|
|
@ -81,20 +81,6 @@ protected:
|
|||
friend class QKeyEvent;
|
||||
};
|
||||
|
||||
// ### Qt 5: remove
|
||||
class QMouseEventEx : public QMouseEvent
|
||||
{
|
||||
public:
|
||||
QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
|
||||
Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers);
|
||||
~QMouseEventEx();
|
||||
|
||||
protected:
|
||||
QPointF posF;
|
||||
friend class QMouseEvent;
|
||||
};
|
||||
|
||||
class QTouchEventTouchPointPrivate
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Reference in New Issue