123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #ifndef CRYINCLUDE_EDITOR_VIEWPANE_H
- #define CRYINCLUDE_EDITOR_VIEWPANE_H
- #pragma once
- // ViewPane.h : header file
- //
- #if !defined(Q_MOC_RUN)
- #include "ViewportTitleDlg.h"
- #include <AzCore/Component/Component.h>
- #include <AzToolsFramework/ActionManager/ActionManagerRegistrationNotificationBus.h>
- #include <AzQtComponents/Components/ToolBarArea.h>
- #include <Include/SandboxAPI.h>
- #endif
- class CViewport;
- class QScrollArea;
- class QToolBar;
- class ViewportTitleExpanderWatcher;
- namespace AzToolsFramework
- {
- class ActionManagerInterface;
- class MenuManagerInterface;
- class ToolBarManagerInterface;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CViewPane view
- class CLayoutViewPane
- : public AzQtComponents::ToolBarArea
- , private AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler
- {
- Q_OBJECT
- public:
- CLayoutViewPane(QWidget* parent = nullptr);
- virtual ~CLayoutViewPane();
- // Operations
- public:
- // ActionManagerRegistrationNotificationBus overrides ...
- void OnMenuRegistrationHook() override;
- void OnToolBarRegistrationHook() override;
- void OnActionRegistrationHook() override;
- void OnMenuBindingHook() override;
- void OnToolBarBindingHook() override;
- // Set get this pane id.
- void SetId(int id) { m_id = id; }
- int GetId() { return m_id; }
- void SetViewClass(const QString& sClass);
- QString GetViewClass() const;
- //! Assign viewport to this pane.
- void SwapViewports(CLayoutViewPane* pView);
- void AttachViewport(QWidget* pViewport);
- //! Detach viewport from this pane.
- void DetachViewport();
- // Releases and destroy attached viewport.
- void ReleaseViewport();
- void SetFullscren(bool f);
- bool IsFullscreen() const { return m_bFullscreen; }
- QWidget* GetViewport() { return m_viewport; }
- //////////////////////////////////////////////////////////////////////////
- bool IsActiveView() const { return m_active; }
- void ShowTitleMenu();
- void ToggleMaximize();
- void SetFocusToViewport();
- void ResizeViewport(int width, int height);
- void SetAspectRatio(unsigned int x, unsigned int y);
- void SetViewportFOV(float fovDegrees);
- void OnFOVChanged(float fovRadians);
- enum class ViewportExpansionPolicy
- {
- AutoExpand,
- FixedSize
- };
- ViewportExpansionPolicy GetViewportExpansionPolicy() { return m_viewportPolicy; }
- //! Determine whether the viewport will be a fixed-size (scrollable if necessary)
- //! independent of the main window size, or auto-expanding based directly on the main window size.
- void SetViewportExpansionPolicy(ViewportExpansionPolicy policy);
- protected:
- void OnMenuLayoutConfig();
- void OnMenuViewSelected(const QString& paneName);
- void OnMenuMaximized();
- void mouseDoubleClickEvent(QMouseEvent* event) override;
- void OnDestroy();
- void focusInEvent(QFocusEvent* event) override;
- void DisconnectRenderViewportInteractionRequestBus();
- private:
- static constexpr int MIN_VIEWPORT_RES = 64;
- static constexpr int MAX_VIEWPORT_RES = 8192;
- static constexpr int MAX_CLASSVIEWS = 100;
- static constexpr int VIEW_BORDER = 0;
- enum TitleMenuCommonCommands
- {
- ID_MAXIMIZED = 50000,
- ID_LAYOUT_CONFIG,
- FIRST_ID_CLASSVIEW,
- LAST_ID_CLASSVIEW = FIRST_ID_CLASSVIEW + MAX_CLASSVIEWS - 1
- };
- QString m_viewPaneClass;
- bool m_bFullscreen;
- CViewportTitleDlg* m_viewportTitleDlg;
- int m_id;
- int m_nBorder;
- QWidget* m_viewport;
- QScrollArea* m_viewportScrollArea = nullptr;
- ViewportExpansionPolicy m_viewportPolicy = ViewportExpansionPolicy::AutoExpand;
- bool m_active;
- AzToolsFramework::ActionManagerInterface* m_actionManagerInterface = nullptr;
- AzToolsFramework::MenuManagerInterface* m_menuManagerInterface = nullptr;
- AzToolsFramework::ToolBarManagerInterface* m_toolBarManagerInterface = nullptr;
- };
- /////////////////////////////////////////////////////////////////////////////
- namespace AzToolsFramework
- {
- //! A component to reflect scriptable commands for the Editor
- class ViewPanePythonFuncsHandler
- : public AZ::Component
- {
- public:
- AZ_COMPONENT(ViewPanePythonFuncsHandler, "{25C99C8F-4440-4656-ABC4-32134F496CC1}")
- SANDBOX_API static void Reflect(AZ::ReflectContext* context);
- // AZ::Component ...
- void Activate() override {}
- void Deactivate() override {}
- };
- } // namespace AzToolsFramework
- #endif // CRYINCLUDE_EDITOR_VIEWPANE_H
|