Initial improvements to fix viewport icon selection and draw order (#6284)

* wip fixes for entity viewport icons displaying in the correct order and handling selection correctly

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add additional comment about z value

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* move manual sorting and some small tidy-up

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update comment

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* updates following initial round of PR feedback

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* additional changes to support tests for entity icon intersection

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add support to enable/disable icons separately from helpers

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* final tests added and small tidy-up to display EntityId correctly

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update some manipulator test framework calls after utility functions were moved

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* fix for implicit cast

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* move icon scale values to AZ_CVARS

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* fix failing tests caught in AR and update some naming conventions for tests

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update naming convention for members of ProjectedViewportRay

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update other references to ProjectedViewportRay

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update more references to ProjectedViewportRay change

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update menus for python tests

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
Tom Hulton-Harrop
2021-12-16 09:35:23 +00:00
committed by GitHub
parent df8326a1b0
commit d065eb9498
56 changed files with 783 additions and 449 deletions
+71 -52
View File
@@ -6,7 +6,6 @@
*
*/
// Description : CViewportTitleDlg implementation file
#if !defined(Q_MOC_RUN)
@@ -42,38 +41,18 @@
#include <AzCore/std/algorithm.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <AzToolsFramework/Viewport/ViewportSettings.h>
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include "ui_ViewportTitleDlg.h"
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
#endif //!defined(Q_MOC_RUN)
#endif //! defined(Q_MOC_RUN)
// CViewportTitleDlg dialog
inline namespace Helpers
{
void ToggleHelpers()
{
const bool newValue = !GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
GetIEditor()->GetDisplaySettings()->DisplayHelpers(newValue);
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
if (newValue == false)
{
GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER);
}
AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast(
&AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged, newValue);
}
bool IsHelpersShown()
{
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
}
}
namespace
{
class CViewportTitleDlgDisplayInfoHelper
@@ -98,7 +77,7 @@ namespace
emit ViewportInfoStatusUpdated(static_cast<int>(state));
}
};
} //end anonymous namespace
} // end anonymous namespace
CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
: QWidget(pParent)
@@ -215,13 +194,65 @@ void CViewportTitleDlg::SetupViewportInformationMenu()
m_ui->m_debugInformationMenu->setMenu(GetViewportInformationMenu());
connect(m_ui->m_debugInformationMenu, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleDisplayInfo);
m_ui->m_debugInformationMenu->setPopupMode(QToolButton::MenuButtonPopup);
}
void CViewportTitleDlg::SetupHelpersButton()
{
connect(m_ui->m_helpers, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleHelpers);
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
if (m_helpersMenu == nullptr)
{
m_helpersMenu = new QMenu("Helpers State", this);
auto helperAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Helpers);
connect(
helperAction, &QAction::triggered, this,
[this]
{
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
});
auto iconAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Icons);
connect(
iconAction, &QAction::triggered, this,
[this]
{
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
});
m_helpersAction = new QAction(tr("Helpers"), m_helpersMenu);
m_helpersAction->setCheckable(true);
connect(
m_helpersAction, &QAction::triggered, this,
[helperAction]
{
helperAction->trigger();
});
m_iconsAction = new QAction(tr("Icons"), m_helpersMenu);
m_iconsAction->setCheckable(true);
connect(
m_iconsAction, &QAction::triggered, this,
[iconAction]
{
iconAction->trigger();
});
m_helpersMenu->addAction(m_helpersAction);
m_helpersMenu->addAction(m_iconsAction);
connect(
m_helpersMenu, &QMenu::aboutToShow, this,
[this]
{
m_helpersAction->setChecked(AzToolsFramework::HelpersVisible());
m_iconsAction->setChecked(AzToolsFramework::IconsVisible());
});
m_ui->m_helpers->setCheckable(true);
m_ui->m_helpers->setMenu(m_helpersMenu);
m_ui->m_helpers->setPopupMode(QToolButton::InstantPopup);
}
m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible());
}
void CViewportTitleDlg::SetupOverflowMenu()
@@ -279,15 +310,20 @@ void CViewportTitleDlg::SetupOverflowMenu()
UpdateMuteActionText();
}
//////////////////////////////////////////////////////////////////////////
void CViewportTitleDlg::SetViewPane(CLayoutViewPane* pViewPane)
{
if (m_pViewPane)
{
m_pViewPane->disconnect(this);
}
m_pViewPane = pViewPane;
if (m_pViewPane)
{
connect(this, &QWidget::customContextMenuRequested, m_pViewPane, &CLayoutViewPane::ShowTitleMenu);
}
}
//////////////////////////////////////////////////////////////////////////
@@ -318,7 +354,6 @@ void CViewportTitleDlg::OnInitDialog()
m_ui->m_prefabFocusPath->hide();
m_ui->m_prefabFocusBackButton->hide();
}
}
//////////////////////////////////////////////////////////////////////////
@@ -336,13 +371,6 @@ void CViewportTitleDlg::OnMaximize()
}
}
//////////////////////////////////////////////////////////////////////////
void CViewportTitleDlg::OnToggleHelpers()
{
Helpers::ToggleHelpers();
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
}
void CViewportTitleDlg::SetNoViewportInfo()
{
AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Broadcast(
@@ -367,7 +395,6 @@ void CViewportTitleDlg::SetCompactViewportInfo()
&AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Events::SetDisplayState, AZ::AtomBridge::ViewportInfoDisplayState::CompactInfo);
}
//////////////////////////////////////////////////////////////////////////
void CViewportTitleDlg::UpdateDisplayInfo()
{
@@ -783,9 +810,6 @@ void CViewportTitleDlg::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnDisplayRenderUpdate:
m_ui->m_helpers->setChecked(Helpers::IsHelpersShown());
break;
case eNotify_OnBeginGameMode:
case eNotify_OnEndGameMode:
UpdateMuteActionText();
@@ -997,24 +1021,18 @@ void CViewportTitleDlg::UpdateOverFlowMenuState()
m_angleSizeActionWidget->setEnabled(angleSnappingActive);
}
namespace
namespace
{
void PyToggleHelpers()
{
GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
if (GetIEditor()->GetDisplaySettings()->IsDisplayHelpers() == false)
{
GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER);
}
AzToolsFramework::SetHelpersVisible(!AzToolsFramework::HelpersVisible());
}
bool PyIsHelpersShown()
{
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
return AzToolsFramework::HelpersVisible();
}
}
} // namespace
namespace AzToolsFramework
{
@@ -1029,11 +1047,12 @@ namespace AzToolsFramework
->Attribute(AZ::Script::Attributes::Category, "Legacy/Editor")
->Attribute(AZ::Script::Attributes::Module, "legacy.general");
};
addLegacyGeneral(behaviorContext->Method("toggle_helpers", PyToggleHelpers, nullptr, "Toggles the display of helpers."));
addLegacyGeneral(behaviorContext->Method("is_helpers_shown", PyIsHelpersShown, nullptr, "Gets the display state of helpers."));
}
}
}
} // namespace AzToolsFramework
#include "ViewportTitleDlg.moc"
#include <moc_ViewportTitleDlg.cpp>