DefaultSlotLayoutComponent.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <Components/Slots/SlotLayoutComponent.h>
  11. #include <GraphCanvas/Components/Nodes/NodeBus.h>
  12. #include <GraphCanvas/Components/SceneBus.h>
  13. #include <GraphCanvas/Components/Slots/SlotBus.h>
  14. #include <GraphCanvas/Components/StyleBus.h>
  15. #include <GraphCanvas/Styling/StyleHelper.h>
  16. #include <Widgets/GraphCanvasLabel.h>
  17. namespace GraphCanvas
  18. {
  19. class DefaultSlotLayoutComponent;
  20. class SlotConnectionPin;
  21. class DefaultSlotLayout
  22. : public QGraphicsLinearLayout
  23. , public StyleNotificationBus::Handler
  24. , public SceneMemberNotificationBus::Handler
  25. {
  26. public:
  27. AZ_CLASS_ALLOCATOR(DefaultSlotLayout, AZ::SystemAllocator);
  28. DefaultSlotLayout(DefaultSlotLayoutComponent& owner);
  29. ~DefaultSlotLayout();
  30. void Activate();
  31. void Deactivate();
  32. // SceneMemberNotificationBus
  33. void OnSceneSet(const AZ::EntityId&) override;
  34. void OnSceneReady() override;
  35. ////
  36. // StyleNotificationBus
  37. void OnStyleChanged() override;
  38. ////
  39. private:
  40. void UpdateLayout();
  41. void UpdateGeometry();
  42. ConnectionType m_connectionType;
  43. Styling::StyleHelper m_style;
  44. DefaultSlotLayoutComponent& m_owner;
  45. SlotConnectionPin* m_slotConnectionPin;
  46. GraphCanvasLabel* m_slotText;
  47. };
  48. //! Lays out the parts of a basic Node
  49. class DefaultSlotLayoutComponent
  50. : public SlotLayoutComponent
  51. {
  52. public:
  53. AZ_COMPONENT(DefaultSlotLayoutComponent, "{40F5DD3B-3B63-488F-AEBC-F6AE34A00415}", SlotLayoutComponent);
  54. static void Reflect(AZ::ReflectContext* context);
  55. DefaultSlotLayoutComponent();
  56. virtual ~DefaultSlotLayoutComponent() = default;
  57. void Init();
  58. void Activate();
  59. void Deactivate();
  60. private:
  61. DefaultSlotLayout* m_defaultSlotLayout;
  62. };
  63. }