| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICK3DXRITEM_P_H |
| 5 | #define QQUICK3DXRITEM_P_H |
| 6 | |
| 7 | #include <QQuickItem> |
| 8 | #include <QtQuick3D/private/qquick3dnode_p.h> |
| 9 | |
| 10 | #include <QtQuick/private/qquicktranslate_p.h> |
| 11 | |
| 12 | // |
| 13 | // W A R N I N G |
| 14 | // ------------- |
| 15 | // |
| 16 | // This file is not part of the Qt API. It exists purely as an |
| 17 | // implementation detail. This header file may change from version to |
| 18 | // version without notice, or even be removed. |
| 19 | // |
| 20 | // We mean it. |
| 21 | // |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQuick3DXrItemPrivate; |
| 26 | class QQuick3DXrView; |
| 27 | |
| 28 | class QQuick3DXrItem : public QQuick3DNode |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_DECLARE_PRIVATE(QQuick3DXrItem) |
| 32 | |
| 33 | Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) |
| 34 | Q_PROPERTY(qreal pixelsPerUnit READ pixelsPerUnit WRITE setPixelsPerUnit NOTIFY pixelsPerUnitChanged FINAL) |
| 35 | Q_PROPERTY(bool manualPixelsPerUnit READ manualPixelsPerUnit WRITE setManualPixelsPerUnit NOTIFY manualPixelsPerUnitChanged FINAL) |
| 36 | Q_PROPERTY(bool automaticHeight READ automaticHeight WRITE setAutomaticHeight NOTIFY automaticHeightChanged FINAL) |
| 37 | Q_PROPERTY(bool automaticWidth READ automaticWidth WRITE setAutomaticWidth NOTIFY automaticWidthChanged FINAL) |
| 38 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) |
| 39 | Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) |
| 40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) |
| 41 | |
| 42 | QML_NAMED_ELEMENT(XrItem) |
| 43 | QML_ADDED_IN_VERSION(6, 8) |
| 44 | public: |
| 45 | struct TouchState |
| 46 | { |
| 47 | int pointId = -1; |
| 48 | QQuick3DXrItem *target = nullptr; |
| 49 | bool grabbed = false; |
| 50 | bool pressed = false; |
| 51 | qreal touchDistance = 1e6; |
| 52 | QPointF cursorPos; |
| 53 | QVector3D previous; |
| 54 | qint64 timestamp; |
| 55 | }; |
| 56 | |
| 57 | explicit QQuick3DXrItem(QQuick3DNode *parent = nullptr); |
| 58 | ~QQuick3DXrItem() override; |
| 59 | |
| 60 | QQuickItem *contentItem() const; |
| 61 | void setContentItem(QQuickItem *newContentItem); |
| 62 | |
| 63 | qreal pixelsPerUnit() const; |
| 64 | void setPixelsPerUnit(qreal newPixelsPerUnit); |
| 65 | |
| 66 | bool manualPixelsPerUnit() const; |
| 67 | void setManualPixelsPerUnit(bool newManualPixelsPerUnit); |
| 68 | |
| 69 | qreal width() const; |
| 70 | void setWidth(qreal newWidth); |
| 71 | |
| 72 | qreal height() const; |
| 73 | void setHeight(qreal newHeight); |
| 74 | |
| 75 | QColor color() const; |
| 76 | void setColor(const QColor &newColor); |
| 77 | |
| 78 | bool automaticHeight() const; |
| 79 | void setAutomaticHeight(bool newAutomaticHeight); |
| 80 | |
| 81 | bool automaticWidth() const; |
| 82 | void setAutomaticWidth(bool newAutomaticHeight); |
| 83 | |
| 84 | void componentComplete() override; |
| 85 | |
| 86 | bool handleVirtualTouch(QQuick3DXrView *view, const QVector3D &pos, TouchState *touchState, QVector3D *offset); |
| 87 | |
| 88 | signals: |
| 89 | void contentItemChanged(); |
| 90 | void pixelsPerUnitChanged(); |
| 91 | void flagsChanged(); |
| 92 | void manualPixelsPerUnitChanged(); |
| 93 | void widthChanged(); |
| 94 | void heightChanged(); |
| 95 | void colorChanged(); |
| 96 | void automaticHeightChanged(); |
| 97 | void automaticWidthChanged(); |
| 98 | }; |
| 99 | |
| 100 | QT_END_NAMESPACE |
| 101 | |
| 102 | #endif // QQUICK3DXRITEM_P_H |
| 103 |
