ViewportMoveGuideInteraction.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include "ViewportDragInteraction.h"
  10. #include "ViewportInteraction.h"
  11. #include <LyShine/Bus/UiTransform2dBus.h>
  12. class EditorWindow;
  13. //! Class used while a "Move guide" interaction is in progress in move or anchor mode
  14. class ViewportMoveGuideInteraction
  15. : public ViewportDragInteraction
  16. {
  17. public:
  18. ViewportMoveGuideInteraction(
  19. EditorWindow* editorWindow,
  20. AZ::EntityId canvasId,
  21. bool guideIsVertical,
  22. int guideIndex,
  23. const AZ::Vector2& startDragMousePos);
  24. virtual ~ViewportMoveGuideInteraction();
  25. // ViewportDragInteraction
  26. void Update(const AZ::Vector2& mousePos) override;
  27. void Render(Draw2dHelper& draw2d) override;
  28. void EndInteraction(EndState endState) override;
  29. // ~ViewportDragInteraction
  30. protected:
  31. void MoveGuideToMousePos(const AZ::Vector2& mousePos);
  32. protected:
  33. // State that we will need every frame in the update is cached locally in this object
  34. EditorWindow* m_editorWindow;
  35. AZ::EntityId m_canvasId;
  36. bool m_guideIsVertical = false;
  37. int m_guideIndex = 0;
  38. bool m_isSnapping = false;
  39. float m_startingPosition = 0.0f;
  40. AZStd::string m_canvasUndoXml;
  41. AZ::Vector2 m_cursorViewportPos;
  42. };