ExtenderSlotLayoutComponent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <QGraphicsLinearLayout>
  10. #include <QTimer>
  11. #include <Components/Slots/SlotLayoutComponent.h>
  12. #include <GraphCanvas/Components/SceneBus.h>
  13. #include <GraphCanvas/Components/Slots/SlotBus.h>
  14. #include <GraphCanvas/Components/StyleBus.h>
  15. #include <GraphCanvas/Components/VisualBus.h>
  16. #include <GraphCanvas/Styling/StyleHelper.h>
  17. #include <Widgets/GraphCanvasLabel.h>
  18. #include <Widgets/NodePropertyDisplayWidget.h>
  19. namespace GraphCanvas
  20. {
  21. class ExtenderSlotLayoutComponent;
  22. class ExtenderSlotConnectionPin;
  23. class GraphCanvasLabel;
  24. class ExtenderSlotLayout
  25. : public QGraphicsLinearLayout
  26. , public SlotNotificationBus::Handler
  27. , public SceneMemberNotificationBus::Handler
  28. , public StyleNotificationBus::Handler
  29. {
  30. public:
  31. AZ_CLASS_ALLOCATOR(ExtenderSlotLayout, AZ::SystemAllocator);
  32. ExtenderSlotLayout(ExtenderSlotLayoutComponent& owner);
  33. ~ExtenderSlotLayout();
  34. void Activate();
  35. void Deactivate();
  36. // SceneMemberNotificationBus
  37. void OnSceneSet(const AZ::EntityId&) override;
  38. void OnSceneReady() override;
  39. ////
  40. // SlotNotificationBus
  41. void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
  42. void OnNameChanged(const AZStd::string& name) override;
  43. void OnTooltipChanged(const AZStd::string& tooltip) override;
  44. ////
  45. // StyleNotificationBus
  46. void OnStyleChanged() override;
  47. ////
  48. private:
  49. void UpdateLayout();
  50. void UpdateGeometry();
  51. ConnectionType m_connectionType;
  52. Styling::StyleHelper m_style;
  53. ExtenderSlotLayoutComponent& m_owner;
  54. ExtenderSlotConnectionPin* m_slotConnectionPin;
  55. GraphCanvasLabel* m_slotText;
  56. QGraphicsItem* m_slotLabelFilter;
  57. };
  58. //! Lays out the parts of a Extender Slot
  59. class ExtenderSlotLayoutComponent
  60. : public SlotLayoutComponent
  61. {
  62. public:
  63. AZ_COMPONENT(ExtenderSlotLayoutComponent, "{596E1A76-6F84-4C1A-B32D-0B6B069FC9AB}", SlotLayoutComponent);
  64. static void Reflect(AZ::ReflectContext* context);
  65. ExtenderSlotLayoutComponent();
  66. ~ExtenderSlotLayoutComponent() override = default;
  67. void Init() override;
  68. void Activate() override;
  69. void Deactivate() override;
  70. private:
  71. ExtenderSlotLayout* m_layout;
  72. };
  73. }