Prefab Focus Mode | Fixes to viewport top toolbar (#7094)
* Fixes to the viewport top toolbar. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Additional checks to prevent issues if widgets aren't set up correctly. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Add asserts to catch UI changes that would break this class. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
+17
-20
@@ -87,29 +87,15 @@ public:
|
||||
}
|
||||
|
||||
// Handle labels with submenus
|
||||
if (auto toolLabel = qobject_cast<QLabel*>(toolWidget))
|
||||
if (auto toolLabel = qobject_cast<QToolButton*>(toolWidget))
|
||||
{
|
||||
if (!toolLabel->isVisible())
|
||||
{
|
||||
// Manually turn the custom context menus into submenus
|
||||
if (toolLabel->objectName() == "m_fovStaticCtrl")
|
||||
if (toolLabel->menu())
|
||||
{
|
||||
QAction* newAction = menu->addMenu(m_viewportDlg->GetFovMenu());
|
||||
newAction->setText(QString("FOV: %1").arg(toolLabel->text()));
|
||||
}
|
||||
else if (toolLabel->objectName() == "m_ratioStaticCtrl")
|
||||
{
|
||||
QAction* newAction = menu->addMenu(m_viewportDlg->GetAspectMenu());
|
||||
newAction->setText(QString("Ratio: %1").arg(toolLabel->text()));
|
||||
}
|
||||
else if (toolLabel->objectName() == "m_sizeStaticCtrl")
|
||||
{
|
||||
QAction* newAction = menu->addMenu(m_viewportDlg->GetResolutionMenu());
|
||||
newAction->setText(QString("%1").arg(toolLabel->text()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't add actions for other Labels
|
||||
QAction* action = menu->addMenu(toolLabel->menu());
|
||||
action->setText(toolLabel->text());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -179,14 +165,25 @@ CLayoutViewPane::CLayoutViewPane(QWidget* parent)
|
||||
toolbar->installEventFilter(&m_viewportTitleDlg);
|
||||
toolbar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(toolbar, &QWidget::customContextMenuRequested, &m_viewportTitleDlg, &QWidget::customContextMenuRequested);
|
||||
|
||||
setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
|
||||
if (QToolButton* expansion = AzQtComponents::ToolBar::getToolBarExpansionButton(toolbar))
|
||||
{
|
||||
expansion->installEventFilter(m_expanderWatcher);
|
||||
}
|
||||
|
||||
AzQtComponents::BreadCrumbs* prefabsBreadcrumbs =
|
||||
qobject_cast<AzQtComponents::BreadCrumbs*>(toolbar->findChild<QWidget*>("m_prefabFocusPath"));
|
||||
QToolButton* backButton = qobject_cast<QToolButton*>(toolbar->findChild<QWidget*>("m_prefabFocusBackButton"));
|
||||
|
||||
AZ_Assert(prefabsBreadcrumbs, "Could not find Prefabs Breadcrumbs widget on CLayoutViewPane initialization!");
|
||||
AZ_Assert(backButton, "Could not find Prefabs Breadcrumbs back button on CLayoutViewPane initialization!");
|
||||
|
||||
if (prefabsBreadcrumbs && backButton)
|
||||
{
|
||||
m_viewportTitleDlg.InitializePrefabViewportFocusPathHandler(prefabsBreadcrumbs, backButton);
|
||||
}
|
||||
|
||||
m_id = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,12 +383,7 @@ void CViewportTitleDlg::OnInitDialog()
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
if (isPrefabSystemEnabled)
|
||||
{
|
||||
m_prefabViewportFocusPathHandler = new AzToolsFramework::Prefab::PrefabViewportFocusPathHandler();
|
||||
m_prefabViewportFocusPathHandler->Initialize(m_ui->m_prefabFocusPath, m_ui->m_prefabFocusBackButton);
|
||||
}
|
||||
else
|
||||
if (!isPrefabSystemEnabled)
|
||||
{
|
||||
m_ui->m_prefabFocusPath->setEnabled(false);
|
||||
m_ui->m_prefabFocusBackButton->setEnabled(false);
|
||||
@@ -397,6 +392,23 @@ void CViewportTitleDlg::OnInitDialog()
|
||||
}
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::InitializePrefabViewportFocusPathHandler(AzQtComponents::BreadCrumbs* breadcrumbsWidget, QToolButton* backButton)
|
||||
{
|
||||
if (m_prefabViewportFocusPathHandler != nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
if (isPrefabSystemEnabled)
|
||||
{
|
||||
m_prefabViewportFocusPathHandler = new AzToolsFramework::Prefab::PrefabViewportFocusPathHandler();
|
||||
m_prefabViewportFocusPathHandler->Initialize(breadcrumbsWidget, backButton);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SetTitle(const QString& title)
|
||||
{
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
QMenu* const GetAspectMenu();
|
||||
QMenu* const GetResolutionMenu();
|
||||
|
||||
void InitializePrefabViewportFocusPathHandler(AzQtComponents::BreadCrumbs* breadcrumbsWidget, QToolButton* backButton);
|
||||
|
||||
Q_SIGNALS:
|
||||
void ActionTriggered(int command);
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@
|
||||
<property name="toolTip">
|
||||
<string>Camera settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera settings</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Menu/camera.svg</normaloff>:/Menu/camera.svg</iconset>
|
||||
@@ -91,6 +94,9 @@
|
||||
<property name="toolTip">
|
||||
<string>Debug information</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Debug information</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Menu/debug.svg</normaloff>:/Menu/debug.svg</iconset>
|
||||
@@ -105,6 +111,9 @@
|
||||
<property name="toolTip">
|
||||
<string>Toggle viewport helpers</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toggle viewport helpers</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Menu/helpers.svg</normaloff>:/Menu/helpers.svg</iconset>
|
||||
@@ -119,6 +128,9 @@
|
||||
<property name="toolTip">
|
||||
<string>Viewport resolution</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Viewport resolution</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Menu/resolution.svg</normaloff>:/Menu/resolution.svg</iconset>
|
||||
@@ -130,6 +142,9 @@
|
||||
<property name="toolTip">
|
||||
<string>Other settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Other settings</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Menu/menu.svg</normaloff>:/Menu/menu.svg</iconset>
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace AzQtComponents
|
||||
{
|
||||
if (QWidget* widget = item->widget())
|
||||
{
|
||||
toolbar->addWidget(widget);
|
||||
QAction* action = toolbar->addWidget(widget);
|
||||
action->setObjectName(widget->objectName());
|
||||
}
|
||||
else if (item->spacerItem())
|
||||
{
|
||||
|
||||
+3
@@ -73,6 +73,9 @@ namespace AzToolsFramework::Prefab
|
||||
{
|
||||
// Push new Path
|
||||
m_breadcrumbsWidget->pushPath(m_prefabFocusPublicInterface->GetPrefabFocusPath(m_editorEntityContextId).c_str());
|
||||
|
||||
// If root instance is focused, disable the back button; else enable it.
|
||||
m_backButton->setEnabled(m_prefabFocusPublicInterface->GetPrefabFocusPathLength(m_editorEntityContextId) > 1);
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework::Prefab
|
||||
|
||||
Reference in New Issue
Block a user