1 | // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
3 | |
4 | #ifndef QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H |
5 | #define QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H |
6 | |
7 | #include <Qt3DQuickExtras/qt3dquickextras_global.h> |
8 | #include <QtCore/QUrl> |
9 | #include <QtCore/qpointer.h> |
10 | #include <QtQuick/QQuickWindow> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QQmlIncubationController; |
15 | |
16 | namespace Qt3DCore { |
17 | class QAbstractAspect; |
18 | namespace Quick { |
19 | class QQmlAspectEngine; |
20 | } |
21 | } |
22 | |
23 | namespace Qt3DRender { |
24 | class QRenderAspect; |
25 | class QCamera; |
26 | } |
27 | |
28 | namespace Qt3DInput { |
29 | class QInputAspect; |
30 | } |
31 | |
32 | namespace Qt3DLogic { |
33 | class QLogicAspect; |
34 | } |
35 | |
36 | namespace Qt3DExtras { |
37 | |
38 | namespace Quick { |
39 | |
40 | class Qt3DQuickWindowPrivate; |
41 | |
42 | class Q_3DQUICKEXTRASSHARED_EXPORT Qt3DQuickWindow : public QWindow |
43 | { |
44 | Q_OBJECT |
45 | Q_PROPERTY(CameraAspectRatioMode cameraAspectRatioMode READ cameraAspectRatioMode WRITE setCameraAspectRatioMode NOTIFY cameraAspectRatioModeChanged) |
46 | |
47 | public: |
48 | explicit Qt3DQuickWindow(QWindow *parent = nullptr); |
49 | ~Qt3DQuickWindow(); |
50 | |
51 | void registerAspect(Qt3DCore::QAbstractAspect *aspect); |
52 | void registerAspect(const QString &name); |
53 | |
54 | void setSource(const QUrl &source); |
55 | Qt3DCore::Quick::QQmlAspectEngine *engine() const; |
56 | |
57 | enum CameraAspectRatioMode { |
58 | AutomaticAspectRatio, |
59 | UserAspectRatio |
60 | }; |
61 | Q_ENUM(CameraAspectRatioMode); // LCOV_EXCL_LINE |
62 | |
63 | void setCameraAspectRatioMode(CameraAspectRatioMode mode); |
64 | CameraAspectRatioMode cameraAspectRatioMode() const; |
65 | |
66 | Q_SIGNALS: |
67 | void cameraAspectRatioModeChanged(CameraAspectRatioMode mode); |
68 | |
69 | protected: |
70 | void showEvent(QShowEvent *e) override; |
71 | |
72 | private: |
73 | void onSceneCreated(QObject *rootObject); |
74 | void setWindowSurface(QObject *rootObject); |
75 | void setCameraAspectModeHelper(); |
76 | void updateCameraAspectRatio(); |
77 | |
78 | Q_DECLARE_PRIVATE(Qt3DQuickWindow) |
79 | }; |
80 | |
81 | } // Quick |
82 | |
83 | } // Qt3DExtras |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif // QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H |
88 |