|
@@ -12,6 +12,8 @@
|
|
|
|
|
|
#include "EditorDefs.h"
|
|
#include "EditorDefs.h"
|
|
|
|
|
|
|
|
+#include "CustomAspectRatioDlg.h"
|
|
|
|
+#include "CustomResolutionDlg.h"
|
|
#include "ViewPane.h"
|
|
#include "ViewPane.h"
|
|
|
|
|
|
// Qt
|
|
// Qt
|
|
@@ -57,10 +59,20 @@ static constexpr AZStd::string_view ViewportCameraMenuIdentifier = "o3de.menu.ed
|
|
static constexpr AZStd::string_view ViewportHelpersMenuIdentifier = "o3de.menu.editor.viewport.helpers";
|
|
static constexpr AZStd::string_view ViewportHelpersMenuIdentifier = "o3de.menu.editor.viewport.helpers";
|
|
static constexpr AZStd::string_view ViewportDebugInfoMenuIdentifier = "o3de.menu.editor.viewport.debugInfo";
|
|
static constexpr AZStd::string_view ViewportDebugInfoMenuIdentifier = "o3de.menu.editor.viewport.debugInfo";
|
|
static constexpr AZStd::string_view ViewportSizeMenuIdentifier = "o3de.menu.editor.viewport.size";
|
|
static constexpr AZStd::string_view ViewportSizeMenuIdentifier = "o3de.menu.editor.viewport.size";
|
|
|
|
+static constexpr AZStd::string_view ViewportSizeRatioMenuIdentifier = "o3de.menu.editor.viewport.size.ratio";
|
|
|
|
+static constexpr AZStd::string_view ViewportSizeResolutionMenuIdentifier = "o3de.menu.editor.viewport.size.resolution";
|
|
static constexpr AZStd::string_view ViewportOptionsMenuIdentifier = "o3de.menu.editor.viewport.options";
|
|
static constexpr AZStd::string_view ViewportOptionsMenuIdentifier = "o3de.menu.editor.viewport.options";
|
|
|
|
|
|
static constexpr AZStd::string_view ViewportTopToolBarIdentifier = "o3de.toolbar.viewport.top";
|
|
static constexpr AZStd::string_view ViewportTopToolBarIdentifier = "o3de.toolbar.viewport.top";
|
|
|
|
|
|
|
|
+static const std::pair<int, int> ViewportRatios[] = { { 16, 9 }, { 16, 10 }, { 4, 3 }, { 5, 4 } };
|
|
|
|
+static const size_t ViewportRatiosCount = sizeof(ViewportRatios) / sizeof(ViewportRatios[0]);
|
|
|
|
+static const std::pair<int, int> ViewportResolutions[] =
|
|
|
|
+ { { 1280, 720 }, { 1920, 1080 }, { 2560, 1440 }, { 2048, 858 }, { 1998, 1080 }, { 3480, 2160 } };
|
|
|
|
+static const size_t ViewportResolutionsCount = sizeof(ViewportResolutions) / sizeof(ViewportResolutions[0]);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// ViewportTitleExpanderWatcher
|
|
// ViewportTitleExpanderWatcher
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
@@ -262,6 +274,16 @@ void CLayoutViewPane::OnMenuRegistrationHook()
|
|
menuProperties.m_name = "Viewport Size";
|
|
menuProperties.m_name = "Viewport Size";
|
|
m_menuManagerInterface->RegisterMenu(ViewportSizeMenuIdentifier, menuProperties);
|
|
m_menuManagerInterface->RegisterMenu(ViewportSizeMenuIdentifier, menuProperties);
|
|
}
|
|
}
|
|
|
|
+ {
|
|
|
|
+ AzToolsFramework::MenuProperties menuProperties;
|
|
|
|
+ menuProperties.m_name = "Ratio";
|
|
|
|
+ m_menuManagerInterface->RegisterMenu(ViewportSizeRatioMenuIdentifier, menuProperties);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ AzToolsFramework::MenuProperties menuProperties;
|
|
|
|
+ menuProperties.m_name = "Resolution";
|
|
|
|
+ m_menuManagerInterface->RegisterMenu(ViewportSizeResolutionMenuIdentifier, menuProperties);
|
|
|
|
+ }
|
|
{
|
|
{
|
|
AzToolsFramework::MenuProperties menuProperties;
|
|
AzToolsFramework::MenuProperties menuProperties;
|
|
menuProperties.m_name = "Viewport Options";
|
|
menuProperties.m_name = "Viewport Options";
|
|
@@ -283,6 +305,23 @@ void CLayoutViewPane::OnToolBarRegistrationHook()
|
|
|
|
|
|
void CLayoutViewPane::OnActionRegistrationHook()
|
|
void CLayoutViewPane::OnActionRegistrationHook()
|
|
{
|
|
{
|
|
|
|
+ // Dummy Action with Resize Icon
|
|
|
|
+ {
|
|
|
|
+ constexpr AZStd::string_view actionIdentifier = "o3de.action.viewport.resizeIcon";
|
|
|
|
+ AzToolsFramework::ActionProperties actionProperties;
|
|
|
|
+ actionProperties.m_name = "Viewport Size";
|
|
|
|
+ actionProperties.m_iconPath = ":/Menu/resolution.svg";
|
|
|
|
+
|
|
|
|
+ m_actionManagerInterface->RegisterAction(
|
|
|
|
+ EditorMainWindowActionContextIdentifier,
|
|
|
|
+ actionIdentifier,
|
|
|
|
+ actionProperties,
|
|
|
|
+ []
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
// Dummy Action with Menu Icon
|
|
// Dummy Action with Menu Icon
|
|
{
|
|
{
|
|
constexpr AZStd::string_view actionIdentifier = "o3de.action.viewport.menuIcon";
|
|
constexpr AZStd::string_view actionIdentifier = "o3de.action.viewport.menuIcon";
|
|
@@ -428,7 +467,96 @@ void CLayoutViewPane::OnActionRegistrationHook()
|
|
}
|
|
}
|
|
|
|
|
|
// Viewport Size
|
|
// Viewport Size
|
|
|
|
+
|
|
|
|
+ for (size_t i = 0; i < ViewportRatiosCount; ++i)
|
|
|
|
+ {
|
|
|
|
+ int width = ViewportRatios[i].first;
|
|
|
|
+ int height = ViewportRatios[i].second;
|
|
|
|
+
|
|
|
|
+ AZStd::string actionIdentifier = AZStd::string::format("o3de.action.viewport.size.ratio[%i:%i]", width, height);
|
|
|
|
+ AzToolsFramework::ActionProperties actionProperties;
|
|
|
|
+ actionProperties.m_name = AZStd::string::format("%i:%i", width, height);
|
|
|
|
+ actionProperties.m_category = "Viewport Size Ratio";
|
|
|
|
+
|
|
|
|
+ m_actionManagerInterface->RegisterAction(
|
|
|
|
+ EditorMainWindowActionContextIdentifier,
|
|
|
|
+ actionIdentifier,
|
|
|
|
+ actionProperties,
|
|
|
|
+ [&, w = width, h = height]
|
|
|
|
+ {
|
|
|
|
+ SetAspectRatio(w, h);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ constexpr AZStd::string_view actionIdentifier = "o3de.action.viewport.size.ratio.custom";
|
|
|
|
+ AzToolsFramework::ActionProperties actionProperties;
|
|
|
|
+ actionProperties.m_name = "Custom...";
|
|
|
|
+ actionProperties.m_category = "Viewport Size Ratio";
|
|
|
|
+
|
|
|
|
+ m_actionManagerInterface->RegisterAction(
|
|
|
|
+ EditorMainWindowActionContextIdentifier,
|
|
|
|
+ actionIdentifier,
|
|
|
|
+ actionProperties,
|
|
|
|
+ [&]
|
|
|
|
+ {
|
|
|
|
+ const QRect viewportRect = GetViewport()->rect();
|
|
|
|
+ const unsigned int width = viewportRect.width();
|
|
|
|
+ const unsigned int height = viewportRect.height();
|
|
|
|
+
|
|
|
|
+ int whGCD = gcd(width, height);
|
|
|
|
+ CCustomAspectRatioDlg aspectRatioInputDialog(width / whGCD, height / whGCD, this);
|
|
|
|
+
|
|
|
|
+ if (aspectRatioInputDialog.exec() == QDialog::Accepted)
|
|
|
|
+ {
|
|
|
|
+ const unsigned int aspectX = aspectRatioInputDialog.GetX();
|
|
|
|
+ const unsigned int aspectY = aspectRatioInputDialog.GetY();
|
|
|
|
+
|
|
|
|
+ SetAspectRatio(aspectX, aspectY);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ for (size_t i = 0; i < ViewportResolutionsCount; ++i)
|
|
{
|
|
{
|
|
|
|
+ int width = ViewportResolutions[i].first;
|
|
|
|
+ int height = ViewportResolutions[i].second;
|
|
|
|
+
|
|
|
|
+ AZStd::string actionIdentifier = AZStd::string::format("o3de.action.viewport.size.resolution[%i:%i]", width, height);
|
|
|
|
+ AzToolsFramework::ActionProperties actionProperties;
|
|
|
|
+ actionProperties.m_name = AZStd::string::format("%i:%i", width, height);
|
|
|
|
+ actionProperties.m_category = "Viewport Size Resolution";
|
|
|
|
+
|
|
|
|
+ m_actionManagerInterface->RegisterAction(
|
|
|
|
+ EditorMainWindowActionContextIdentifier,
|
|
|
|
+ actionIdentifier,
|
|
|
|
+ actionProperties,
|
|
|
|
+ [&, w = width, h = height]
|
|
|
|
+ {
|
|
|
|
+ ResizeViewport(w, h);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ constexpr AZStd::string_view actionIdentifier = "o3de.action.viewport.size.resolution.custom";
|
|
|
|
+ AzToolsFramework::ActionProperties actionProperties;
|
|
|
|
+ actionProperties.m_name = "Custom...";
|
|
|
|
+ actionProperties.m_category = "Viewport Size Resolution";
|
|
|
|
+
|
|
|
|
+ m_actionManagerInterface->RegisterAction(
|
|
|
|
+ EditorMainWindowActionContextIdentifier,
|
|
|
|
+ actionIdentifier,
|
|
|
|
+ actionProperties,
|
|
|
|
+ [&]
|
|
|
|
+ {
|
|
|
|
+ const QRect rectViewport = GetViewport()->rect();
|
|
|
|
+ CCustomResolutionDlg resDlg(rectViewport.width(), rectViewport.height(), parentWidget());
|
|
|
|
+ if (resDlg.exec() == QDialog::Accepted)
|
|
|
|
+ {
|
|
|
|
+ ResizeViewport(resDlg.GetWidth(), resDlg.GetHeight());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -457,6 +585,42 @@ void CLayoutViewPane::OnMenuBindingHook()
|
|
m_menuManagerInterface->AddActionToMenu(ViewportHelpersMenuIdentifier, "o3de.action.view.toggleSelectedEntityHelpers", 300);
|
|
m_menuManagerInterface->AddActionToMenu(ViewportHelpersMenuIdentifier, "o3de.action.view.toggleSelectedEntityHelpers", 300);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Size
|
|
|
|
+ {
|
|
|
|
+ m_menuManagerInterface->AddSubMenuToMenu(ViewportSizeMenuIdentifier, ViewportSizeRatioMenuIdentifier, 100);
|
|
|
|
+ {
|
|
|
|
+ for (size_t i = 0; i < ViewportRatiosCount; ++i)
|
|
|
|
+ {
|
|
|
|
+ int width = ViewportRatios[i].first;
|
|
|
|
+ int height = ViewportRatios[i].second;
|
|
|
|
+ AZStd::string actionIdentifier = AZStd::string::format("o3de.action.viewport.size.ratio[%i:%i]", width, height);
|
|
|
|
+
|
|
|
|
+ m_menuManagerInterface->AddActionToMenu(ViewportSizeRatioMenuIdentifier, actionIdentifier, 100 * (aznumeric_cast<int>(i) + 1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ m_menuManagerInterface->AddSeparatorToMenu(
|
|
|
|
+ ViewportSizeRatioMenuIdentifier, 100 * (aznumeric_cast<int>(ViewportRatiosCount) + 1));
|
|
|
|
+ m_menuManagerInterface->AddActionToMenu(
|
|
|
|
+ ViewportSizeRatioMenuIdentifier, "o3de.action.viewport.size.ratio.custom", 100 * (aznumeric_cast<int>(ViewportRatiosCount) + 2));
|
|
|
|
+ }
|
|
|
|
+ m_menuManagerInterface->AddSubMenuToMenu(ViewportSizeMenuIdentifier, ViewportSizeResolutionMenuIdentifier, 200);
|
|
|
|
+ {
|
|
|
|
+ for (size_t i = 0; i < ViewportResolutionsCount; ++i)
|
|
|
|
+ {
|
|
|
|
+ int width = ViewportResolutions[i].first;
|
|
|
|
+ int height = ViewportResolutions[i].second;
|
|
|
|
+ AZStd::string actionIdentifier = AZStd::string::format("o3de.action.viewport.size.resolution[%i:%i]", width, height);
|
|
|
|
+
|
|
|
|
+ m_menuManagerInterface->AddActionToMenu(ViewportSizeResolutionMenuIdentifier, actionIdentifier, 100 * (aznumeric_cast<int>(i) + 1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ m_menuManagerInterface->AddSeparatorToMenu(
|
|
|
|
+ ViewportSizeResolutionMenuIdentifier, 100 * (aznumeric_cast<int>(ViewportResolutionsCount) + 1));
|
|
|
|
+ m_menuManagerInterface->AddActionToMenu(
|
|
|
|
+ ViewportSizeResolutionMenuIdentifier, "o3de.action.viewport.size.resolution.custom", 100 * (aznumeric_cast<int>(ViewportResolutionsCount) + 2));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Options
|
|
// Options
|
|
{
|
|
{
|
|
m_menuManagerInterface->AddActionToMenu(ViewportOptionsMenuIdentifier, "o3de.action.edit.snap.toggleGridSnapping", 300);
|
|
m_menuManagerInterface->AddActionToMenu(ViewportOptionsMenuIdentifier, "o3de.action.edit.snap.toggleGridSnapping", 300);
|
|
@@ -478,6 +642,8 @@ void CLayoutViewPane::OnToolBarBindingHook()
|
|
ViewportTopToolBarIdentifier, "o3de.action.viewport.info.toggle", ViewportDebugInfoMenuIdentifier, 600);
|
|
ViewportTopToolBarIdentifier, "o3de.action.viewport.info.toggle", ViewportDebugInfoMenuIdentifier, 600);
|
|
m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
|
|
m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
|
|
ViewportTopToolBarIdentifier, "o3de.action.view.toggleHelpers", ViewportHelpersMenuIdentifier, 700);
|
|
ViewportTopToolBarIdentifier, "o3de.action.view.toggleHelpers", ViewportHelpersMenuIdentifier, 700);
|
|
|
|
+ m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
|
|
|
|
+ ViewportTopToolBarIdentifier, "o3de.action.viewport.resizeIcon", ViewportSizeMenuIdentifier, 800);
|
|
m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
|
|
m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
|
|
ViewportTopToolBarIdentifier, "o3de.action.viewport.menuIcon", ViewportOptionsMenuIdentifier, 900);
|
|
ViewportTopToolBarIdentifier, "o3de.action.viewport.menuIcon", ViewportOptionsMenuIdentifier, 900);
|
|
}
|
|
}
|