| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QT3DINPUT_QMOUSEEVENT_H |
| 41 | #define QT3DINPUT_QMOUSEEVENT_H |
| 42 | |
| 43 | #include <Qt3DInput/qt3dinput_global.h> |
| 44 | #include <QtCore/QtGlobal> |
| 45 | #include <QtCore/QObject> |
| 46 | #include <QtGui/QMouseEvent> |
| 47 | |
| 48 | QT_BEGIN_NAMESPACE |
| 49 | |
| 50 | namespace Qt3DInput { |
| 51 | |
| 52 | class Q_3DINPUTSHARED_EXPORT QMouseEvent : public QObject |
| 53 | { |
| 54 | Q_OBJECT |
| 55 | Q_PROPERTY(int x READ x CONSTANT) |
| 56 | Q_PROPERTY(int y READ y CONSTANT) |
| 57 | Q_PROPERTY(bool wasHeld READ wasHeld CONSTANT) |
| 58 | Q_PROPERTY(Qt3DInput::QMouseEvent::Buttons button READ button CONSTANT) |
| 59 | Q_PROPERTY(int buttons READ buttons CONSTANT) |
| 60 | Q_PROPERTY(Qt3DInput::QMouseEvent::Modifiers modifiers READ modifiers CONSTANT) |
| 61 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) |
| 62 | |
| 63 | public: |
| 64 | enum Buttons { |
| 65 | LeftButton = Qt::LeftButton, |
| 66 | RightButton = Qt::RightButton, |
| 67 | MiddleButton = Qt::MiddleButton, |
| 68 | BackButton = Qt::BackButton, |
| 69 | NoButton = Qt::NoButton |
| 70 | }; |
| 71 | Q_ENUM(Buttons) // LCOV_EXCL_LINE |
| 72 | |
| 73 | enum Modifiers { |
| 74 | NoModifier = Qt::NoModifier, |
| 75 | ShiftModifier = Qt::ShiftModifier, |
| 76 | ControlModifier = Qt::ControlModifier, |
| 77 | AltModifier = Qt::AltModifier, |
| 78 | MetaModifier = Qt::MetaModifier, |
| 79 | KeypadModifier = Qt::KeypadModifier |
| 80 | }; |
| 81 | Q_ENUM(Modifiers) // LCOV_EXCL_LINE |
| 82 | // TO DO Qt6 Modifiers -> Modifier and add Q_FLAG(Modifiers) |
| 83 | |
| 84 | explicit QMouseEvent(const QT_PREPEND_NAMESPACE(QMouseEvent) &e); |
| 85 | ~QMouseEvent(); |
| 86 | |
| 87 | inline int x() const { return m_event.x(); } |
| 88 | inline int y() const { return m_event.y(); } |
| 89 | inline bool wasHeld() const { |
| 90 | #if QT_CONFIG(gestures) |
| 91 | return static_cast<Qt::GestureType>(m_event.type()) == Qt::TapAndHoldGesture; |
| 92 | #else |
| 93 | return false; |
| 94 | #endif |
| 95 | } |
| 96 | Buttons button() const; |
| 97 | int buttons() const; |
| 98 | Modifiers modifiers() const; |
| 99 | |
| 100 | inline bool isAccepted() const { return m_event.isAccepted(); } |
| 101 | inline void setAccepted(bool accepted) { m_event.setAccepted(accepted); } |
| 102 | inline QEvent::Type type() const { return m_event.type(); } |
| 103 | |
| 104 | private: |
| 105 | QT_PREPEND_NAMESPACE(QMouseEvent) m_event; |
| 106 | }; |
| 107 | |
| 108 | typedef QSharedPointer<QMouseEvent> QMouseEventPtr; |
| 109 | |
| 110 | #if QT_CONFIG(wheelevent) |
| 111 | class Q_3DINPUTSHARED_EXPORT QWheelEvent : public QObject |
| 112 | { |
| 113 | Q_OBJECT |
| 114 | Q_PROPERTY(int x READ x CONSTANT) |
| 115 | Q_PROPERTY(int y READ y CONSTANT) |
| 116 | Q_PROPERTY(QPoint angleDelta READ angleDelta CONSTANT) |
| 117 | Q_PROPERTY(int buttons READ buttons CONSTANT) |
| 118 | Q_PROPERTY(Qt3DInput::QWheelEvent::Modifiers modifiers READ modifiers CONSTANT) |
| 119 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) |
| 120 | |
| 121 | public: |
| 122 | enum Buttons { |
| 123 | LeftButton = Qt::LeftButton, |
| 124 | RightButton = Qt::RightButton, |
| 125 | MiddleButton = Qt::MiddleButton, |
| 126 | BackButton = Qt::BackButton, |
| 127 | NoButton = Qt::NoButton |
| 128 | }; |
| 129 | Q_ENUM(Buttons) // LCOV_EXCL_LINE |
| 130 | |
| 131 | enum Modifiers { |
| 132 | NoModifier = Qt::NoModifier, |
| 133 | ShiftModifier = Qt::ShiftModifier, |
| 134 | ControlModifier = Qt::ControlModifier, |
| 135 | AltModifier = Qt::AltModifier, |
| 136 | MetaModifier = Qt::MetaModifier, |
| 137 | KeypadModifier = Qt::KeypadModifier |
| 138 | }; |
| 139 | Q_ENUM(Modifiers) // LCOV_EXCL_LINE |
| 140 | // TO DO Qt6 Modifiers -> Modifier and add Q_FLAG(Modifiers) |
| 141 | |
| 142 | explicit QWheelEvent(const QT_PREPEND_NAMESPACE(QWheelEvent) &e); |
| 143 | ~QWheelEvent(); |
| 144 | |
| 145 | inline int x() const { return int(m_event.position().x()); } |
| 146 | inline int y() const { return int(m_event.position().y()); } |
| 147 | inline QPoint angleDelta() const { return m_event.angleDelta(); } |
| 148 | int buttons() const; |
| 149 | Modifiers modifiers() const; |
| 150 | |
| 151 | inline bool isAccepted() const { return m_event.isAccepted(); } |
| 152 | inline void setAccepted(bool accepted) { m_event.setAccepted(accepted); } |
| 153 | inline QEvent::Type type() const { return m_event.type(); } |
| 154 | |
| 155 | private: |
| 156 | QT_PREPEND_NAMESPACE(QWheelEvent) m_event; |
| 157 | }; |
| 158 | |
| 159 | typedef QSharedPointer<QWheelEvent> QWheelEventPtr; |
| 160 | #endif |
| 161 | |
| 162 | } // namespace Qt3DInput |
| 163 | |
| 164 | QT_END_NAMESPACE |
| 165 | |
| 166 | Q_DECLARE_METATYPE(Qt3DInput::QMouseEvent*) // LCOV_EXCL_LINE |
| 167 | |
| 168 | #if QT_CONFIG(wheelevent) |
| 169 | Q_DECLARE_METATYPE(Qt3DInput::QWheelEvent*) // LCOV_EXCL_LINE |
| 170 | #endif |
| 171 | |
| 172 | #endif // QT3DINPUT_QMOUSEEVENT_H |
| 173 | |