1 | // Copyright (C) 2024 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DXRVIRTUALMOUSE_P_H |
5 | #define QQUICK3DXRVIRTUALMOUSE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QObject> |
19 | #include <QEvent> |
20 | #include <QtQml/qqml.h> |
21 | #include <QTimer> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQuick3DXrView; |
26 | class QQuick3DNode; |
27 | |
28 | class QQuick3DXrVirtualMouse : public QObject |
29 | { |
30 | Q_OBJECT |
31 | Q_PROPERTY(bool rightMouseButton READ rightMouseButton WRITE setRightMouseButton NOTIFY rightMouseButtonChanged) |
32 | Q_PROPERTY(bool leftMouseButton READ leftMouseButton WRITE setLeftMouseButton NOTIFY leftMouseButtonChanged) |
33 | Q_PROPERTY(bool middleMouseButton READ middleMouseButton WRITE setMiddleMouseButton NOTIFY middleMouseButtonChanged) |
34 | Q_PROPERTY(float scrollWheelX READ scrollWheelX WRITE setScrollWheelX NOTIFY scrollWheelXChanged) |
35 | Q_PROPERTY(float scrollWheelY READ scrollWheelY WRITE setScrollWheelY NOTIFY scrollWheelYChanged) |
36 | Q_PROPERTY(int scrollTimerInterval READ scrollTimerInterval WRITE setScrollTimerInterval NOTIFY scrollTimerIntervalChanged) |
37 | Q_PROPERTY(int scrollPixelDelta READ scrollPixelDelta WRITE setScrollPixelDelta NOTIFY scrollPixelDeltaChanged) |
38 | Q_PROPERTY(QQuick3DNode* source READ source WRITE setSource NOTIFY sourceChanged) |
39 | Q_PROPERTY(QQuick3DXrView* view READ view WRITE setView NOTIFY viewChanged) |
40 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) |
41 | |
42 | QML_NAMED_ELEMENT(XrVirtualMouse) |
43 | QML_ADDED_IN_VERSION(6, 8) |
44 | |
45 | public: |
46 | explicit QQuick3DXrVirtualMouse(QObject *parent = nullptr); |
47 | |
48 | bool rightMouseButton() const; |
49 | bool leftMouseButton() const; |
50 | bool middleMouseButton() const; |
51 | float scrollWheelX() const; |
52 | float scrollWheelY() const; |
53 | int scrollTimerInterval() const; |
54 | int scrollPixelDelta() const; |
55 | |
56 | QQuick3DNode *source() const; |
57 | QQuick3DXrView* view() const; |
58 | |
59 | bool enabled() const; |
60 | |
61 | public Q_SLOTS: |
62 | void setRightMouseButton(bool rightMouseButton); |
63 | void setLeftMouseButton(bool leftMouseButton); |
64 | void setMiddleMouseButton(bool middleMouseButton); |
65 | void setScrollWheelX(float scrollWheelX); |
66 | void setScrollWheelY(float scrollWheelY); |
67 | void setScrollTimerInterval(int scrollTimerInterval); |
68 | void setScrollPixelDelta(int scrollPixelDelta); |
69 | void setSource(QQuick3DNode* source); |
70 | void setView(QQuick3DXrView* view); |
71 | void setEnabled(bool enabled); |
72 | |
73 | private Q_SLOTS: |
74 | void moveEvent(); |
75 | void generateWheelEvent(); |
76 | |
77 | Q_SIGNALS: |
78 | void rightMouseButtonChanged(bool rightMouseButton); |
79 | void leftMouseButtonChanged(bool leftMouseButton); |
80 | void middleMouseButtonChanged(bool middleMouseButton); |
81 | void scrollWheelXChanged(float scrollWheelX); |
82 | void scrollWheelYChanged(float scrollWheelY); |
83 | void scrollTimerIntervalChanged(int scrollTimerInterval); |
84 | void scrollPixelDeltaChanged(int scrollPixelDelta); |
85 | void sourceChanged(QQuick3DNode* source); |
86 | void viewChanged(QQuick3DXrView* view); |
87 | void enabledChanged(bool enabled); |
88 | |
89 | private: |
90 | void generateEvent(QEvent::Type type, Qt::MouseButton button = Qt::NoButton); |
91 | |
92 | QTimer* m_scrollTimer = nullptr; |
93 | bool m_rightMouseButton = false; |
94 | bool m_leftMouseButton = false; |
95 | bool m_middleMouseButton = false; |
96 | float m_scrollWheelX = 0; |
97 | float m_scrollWheelY = 0; |
98 | int m_scrollTimerInterval = 30; |
99 | int m_scrollPixelDelta = 15; |
100 | QQuick3DNode* m_source = nullptr; |
101 | QQuick3DXrView* m_view = nullptr; |
102 | bool m_enabled = true; |
103 | }; |
104 | |
105 | QT_END_NAMESPACE |
106 | |
107 | #endif // QQUICK3DXRVIRTUALMOUSE_P_H |
108 | |