LayoutWnd.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef CRYINCLUDE_EDITOR_LAYOUTWND_H
  9. #define CRYINCLUDE_EDITOR_LAYOUTWND_H
  10. #pragma once
  11. // LayoutWnd.h : header file
  12. //
  13. #if !defined(Q_MOC_RUN)
  14. #include "Viewport.h"
  15. #include <QSplitter>
  16. #include <QPointer>
  17. #include <AzQtComponents/Components/ToolBarArea.h>
  18. #endif
  19. class CLayoutViewPane;
  20. class CViewport;
  21. class QSettings;
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CLayoutWnd window
  24. enum EViewLayout
  25. {
  26. ET_Layout0,
  27. ET_Layout1,
  28. ET_Layout2,
  29. ET_Layout3,
  30. ET_Layout4,
  31. ET_Layout5,
  32. ET_Layout6,
  33. ET_Layout7,
  34. ET_Layout8
  35. };
  36. #define MAX_VIEWPORTS 9
  37. /** Window used as splitter window in Layout.
  38. */
  39. class CLayoutSplitter
  40. : public QSplitter
  41. {
  42. Q_OBJECT
  43. public:
  44. CLayoutSplitter(QWidget* parent = nullptr);
  45. // Implementation
  46. public:
  47. virtual ~CLayoutSplitter();
  48. void otherSplitterMoved(int pos, int index) { const QSignalBlocker sb(this); QSplitter::moveSplitter(pos, index); }
  49. // Generated message map functions
  50. protected:
  51. void resizeEvent(QResizeEvent* event) override;
  52. void CreateLayoutView(int row, int col, int id);
  53. QSplitterHandle* createHandle() override;
  54. private:
  55. friend class CLayoutWnd;
  56. };
  57. /** Main layout window.
  58. */
  59. class CLayoutWnd
  60. : public AzQtComponents::ToolBarArea
  61. {
  62. // Construction
  63. Q_OBJECT
  64. public:
  65. CLayoutWnd(QSettings* settings, QWidget* parent = nullptr);
  66. // Attributes
  67. public:
  68. CLayoutViewPane* GetViewPane(int id);
  69. CLayoutViewPane* GetViewPaneByIndex(unsigned int index);
  70. unsigned int GetViewPaneCount();
  71. //! Maximize viewport with specified type.
  72. void MaximizeViewport(int paneId);
  73. //! Create specific layout.
  74. void CreateLayout(EViewLayout layout, bool bBindViewports = true, EViewportType defaultView = ET_ViewportCamera);
  75. EViewLayout GetLayout() const { return m_layout; }
  76. //! Save layout window configuration to registry.
  77. void SaveConfig();
  78. //! Load layout window configuration from registry.
  79. bool LoadConfig();
  80. //! Get the config group name in the registry.
  81. static const char* GetConfigGroupName();
  82. CLayoutViewPane* FindViewByClass(const QString& viewClassName);
  83. void BindViewport(CLayoutViewPane* vp, const QString& viewClassName, QWidget* pViewport = nullptr);
  84. QString ViewportTypeToClassName(EViewportType viewType);
  85. //! Switch 2D viewports.
  86. void Cycle2DViewport();
  87. using AzQtComponents::ToolBarArea::SetMainWidget;
  88. public slots:
  89. void ResetLayout();
  90. public:
  91. virtual ~CLayoutWnd();
  92. // Generated message map functions
  93. protected:
  94. void OnDestroy();
  95. // Bind viewports to split panes.
  96. void BindViewports();
  97. void UnbindViewports();
  98. void CreateLayoutView(CLayoutSplitter* wndSplitter, int row, int col, int id, EViewportType viewType);
  99. bool CycleViewport(EViewportType from, EViewportType to);
  100. private slots:
  101. void OnFocusChanged(QWidget* oldWidget, QWidget* newWidget);
  102. private:
  103. void FocusFirstLayoutViewPane(CLayoutSplitter*);
  104. void MoveViewport(CLayoutViewPane* from, CLayoutViewPane* to, const QString& viewClassName);
  105. bool m_bMaximized;
  106. //! What view type is current maximized.
  107. EViewLayout m_layout;
  108. // ViewPane id to viewport type
  109. QString m_viewType[MAX_VIEWPORTS];
  110. //! Primary split window.
  111. QPointer<CLayoutSplitter> m_splitWnd;
  112. //! Secondary split window.
  113. QPointer<CLayoutSplitter> m_splitWnd2;
  114. //! Tertiary split window.
  115. QPointer<CLayoutSplitter> m_splitWnd3;
  116. //! View pane for maximized layout.
  117. QPointer<CLayoutViewPane> m_maximizedView;
  118. // Id of maximized view pane.
  119. int m_maximizedViewId;
  120. QSettings* m_settings;
  121. };
  122. /////////////////////////////////////////////////////////////////////////////
  123. #endif // CRYINCLUDE_EDITOR_LAYOUTWND_H