CreateMenu/CreateTabBar
Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
+2
-4
@@ -38,9 +38,9 @@ namespace AtomToolsFramework
|
||||
bool IsDockWidgetVisible(const AZStd::string& name) const override;
|
||||
AZStd::vector<AZStd::string> GetDockWidgetNames() const override;
|
||||
|
||||
virtual void SetupMenu();
|
||||
virtual void CreateMenu();
|
||||
|
||||
virtual void SetupTabs();
|
||||
virtual void CreateTabBar();
|
||||
virtual void AddTabForDocumentId(const AZ::Uuid& documentId);
|
||||
virtual void RemoveTabForDocumentId(const AZ::Uuid& documentId);
|
||||
virtual void UpdateTabForDocumentId(const AZ::Uuid& documentId);
|
||||
@@ -57,7 +57,5 @@ namespace AtomToolsFramework
|
||||
QStatusBar* m_statusBar = nullptr;
|
||||
|
||||
AZStd::unordered_map<AZStd::string, AzQtComponents::StyledDockWidget*> m_dockWidgets;
|
||||
|
||||
QMenu* m_menuFile = {};
|
||||
};
|
||||
} // namespace AtomToolsFramework
|
||||
|
||||
@@ -21,16 +21,6 @@ namespace AtomToolsFramework
|
||||
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||
|
||||
m_menuBar = new QMenuBar(this);
|
||||
m_menuBar->setObjectName("MenuBar");
|
||||
setMenuBar(m_menuBar);
|
||||
|
||||
m_centralWidget = new QWidget(this);
|
||||
m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget);
|
||||
m_tabWidget->setObjectName("TabWidget");
|
||||
m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
||||
m_tabWidget->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_statusBar = new QStatusBar(this);
|
||||
m_statusBar->setObjectName("StatusBar");
|
||||
statusBar()->addPermanentWidget(m_statusBar, 1);
|
||||
@@ -110,26 +100,20 @@ namespace AtomToolsFramework
|
||||
return names;
|
||||
}
|
||||
|
||||
void AtomToolsMainWindow::SetupMenu()
|
||||
void AtomToolsMainWindow::CreateMenu()
|
||||
{
|
||||
// Generating the main menu manually because it's easier and we will have some dynamic or data driven entries
|
||||
m_menuFile = m_menuBar->addMenu("&File");
|
||||
m_menuBar = new QMenuBar(this);
|
||||
m_menuBar->setObjectName("MenuBar");
|
||||
setMenuBar(m_menuBar);
|
||||
}
|
||||
|
||||
void AtomToolsMainWindow::SetupTabs()
|
||||
void AtomToolsMainWindow::CreateTabBar()
|
||||
{
|
||||
// The tab bar should only be visible if it has active documents
|
||||
m_tabWidget->setVisible(false);
|
||||
m_tabWidget->setTabBarAutoHide(false);
|
||||
m_tabWidget->setMovable(true);
|
||||
m_tabWidget->setTabsClosable(true);
|
||||
m_tabWidget->setUsesScrollButtons(true);
|
||||
|
||||
// Add context menu for right-clicking on tabs
|
||||
m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
||||
connect(m_tabWidget, &QWidget::customContextMenuRequested, this, [this]() {
|
||||
OpenTabContextMenu();
|
||||
});
|
||||
m_centralWidget = new QWidget(this);
|
||||
m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget);
|
||||
m_tabWidget->setObjectName("TabWidget");
|
||||
m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
||||
m_tabWidget->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void AtomToolsMainWindow::AddTabForDocumentId(const AZ::Uuid& documentId)
|
||||
|
||||
@@ -93,6 +93,9 @@ namespace MaterialEditor
|
||||
m_materialViewport->setObjectName("Viewport");
|
||||
m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
CreateMenu();
|
||||
CreateTabBar();
|
||||
|
||||
QVBoxLayout* vl = new QVBoxLayout(m_centralWidget);
|
||||
vl->setMargin(0);
|
||||
vl->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -101,9 +104,6 @@ namespace MaterialEditor
|
||||
m_centralWidget->setLayout(vl);
|
||||
setCentralWidget(m_centralWidget);
|
||||
|
||||
SetupMenu();
|
||||
SetupTabs();
|
||||
|
||||
AddDockWidget("Asset Browser", new MaterialBrowserWidget, Qt::BottomDockWidgetArea, Qt::Vertical);
|
||||
AddDockWidget("Inspector", new MaterialInspector, Qt::RightDockWidgetArea, Qt::Horizontal);
|
||||
AddDockWidget("Viewport Settings", new ViewportSettingsInspector, Qt::LeftDockWidgetArea, Qt::Horizontal);
|
||||
@@ -283,9 +283,12 @@ namespace MaterialEditor
|
||||
m_statusBar->setWindowIconText(QString("<font color=\"White\">%1</font>").arg(status));
|
||||
}
|
||||
|
||||
void MaterialEditorWindow::SetupMenu()
|
||||
void MaterialEditorWindow::CreateMenu()
|
||||
{
|
||||
Base::SetupMenu();
|
||||
Base::CreateMenu();
|
||||
|
||||
// Generating the main menu manually because it's easier and we will have some dynamic or data driven entries
|
||||
m_menuFile = m_menuBar->addMenu("&File");
|
||||
|
||||
m_actionNew = m_menuFile->addAction("&New...", [this]() {
|
||||
CreateMaterialDialog createDialog(this);
|
||||
@@ -481,9 +484,22 @@ namespace MaterialEditor
|
||||
});
|
||||
}
|
||||
|
||||
void MaterialEditorWindow::SetupTabs()
|
||||
void MaterialEditorWindow::CreateTabBar()
|
||||
{
|
||||
Base::SetupTabs();
|
||||
Base::CreateTabBar();
|
||||
|
||||
// The tab bar should only be visible if it has active documents
|
||||
m_tabWidget->setVisible(false);
|
||||
m_tabWidget->setTabBarAutoHide(false);
|
||||
m_tabWidget->setMovable(true);
|
||||
m_tabWidget->setTabsClosable(true);
|
||||
m_tabWidget->setUsesScrollButtons(true);
|
||||
|
||||
// Add context menu for right-clicking on tabs
|
||||
m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
||||
connect(m_tabWidget, &QWidget::customContextMenuRequested, this, [this]() {
|
||||
OpenTabContextMenu();
|
||||
});
|
||||
|
||||
// This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged
|
||||
// When the last tab is removed tabIndex will be -1 and the document ID will be null
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace MaterialEditor
|
||||
void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentSaved(const AZ::Uuid& documentId) override;
|
||||
|
||||
void SetupMenu() override;
|
||||
void CreateMenu() override;
|
||||
|
||||
void SetupTabs() override;
|
||||
void CreateTabBar() override;
|
||||
void AddTabForDocumentId(const AZ::Uuid& documentId) override;
|
||||
void UpdateTabForDocumentId(const AZ::Uuid& documentId) override;
|
||||
QString GetDocumentPath(const AZ::Uuid& documentId) const;
|
||||
@@ -82,6 +82,7 @@ namespace MaterialEditor
|
||||
MaterialViewportWidget* m_materialViewport = nullptr;
|
||||
MaterialEditorToolBar* m_toolBar = nullptr;
|
||||
|
||||
QMenu* m_menuFile = {};
|
||||
QAction* m_actionNew = {};
|
||||
QAction* m_actionOpen = {};
|
||||
QAction* m_actionOpenRecent = {};
|
||||
|
||||
+23
-7
@@ -49,6 +49,9 @@ namespace ShaderManagementConsole
|
||||
m_toolBar->setObjectName("ToolBar");
|
||||
addToolBar(m_toolBar);
|
||||
|
||||
CreateMenu();
|
||||
CreateTabBar();
|
||||
|
||||
QVBoxLayout* vl = new QVBoxLayout(m_centralWidget);
|
||||
vl->setMargin(0);
|
||||
vl->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -56,9 +59,6 @@ namespace ShaderManagementConsole
|
||||
m_centralWidget->setLayout(vl);
|
||||
setCentralWidget(m_centralWidget);
|
||||
|
||||
SetupMenu();
|
||||
SetupTabs();
|
||||
|
||||
AddDockWidget("Asset Browser", new ShaderManagementConsoleBrowserWidget, Qt::BottomDockWidgetArea, Qt::Vertical);
|
||||
AddDockWidget("Python Terminal", new AzToolsFramework::CScriptTermDialog, Qt::BottomDockWidgetArea, Qt::Horizontal);
|
||||
|
||||
@@ -159,9 +159,12 @@ namespace ShaderManagementConsole
|
||||
UpdateTabForDocumentId(documentId);
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindow::SetupMenu()
|
||||
void ShaderManagementConsoleWindow::CreateMenu()
|
||||
{
|
||||
Base::SetupMenu();
|
||||
Base::CreateMenu();
|
||||
|
||||
// Generating the main menu manually because it's easier and we will have some dynamic or data driven entries
|
||||
m_menuFile = m_menuBar->addMenu("&File");
|
||||
|
||||
m_actionOpen = m_menuFile->addAction("&Open...", [this]() {
|
||||
const AZStd::vector<AZ::Data::AssetType> assetTypes = {
|
||||
@@ -277,9 +280,22 @@ namespace ShaderManagementConsole
|
||||
});
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindow::SetupTabs()
|
||||
void ShaderManagementConsoleWindow::CreateTabBar()
|
||||
{
|
||||
Base::SetupTabs();
|
||||
Base::CreateTabBar();
|
||||
|
||||
// The tab bar should only be visible if it has active documents
|
||||
m_tabWidget->setVisible(false);
|
||||
m_tabWidget->setTabBarAutoHide(false);
|
||||
m_tabWidget->setMovable(true);
|
||||
m_tabWidget->setTabsClosable(true);
|
||||
m_tabWidget->setUsesScrollButtons(true);
|
||||
|
||||
// Add context menu for right-clicking on tabs
|
||||
m_tabWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
||||
connect(m_tabWidget, &QWidget::customContextMenuRequested, this, [this]() {
|
||||
OpenTabContextMenu();
|
||||
});
|
||||
|
||||
// This signal will be triggered whenever a tab is added, removed, selected, clicked, dragged
|
||||
// When the last tab is removed tabIndex will be -1 and the document ID will be null
|
||||
|
||||
+3
-2
@@ -63,9 +63,9 @@ namespace ShaderManagementConsole
|
||||
void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentSaved(const AZ::Uuid& documentId) override;
|
||||
|
||||
void SetupMenu() override;
|
||||
void CreateMenu() override;
|
||||
|
||||
void SetupTabs() override;
|
||||
void CreateTabBar() override;
|
||||
void AddTabForDocumentId(const AZ::Uuid& documentId) override;
|
||||
void UpdateTabForDocumentId(const AZ::Uuid& documentId) override;
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace ShaderManagementConsole
|
||||
|
||||
ShaderManagementConsoleToolBar* m_toolBar = nullptr;
|
||||
|
||||
QMenu* m_menuFile = {};
|
||||
QMenu* m_menuNew = {};
|
||||
QAction* m_actionOpen = {};
|
||||
QAction* m_actionOpenRecent = {};
|
||||
|
||||
Reference in New Issue
Block a user