EditorImageGradientComponentMode.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
  10. #include <AzToolsFramework/Manipulators/PaintBrushManipulator.h>
  11. #include <AzToolsFramework/PaintBrush/PaintBrushSubModeCluster.h>
  12. #include <AzToolsFramework/Undo/UndoSystem.h>
  13. #include <AzToolsFramework/ViewportUi/ViewportUiRequestBus.h>
  14. #include <GradientSignal/Ebuses/ImageGradientModificationBus.h>
  15. namespace GradientSignal
  16. {
  17. class PaintBrushUndoBuffer;
  18. class ImageTileBuffer;
  19. class EditorImageGradientComponentMode
  20. : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
  21. , private ImageGradientModificationNotificationBus::Handler
  22. {
  23. public:
  24. AZ_CLASS_ALLOCATOR_DECL
  25. AZ_RTTI(EditorImageGradientComponentMode, "{49957D52-F1C3-4C34-AA84-7661BC418AB2}", EditorBaseComponentMode)
  26. EditorImageGradientComponentMode(const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
  27. ~EditorImageGradientComponentMode() override;
  28. static void Reflect(AZ::ReflectContext* context);
  29. static void RegisterActions();
  30. static void BindActionsToModes();
  31. static void BindActionsToMenus();
  32. // EditorBaseComponentMode overrides...
  33. void Refresh() override;
  34. AZStd::vector<AzToolsFramework::ActionOverride> PopulateActionsImpl() override;
  35. bool HandleMouseInteraction(const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override;
  36. AZStd::string GetComponentModeName() const override;
  37. AZ::Uuid GetComponentModeType() const override;
  38. protected:
  39. // ImageGradientModificationNotificationBus overrides...
  40. void OnImageGradientBrushStrokeBegin() override;
  41. void OnImageGradientBrushStrokeEnd(AZStd::shared_ptr<ImageTileBuffer> changedDataBuffer, const AZ::Aabb& dirtyRegion) override;
  42. void BeginUndoBatch();
  43. void EndUndoBatch();
  44. private:
  45. //! The core paintbrush manipulator and painting logic.
  46. AZStd::shared_ptr<AzToolsFramework::PaintBrushManipulator> m_brushManipulator;
  47. //! The undo information for the in-progress painting brush stroke.
  48. AzToolsFramework::UndoSystem::URSequencePoint* m_undoBatch = nullptr;
  49. PaintBrushUndoBuffer* m_paintBrushUndoBuffer = nullptr;
  50. //! The paint brush cluster that manages switching between paint/smooth/eyedropper modes
  51. AzToolsFramework::PaintBrushSubModeCluster m_subModeCluster;
  52. };
  53. } // namespace GradientSignal