PropertySlotLayoutComponent.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/StyleBus.h>
  14. #include <GraphCanvas/Components/Slots/SlotBus.h>
  15. #include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
  16. #include <GraphCanvas/Components/VisualBus.h>
  17. #include <Widgets/GraphCanvasLabel.h>
  18. #include <Widgets/NodePropertyDisplayWidget.h>
  19. #include <GraphCanvas/Styling/StyleHelper.h>
  20. namespace GraphCanvas
  21. {
  22. class PropertySlotLayoutComponent;
  23. class GraphCanvasLabel;
  24. class PropertySlotLayout
  25. : public QGraphicsLinearLayout
  26. , public SlotNotificationBus::Handler
  27. , public SceneMemberNotificationBus::Handler
  28. , public StyleNotificationBus::Handler
  29. , public VisualNotificationBus::Handler
  30. {
  31. public:
  32. AZ_CLASS_ALLOCATOR(PropertySlotLayout, AZ::SystemAllocator);
  33. PropertySlotLayout(PropertySlotLayoutComponent& owner);
  34. ~PropertySlotLayout();
  35. void Activate();
  36. void Deactivate();
  37. // SceneMemberNotificationBus
  38. void OnSceneSet(const AZ::EntityId&) override;
  39. void OnSceneReady() override;
  40. ////
  41. // SlotNotificationBus
  42. void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
  43. void OnTooltipChanged(const AZStd::string& tooltip) override;
  44. ////
  45. // StyleNotificationBus
  46. void OnStyleChanged() override;
  47. ////
  48. private:
  49. void TryAndSetupSlot();
  50. void CreateDataDisplay();
  51. void UpdateLayout();
  52. void UpdateGeometry();
  53. ConnectionType m_connectionType;
  54. Styling::StyleHelper m_style;
  55. PropertySlotLayoutComponent& m_owner;
  56. QGraphicsWidget* m_spacer;
  57. NodePropertyDisplayWidget* m_nodePropertyDisplay;
  58. GraphCanvasLabel* m_slotText;
  59. };
  60. //! Lays out the parts of the Data Slot
  61. class PropertySlotLayoutComponent
  62. : public SlotLayoutComponent
  63. {
  64. public:
  65. AZ_COMPONENT(PropertySlotLayoutComponent, "{B9F55349-7CAD-49BE-A9D1-F41A89A28024}");
  66. static void Reflect(AZ::ReflectContext* context);
  67. PropertySlotLayoutComponent();
  68. virtual ~PropertySlotLayoutComponent() = default;
  69. void Init();
  70. void Activate();
  71. void Deactivate();
  72. private:
  73. PropertySlotLayout* m_layout;
  74. };
  75. }