3
0

CreateNodeMimeEvent.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <AzCore/Memory/SystemAllocator.h>
  10. #include <AzCore/RTTI/ReflectContext.h>
  11. #include <GraphCanvas/Widgets/MimeEvents/CreateSplicingNodeMimeEvent.h>
  12. #include "ScriptCanvas/Bus/NodeIdPair.h"
  13. #include <ScriptCanvas/Core/Core.h>
  14. namespace ScriptCanvasEditor
  15. {
  16. class CreateNodeMimeEvent
  17. : public GraphCanvas::CreateSplicingNodeMimeEvent
  18. {
  19. public:
  20. AZ_RTTI(CreateNodeMimeEvent, "{95C84213-1FF8-42FF-96F3-37B80B7E2C20}", GraphCanvas::CreateSplicingNodeMimeEvent);
  21. AZ_CLASS_ALLOCATOR(CreateNodeMimeEvent, AZ::SystemAllocator);
  22. static void Reflect(AZ::ReflectContext* reflectContext);
  23. CreateNodeMimeEvent() = default;
  24. ~CreateNodeMimeEvent() = default;
  25. const ScriptCanvasEditor::NodeIdPair& GetCreatedPair() const;
  26. bool ExecuteEvent(const AZ::Vector2& mouseDropPosition, AZ::Vector2& dropPosition, const AZ::EntityId& graphCanvasGraphId) override final;
  27. AZ::EntityId CreateSplicingNode(const AZ::EntityId& graphCanvasGraphId) override;
  28. protected:
  29. virtual ScriptCanvasEditor::NodeIdPair CreateNode(const ScriptCanvas::ScriptCanvasId& scriptCanvasId) const = 0;
  30. NodeIdPair m_nodeIdPair;
  31. };
  32. // There are a couple of cases where we have some weird construction steps that aren't captured in the CreateNodeMimeEvent
  33. // To deal with those cases, we want to make a specialized mime event so we can catch these cases from the context menu
  34. // and execute the right functions.
  35. class SpecializedCreateNodeMimeEvent
  36. : public GraphCanvas::GraphCanvasMimeEvent
  37. {
  38. public:
  39. AZ_RTTI(SpecializedCreateNodeMimeEvent, "{7909C855-B6DA-47E4-97DB-BBC8315C30B1}", GraphCanvas::GraphCanvasMimeEvent);
  40. AZ_CLASS_ALLOCATOR(SpecializedCreateNodeMimeEvent, AZ::SystemAllocator);
  41. static void Reflect(AZ::ReflectContext* reflectContext);
  42. SpecializedCreateNodeMimeEvent() = default;
  43. ~SpecializedCreateNodeMimeEvent() = default;
  44. virtual NodeIdPair ConstructNode(const AZ::EntityId& scriptCanvasGraphId, const AZ::Vector2& scenePosition) = 0;
  45. };
  46. // Special case specialization here for some automation procedures.
  47. // Want to be able to generate all of the possible events from a MultiCreationNode and handle
  48. // them all in an automated way
  49. class MultiCreateNodeMimeEvent
  50. : public SpecializedCreateNodeMimeEvent
  51. {
  52. public:
  53. AZ_RTTI(MultiCreateNodeMimeEvent, "{44A3F43F-E6D3-4EC7-8E80-82981661603E}", SpecializedCreateNodeMimeEvent);
  54. AZ_CLASS_ALLOCATOR(MultiCreateNodeMimeEvent, AZ::SystemAllocator);
  55. static void Reflect(AZ::ReflectContext* reflectContext);
  56. virtual AZStd::vector< GraphCanvas::GraphCanvasMimeEvent* > CreateMimeEvents() const = 0;
  57. };
  58. }