Expose sticky select option to the SettingsRegistry and disable by default (#4149)

* expose sticky select option to the SettingsRegistry

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* update missed callsites after API change to Manipulator Test Framework

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* updates following review feedback

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-09-16 09:14:37 +01:00
committed by GitHub
parent a8908a987a
commit 7e85b1512a
19 changed files with 275 additions and 182 deletions
@@ -15,19 +15,19 @@
namespace AzManipulatorTestFramework
{
//! Base class for derived immediate and retained action dispatchers.
//! Base class for derived immediate action dispatchers.
template<typename DerivedDispatcherT>
class ActionDispatcher
{
public:
virtual ~ActionDispatcher() = default;
//! Enable grid snapping.
DerivedDispatcherT* EnableSnapToGrid();
//! Disable grid snapping.
DerivedDispatcherT* DisableSnapToGrid();
//! Enable/disable grid snapping.
DerivedDispatcherT* SetSnapToGrid(bool enabled);
//! Set the grid size.
DerivedDispatcherT* GridSize(float size);
//! Enable/disable sticky select.
DerivedDispatcherT* SetStickySelect(bool enabled);
//! Enable/disable action logging.
DerivedDispatcherT* LogActions(bool logging);
//! Output a trace debug message.
@@ -66,9 +66,9 @@ namespace AzManipulatorTestFramework
DerivedDispatcherT* EnterComponentMode();
protected:
// Actions to be implemented by derived immediate and retained action dispatchers.
virtual void EnableSnapToGridImpl() = 0;
virtual void DisableSnapToGridImpl() = 0;
// Actions to be implemented by derived immediate action dispatcher.
virtual void SetSnapToGridImpl(bool enabled) = 0;
virtual void SetStickySelectImpl(bool enabled) = 0;
virtual void GridSizeImpl(float size) = 0;
virtual void CameraStateImpl(const AzFramework::CameraState& cameraState) = 0;
virtual void MouseLButtonDownImpl() = 0;
@@ -127,18 +127,18 @@ namespace AzManipulatorTestFramework
}
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::EnableSnapToGrid()
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetSnapToGrid(const bool enabled)
{
Log("Enabling SnapToGrid");
EnableSnapToGridImpl();
Log("SnapToGrid %s", enabled ? "on" : "off");
SetSnapToGridImpl(enabled);
return static_cast<DerivedDispatcherT*>(this);
}
template<typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::DisableSnapToGrid()
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::SetStickySelect(bool enabled)
{
Log("Disabling SnapToGrid");
DisableSnapToGridImpl();
Log("StickySelect %s", enabled ? "on" : "off");
SetStickySelectImpl(enabled);
return static_cast<DerivedDispatcherT*>(this);
}
@@ -16,7 +16,7 @@ namespace AzFramework
{
class DebugDisplayRequests;
struct CameraState;
}
} // namespace AzFramework
namespace AzManipulatorTestFramework
{
@@ -31,14 +31,10 @@ namespace AzManipulatorTestFramework
virtual void SetCameraState(const AzFramework::CameraState& cameraState) = 0;
//! Retrieve the debug display.
virtual AzFramework::DebugDisplayRequests& GetDebugDisplay() = 0;
//! Enable grid snapping.
virtual void EnableGridSnaping() = 0;
//! Disable grid snapping.
virtual void DisableGridSnaping() = 0;
//! Enable grid snapping.
virtual void EnableAngularSnaping() = 0;
//! Disable grid snapping.
virtual void DisableAngularSnaping() = 0;
//! Set if grid snapping is enabled or not.
virtual void SetGridSnapping(bool enabled) = 0;
//! Set if angular snapping is enabled or not.
virtual void SetAngularSnapping(bool enabled) = 0;
//! Set the grid size.
virtual void SetGridSize(float size) = 0;
//! Set the angular step.
@@ -48,6 +44,8 @@ namespace AzManipulatorTestFramework
//! Updates the visibility state.
//! Updates which entities are currently visible given the current camera state.
virtual void UpdateVisibility() = 0;
//! Set if sticky select is enabled or not.
virtual void SetStickySelect(bool enabled) = 0;
};
//! This interface is used to simulate the manipulator manager while the manipulators are under test.
@@ -82,15 +80,15 @@ namespace AzManipulatorTestFramework
//! Return the representation of the viewport interaction model.
ViewportInteractionInterface& GetViewportInteraction()
{
return const_cast<
ViewportInteractionInterface&>(const_cast<const ManipulatorViewportInteraction*>(this)->GetViewportInteraction());
return const_cast<ViewportInteractionInterface&>(
const_cast<const ManipulatorViewportInteraction*>(this)->GetViewportInteraction());
}
//! Return the const representation of the manipulator manager.
ManipulatorManagerInterface& GetManipulatorManager()
{
return const_cast<
ManipulatorManagerInterface&>(const_cast<const ManipulatorViewportInteraction*>(this)->GetManipulatorManager());
return const_cast<ManipulatorManagerInterface&>(
const_cast<const ManipulatorViewportInteraction*>(this)->GetManipulatorManager());
}
};
} // namespace AzManipulatorTestFramework
@@ -52,8 +52,8 @@ namespace AzManipulatorTestFramework
protected:
// ActionDispatcher ...
void EnableSnapToGridImpl() override;
void DisableSnapToGridImpl() override;
void SetSnapToGridImpl(bool enabled) override;
void SetStickySelectImpl(bool enabled) override;
void GridSizeImpl(float size) override;
void CameraStateImpl(const AzFramework::CameraState& cameraState) override;
void MouseLButtonDownImpl() override;
@@ -29,14 +29,13 @@ namespace AzManipulatorTestFramework
// ViewportInteractionInterface overrides ...
void SetCameraState(const AzFramework::CameraState& cameraState) override;
AzFramework::DebugDisplayRequests& GetDebugDisplay() override;
void EnableGridSnaping() override;
void DisableGridSnaping() override;
void EnableAngularSnaping() override;
void DisableAngularSnaping() override;
void SetGridSnapping(bool enabled) override;
void SetAngularSnapping(bool enabled) override;
void SetGridSize(float size) override;
void SetAngularStep(float step) override;
int GetViewportId() const override;
void UpdateVisibility() override;
void SetStickySelect(bool enabled) override;
// ViewportInteractionRequestBus overrides ...
AzFramework::CameraState GetCameraState() override;
@@ -54,6 +53,7 @@ namespace AzManipulatorTestFramework
float AngleStep() const override;
float ManipulatorLineBoundWidth() const override;
float ManipulatorCircleBoundWidth() const override;
bool StickySelectEnabled() const override;
// EditorEntityViewportInteractionRequestBus overrides ...
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntities) override;
@@ -65,6 +65,7 @@ namespace AzManipulatorTestFramework
AzFramework::CameraState m_cameraState;
bool m_gridSnapping = false;
bool m_angularSnapping = false;
bool m_stickySelect = true;
float m_gridSize = 1.0f;
float m_angularStep = 0.0f;
};
@@ -49,17 +49,17 @@ namespace AzManipulatorTestFramework
m_viewportManipulatorInteraction.GetManipulatorManager().ConsumeMouseInteractionEvent(*m_event);
}
void ImmediateModeActionDispatcher::EnableSnapToGridImpl()
void ImmediateModeActionDispatcher::SetSnapToGridImpl(const bool enabled)
{
m_viewportManipulatorInteraction.GetViewportInteraction().EnableGridSnaping();
m_viewportManipulatorInteraction.GetViewportInteraction().SetGridSnapping(enabled);
}
void ImmediateModeActionDispatcher::DisableSnapToGridImpl()
void ImmediateModeActionDispatcher::SetStickySelectImpl(const bool enabled)
{
m_viewportManipulatorInteraction.GetViewportInteraction().DisableGridSnaping();
m_viewportManipulatorInteraction.GetViewportInteraction().SetStickySelect(enabled);
}
void ImmediateModeActionDispatcher::GridSizeImpl(float size)
void ImmediateModeActionDispatcher::GridSizeImpl(const float size)
{
m_viewportManipulatorInteraction.GetViewportInteraction().SetGridSize(size);
}
@@ -6,16 +6,15 @@
*
*/
#include <AzManipulatorTestFramework/ViewportInteraction.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzFramework/Viewport/CameraState.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzManipulatorTestFramework/ViewportInteraction.h>
#include <AzToolsFramework/Manipulators/ManipulatorBus.h>
namespace AzManipulatorTestFramework
{
// Null debug display for dummy draw calls
class NullDebugDisplayRequests
: public AzFramework::DebugDisplayRequests
class NullDebugDisplayRequests : public AzFramework::DebugDisplayRequests
{
public:
virtual ~NullDebugDisplayRequests() = default;
@@ -76,6 +75,11 @@ namespace AzManipulatorTestFramework
return 0.1f;
}
bool ViewportInteraction::StickySelectEnabled() const
{
return m_stickySelect;
}
void ViewportInteraction::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut)
{
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
@@ -101,24 +105,19 @@ namespace AzManipulatorTestFramework
return *m_nullDebugDisplayRequests;
}
void ViewportInteraction::EnableGridSnaping()
void ViewportInteraction::SetGridSnapping(const bool enabled)
{
m_gridSnapping = true;
m_gridSnapping = enabled;
}
void ViewportInteraction::DisableGridSnaping()
void ViewportInteraction::SetAngularSnapping(const bool enabled)
{
m_gridSnapping = false;
m_angularSnapping = enabled;
}
void ViewportInteraction::EnableAngularSnaping()
void ViewportInteraction::SetStickySelect(const bool enabled)
{
m_angularSnapping = true;
}
void ViewportInteraction::DisableAngularSnaping()
{
m_angularSnapping = false;
m_stickySelect = enabled;
}
void ViewportInteraction::SetGridSize(float size)
@@ -152,4 +151,4 @@ namespace AzManipulatorTestFramework
{
return 1.0f;
}
}// namespace AzManipulatorTestFramework
} // namespace AzManipulatorTestFramework
@@ -76,7 +76,7 @@ namespace UnitTest
linearManipulator->SetLocalPosition(action.LocalPosition());
});
m_actionDispatcher->EnableSnapToGrid()
m_actionDispatcher->SetSnapToGrid(true)
->GridSize(5.0f)
->CameraState(m_cameraState)
->MousePosition(initialPositionScreen)
@@ -114,7 +114,7 @@ namespace UnitTest
manipulator->SetLocalPosition(action.LocalPosition());
});
actionDispatcher->EnableSnapToGrid()
actionDispatcher->SetSnapToGrid(true)
->GridSize(1.0f)
->CameraState(cameraState)
->MousePosition(initialPositionScreen)
@@ -48,7 +48,7 @@ namespace UnitTest
{
bool snapping = false;
m_viewportInteraction->EnableGridSnaping();
m_viewportInteraction->SetGridSnapping(true);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
@@ -60,7 +60,7 @@ namespace UnitTest
{
bool snapping = true;
m_viewportInteraction->DisableGridSnaping();
m_viewportInteraction->SetGridSnapping(false);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
@@ -75,7 +75,7 @@ namespace UnitTest
m_viewportInteraction->SetGridSize(expectedGridSize);
m_viewportInteraction->DisableGridSnaping();
m_viewportInteraction->SetGridSnapping(false);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
gridSize, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
@@ -87,7 +87,7 @@ namespace UnitTest
{
bool snapping = false;
m_viewportInteraction->EnableAngularSnaping();
m_viewportInteraction->SetAngularSnapping(true);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
@@ -99,7 +99,7 @@ namespace UnitTest
{
bool snapping = true;
m_viewportInteraction->DisableAngularSnaping();
m_viewportInteraction->SetAngularSnapping(false);
AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
snapping, m_viewportInteraction->GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);