Update snapping settings to be stored in the Settings Registry (#646)

* add overload to ActionManager to support capturing an AZStd::function

* move snapping settings to new settings registry

* remove unneeded reference in ViewportSettings

* move viewport setting function implementations to .cpp file

* add more sensible default values for snapping

* fix variable name for angle snapping

* remove const from function prototype value parameters

* add import/export api for free functions

* change from std::bind to a lambda

* remove redundant const for constexpr string_view

* add AZStd alias for std::abs
This commit is contained in:
Tom Hulton-Harrop
2021-05-10 18:40:32 +01:00
committed by GitHub
parent bdaa7eb3c1
commit b2523217c3
15 changed files with 242 additions and 81 deletions
+16 -6
View File
@@ -78,6 +78,7 @@ AZ_POP_DISABLE_WARNING
#include "Core/QtEditorApplication.h"
#include "UndoDropDown.h"
#include "CVarMenu.h"
#include "EditorViewportSettings.h"
#include "KeyboardCustomizationSettings.h"
#include "CustomizeKeyboardDialog.h"
@@ -915,13 +916,22 @@ void MainWindow::InitActions()
.SetToolTip(tr("Snap to grid (G)"))
.SetStatusTip(tr("Toggles snap to grid"))
.SetCheckable(true)
.RegisterUpdateCallback(this, &MainWindow::OnUpdateSnapToGrid);
.RegisterUpdateCallback([](QAction* action) {
Q_ASSERT(action->isCheckable());
action->setChecked(Editor::GridSnappingEnabled());
})
.Connect(&QAction::triggered, []() { Editor::SetGridSnapping(!Editor::GridSnappingEnabled()); });
am->AddAction(ID_SNAPANGLE, tr("Snap angle"))
.SetIcon(Style::icon("Angle"))
.SetApplyHoverEffect()
.SetStatusTip(tr("Snap angle"))
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSnapangle);
.RegisterUpdateCallback([](QAction* action) {
Q_ASSERT(action->isCheckable());
action->setChecked(Editor::AngleSnappingEnabled());
})
.Connect(&QAction::triggered, []() { Editor::SetAngleSnapping(!Editor::AngleSnappingEnabled()); });
// Display actions
am->AddAction(ID_WIREFRAME, tr("&Wireframe"))
@@ -1432,12 +1442,12 @@ QWidget* MainWindow::CreateSnapToGridWidget()
{
SnapToWidget::SetValueCallback setCallback = [](double snapStep)
{
GetIEditor()->GetViewManager()->GetGrid()->size = snapStep;
Editor::SetGridSnappingSize(snapStep);
};
SnapToWidget::GetValueCallback getCallback = []()
{
return GetIEditor()->GetViewManager()->GetGrid()->size;
return Editor::GridSnappingSize();
};
return new SnapToWidget(m_actionManager->GetAction(ID_SNAP_TO_GRID), setCallback, getCallback);
@@ -1447,12 +1457,12 @@ QWidget* MainWindow::CreateSnapToAngleWidget()
{
SnapToWidget::SetValueCallback setCallback = [](double snapAngle)
{
GetIEditor()->GetViewManager()->GetGrid()->angleSnap = snapAngle;
Editor::SetAngleSnappingSize(snapAngle);
};
SnapToWidget::GetValueCallback getCallback = []()
{
return GetIEditor()->GetViewManager()->GetGrid()->angleSnap;
return Editor::AngleSnappingSize();
};
return new SnapToWidget(m_actionManager->GetAction(ID_SNAPANGLE), setCallback, getCallback);