CommentNodeFrameComponent.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 <QGraphicsWidget>
  10. #include <Components/Nodes/General/GeneralNodeFrameComponent.h>
  11. #include <Components/Nodes/NodeFrameGraphicsWidget.h>
  12. #include <GraphCanvas/Components/Nodes/Comment/CommentBus.h>
  13. #include <GraphCanvas/Components/Nodes/NodeBus.h>
  14. #include <GraphCanvas/Components/Nodes/NodeLayoutBus.h>
  15. #include <GraphCanvas/Components/Nodes/NodeUIBus.h>
  16. #include <GraphCanvas/Components/VisualBus.h>
  17. #include <GraphCanvas/Styling/StyleHelper.h>
  18. namespace GraphCanvas
  19. {
  20. class CommentNodeFrameGraphicsWidget;
  21. class CommentNodeFrameComponent
  22. : public AZ::Component
  23. , public NodeNotificationBus::Handler
  24. {
  25. public:
  26. AZ_COMPONENT(CommentNodeFrameComponent, "{207F2AC3-40C6-49EC-9B73-E691A9ED73E7}", AZ::Component);
  27. static void Reflect(AZ::ReflectContext*);
  28. CommentNodeFrameComponent();
  29. ~CommentNodeFrameComponent() override = default;
  30. // AZ::Component
  31. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  32. {
  33. provided.push_back(AZ_CRC("GraphCanvas_NodeVisualService", 0x39c4e7f3));
  34. provided.push_back(AZ_CRC("GraphCanvas_RootVisualService", 0x9ec46d3b));
  35. provided.push_back(AZ_CRC("GraphCanvas_VisualService", 0xfbb2c871));
  36. }
  37. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  38. {
  39. incompatible.push_back(AZ_CRC("GraphCanvas_NodeVisualService", 0x39c4e7f3));
  40. incompatible.push_back(AZ_CRC("GraphCanvas_RootVisualService", 0x9ec46d3b));
  41. incompatible.push_back(AZ_CRC("GraphCanvas_VisualService", 0xfbb2c871));
  42. }
  43. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  44. {
  45. (void)dependent;
  46. }
  47. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  48. {
  49. required.push_back(AZ_CRC("GraphCanvas_NodeService", 0xcc0f32cc));
  50. required.push_back(AZ_CRC("GraphCanvas_StyledGraphicItemService", 0xeae4cdf4));
  51. }
  52. void Init() override;
  53. void Activate() override;
  54. void Deactivate() override;
  55. ////
  56. // NodeNotifications
  57. void OnNodeActivated() override;
  58. ////
  59. private:
  60. CommentNodeFrameComponent(const CommentNodeFrameComponent&) = delete;
  61. const CommentNodeFrameComponent& operator=(const CommentNodeFrameComponent&) = delete;
  62. AZStd::unique_ptr<CommentNodeFrameGraphicsWidget> m_frameWidget;
  63. };
  64. //! The QGraphicsItem for the generic frame.
  65. class CommentNodeFrameGraphicsWidget
  66. : public GeneralNodeFrameGraphicsWidget
  67. , public CommentNotificationBus::Handler
  68. {
  69. public:
  70. AZ_TYPE_INFO_LEGACY(CommentNodeFrameGraphicsWidget, "{99343103-C8EF-44D0-BD6C-EF44ACDBD69B}", GeneralNodeFrameGraphicsWidget);
  71. AZ_CLASS_ALLOCATOR(CommentNodeFrameGraphicsWidget, AZ::SystemAllocator, 0);
  72. // Do not allow Serialization of Graphics Ui classes
  73. static void Reflect(AZ::ReflectContext*) = delete;
  74. CommentNodeFrameGraphicsWidget(const AZ::EntityId& nodeVisual);
  75. ~CommentNodeFrameGraphicsWidget() override = default;
  76. // CommentNotificationBus
  77. void OnBackgroundColorChanged(const AZ::Color& color) override;
  78. ////
  79. // QGraphicsWidget
  80. void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
  81. ////
  82. };
  83. }