GeneralNodeLayoutComponent.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <AzCore/Component/Component.h>
  11. #include <Components/Nodes/NodeLayoutComponent.h>
  12. #include <GraphCanvas/Components/Nodes/NodeConfiguration.h>
  13. #include <GraphCanvas/Components/Nodes/NodeLayoutBus.h>
  14. #include <GraphCanvas/Components/StyleBus.h>
  15. #include <GraphCanvas/Styling/StyleHelper.h>
  16. class QGraphicsGridLayout;
  17. namespace GraphCanvas
  18. {
  19. //! Lays out the parts of the generic Node
  20. class GeneralNodeLayoutComponent
  21. : public NodeLayoutComponent
  22. , public NodeNotificationBus::Handler
  23. , public StyleNotificationBus::Handler
  24. {
  25. public:
  26. AZ_COMPONENT(GeneralNodeLayoutComponent, "{2AD34925-FF0E-4D0D-A371-6338FBAE0F43}", NodeLayoutComponent);
  27. static void Reflect(AZ::ReflectContext*);
  28. static AZ::Entity* CreateGeneralNodeEntity(const char* nodeType, const NodeConfiguration& nodeConfiguration = NodeConfiguration());
  29. explicit GeneralNodeLayoutComponent();
  30. ~GeneralNodeLayoutComponent();
  31. // AZ::Component
  32. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  33. {
  34. dependent.push_back(NodeLayoutSupportServiceCrc);
  35. dependent.push_back(AZ_CRC("GraphCanvas_TitleService", 0xfe6d63bc));
  36. dependent.push_back(AZ_CRC("GraphCanvas_SlotsContainerService", 0x948b6696));
  37. }
  38. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  39. {
  40. required.push_back(AZ_CRC("GraphCanvas_NodeService", 0xcc0f32cc));
  41. required.push_back(AZ_CRC("GraphCanvas_StyledGraphicItemService", 0xeae4cdf4));
  42. }
  43. void Init() override;
  44. void Activate() override;
  45. void Deactivate() override;
  46. ////
  47. // StyleNotificationBus
  48. void OnStyleChanged() override;
  49. ////
  50. // NodeNotificationBus
  51. void OnNodeActivated() override;
  52. ////
  53. protected:
  54. void UpdateLayoutParameters();
  55. void UpdateHorizontalLayout();
  56. QGraphicsLinearLayout* m_title;
  57. QGraphicsLinearLayout* m_slots;
  58. QGraphicsLinearLayout* m_inputSlots;
  59. QGraphicsLinearLayout* m_outputSlots;
  60. };
  61. }