diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2016-01-18 15:45:06 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-01-18 16:05:44 +0000 |
commit | ce8e5ed4a6b2c4b1e1b26a33b74e92c3edc8bfd1 (patch) | |
tree | 9ea71fe157c6fd3df7034387f8e8e8f31dc98d0a /examples/qt3d/examples-common/qt3dquickwindow.h | |
parent | e2fddf5f24b2c23c8188a3508e75e32db7f9ca57 (diff) |
Allow for window to manage camera aspect ratio
Change-Id: I465811b8cce6b26614493f844829f9e1f0b1f3c9
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/qt3d/examples-common/qt3dquickwindow.h')
-rw-r--r-- | examples/qt3d/examples-common/qt3dquickwindow.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/qt3d/examples-common/qt3dquickwindow.h b/examples/qt3d/examples-common/qt3dquickwindow.h index 9991a85e5..919ab7fd4 100644 --- a/examples/qt3d/examples-common/qt3dquickwindow.h +++ b/examples/qt3d/examples-common/qt3dquickwindow.h @@ -38,6 +38,7 @@ #define QT3DQUICKWINDOW_H #include <QQuickWindow> +#include <QtCore/qpointer.h> #include <QUrl> QT_BEGIN_NAMESPACE @@ -51,6 +52,7 @@ class QQmlAspectEngine; namespace Qt3DRender { class QRenderAspect; +class QCamera; } namespace Qt3DInput { @@ -64,6 +66,8 @@ class QLogicAspect; class Qt3DQuickWindow : public QQuickWindow { Q_OBJECT + Q_PROPERTY(CameraAspectRatioMode cameraAspectRatioMode READ cameraAspectRatioMode WRITE setCameraAspectRatioMode NOTIFY cameraAspectRatioModeChanged) + public: Qt3DQuickWindow(QWindow *parent = Q_NULLPTR); ~Qt3DQuickWindow(); @@ -74,11 +78,26 @@ public: void setSource(const QUrl &source); Qt3DCore::Quick::QQmlAspectEngine *engine() const; + enum CameraAspectRatioMode { + AutomaticAspectRatio, + UserAspectRatio + }; + Q_ENUM(CameraAspectRatioMode); + + void setCameraAspectRatioMode(CameraAspectRatioMode mode); + CameraAspectRatioMode cameraAspectRatioMode() const; + +Q_SIGNALS: + void cameraAspectRatioModeChanged(CameraAspectRatioMode mode); + protected: void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; private: void onSceneCreated(QObject *rootObject); + void setWindowSurface(QObject *rootObject); + void setCameraAspectModeHelper(); + void updateCameraAspectRatio(); QScopedPointer<Qt3DCore::Quick::QQmlAspectEngine> m_engine; @@ -89,6 +108,8 @@ private: QUrl m_source; bool m_initialized; + QPointer<Qt3DRender::QCamera> m_camera; + CameraAspectRatioMode m_cameraAspectRatioMode; }; QT_END_NAMESPACE |