1 | // Copyright (C) 2024 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtGraphs API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef QGRAPHSINPUTHANDLER_P_H |
15 | #define QGRAPHSINPUTHANDLER_P_H |
16 | |
17 | #include <QtQuick/qquickitem.h> |
18 | |
19 | QT_BEGIN_NAMESPACE |
20 | |
21 | class QQuickGraphsItem; |
22 | class QQuickTapHandler; |
23 | class QQuickDragHandler; |
24 | class QQuickPinchHandler; |
25 | class QQuickWheelHandler; |
26 | class QQuickWheelEvent; |
27 | |
28 | class QGraphsInputHandler : public QQuickItem |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | QGraphsInputHandler(QQuickItem *parent = nullptr); |
34 | |
35 | ~QGraphsInputHandler() override; |
36 | |
37 | void setGraphsItem(QQuickGraphsItem *item); |
38 | QPoint pendingPoint() { return m_pendingPoint; } |
39 | |
40 | void setZoomEnabled(bool enable); |
41 | bool isZoomEnabled(); |
42 | void setZoomAtTargetEnabled(bool enable); |
43 | bool isZoomAtTargetEnabled(); |
44 | void setRotationEnabled(bool enable); |
45 | bool isRotationEnabled(); |
46 | void setSelectionEnabled(bool enable); |
47 | bool isSelectionEnabled(); |
48 | |
49 | void setDefaultInputHandler(); |
50 | void unsetDefaultInputHandler(); |
51 | void unsetDefaultTapHandler(); |
52 | void unsetDefaultDragHandler(); |
53 | void unsetDefaultWheelHandler(); |
54 | void unsetDefaultPinchHandler(); |
55 | void setDragButton(Qt::MouseButtons button); |
56 | |
57 | void onTapped(); |
58 | void onTranslationChanged(QVector2D delta); |
59 | void onGrabChanged(QPointingDevice::GrabTransition transition, QEventPoint point); |
60 | void onWheel(QQuickWheelEvent *event); |
61 | void onPinchScaleChanged(qreal delta); |
62 | |
63 | Q_SIGNAL void mouseMove(QPoint mousePos); |
64 | |
65 | protected: |
66 | void hoverMoveEvent(QHoverEvent *event) override; |
67 | |
68 | private: |
69 | bool m_zoomEnabled; |
70 | bool m_zoomAtTarget; |
71 | bool m_rotationEnabled; |
72 | bool m_selectionEnabled; |
73 | QPoint m_pendingPoint; |
74 | qreal m_pinchDiff; |
75 | |
76 | QQuickTapHandler *m_tapHandler; |
77 | QQuickPinchHandler *m_pinchHandler; |
78 | QQuickWheelHandler *m_wheelHandler; |
79 | QQuickDragHandler *m_dragHandler; |
80 | |
81 | QQuickGraphsItem *m_graphsItem; |
82 | }; |
83 | |
84 | QT_END_NAMESPACE |
85 | |
86 | #endif // QGRAPHSINPUTHANDLER_P_H |
87 | |