ViewportManipulatorController.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <AzFramework/Input/Events/InputChannelEventListener.h>
  10. #include <AzFramework/Viewport/MultiViewportController.h>
  11. #include <AzFramework/Viewport/ViewportId.h>
  12. #include <AzToolsFramework/Viewport/ViewportTypes.h>
  13. #include <AzCore/Math/Vector2.h>
  14. #include <SandboxAPI.h>
  15. namespace SandboxEditor
  16. {
  17. class ViewportManipulatorControllerInstance;
  18. using ViewportManipulatorController = AzFramework::
  19. MultiViewportController<ViewportManipulatorControllerInstance, AzFramework::ViewportControllerPriority::DispatchToAllPriorities>;
  20. class ViewportManipulatorControllerInstance final
  21. : public AzFramework::MultiViewportControllerInstanceInterface<ViewportManipulatorController>
  22. {
  23. public:
  24. SANDBOX_API ViewportManipulatorControllerInstance(AzFramework::ViewportId viewport, ViewportManipulatorController* controller);
  25. SANDBOX_API ~ViewportManipulatorControllerInstance();
  26. SANDBOX_API bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
  27. SANDBOX_API void ResetInputChannels() override;
  28. SANDBOX_API void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
  29. private:
  30. bool IsDoubleClick(AzToolsFramework::ViewportInteraction::MouseButton) const;
  31. //! Represents the time and location of a click.
  32. struct ClickEvent
  33. {
  34. AZ::ScriptTimePoint m_time;
  35. AzFramework::ScreenPoint m_position;
  36. };
  37. AzToolsFramework::ViewportInteraction::MouseInteraction m_mouseInteraction;
  38. AZStd::unordered_map<AzToolsFramework::ViewportInteraction::MouseButton, ClickEvent> m_pendingDoubleClicks;
  39. AZ::ScriptTimePoint m_currentTime;
  40. };
  41. } // namespace SandboxEditor