SlotLayoutComponent.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <GraphCanvas/Components/VisualBus.h>
  12. class QGraphicsLayout;
  13. namespace GraphCanvas
  14. {
  15. class SlotLayoutComponent
  16. : public AZ::Component
  17. , public VisualRequestBus::Handler
  18. {
  19. public:
  20. AZ_COMPONENT(SlotLayoutComponent , "{77518A10-3443-4668-ADCB-D6EFC3BF9907}");
  21. static void Reflect(AZ::ReflectContext* context);
  22. SlotLayoutComponent();
  23. virtual ~SlotLayoutComponent();
  24. // AZ::Component
  25. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  26. {
  27. provided.push_back(AZ_CRC("GraphCanvas_SlotVisualService", 0x30aa128a));
  28. provided.push_back(AZ_CRC("GraphCanvas_RootVisualService", 0x9ec46d3b));
  29. }
  30. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  31. {
  32. incompatible.push_back(AZ_CRC("GraphCanvas_SlotVisualService", 0x30aa128a));
  33. incompatible.push_back(AZ_CRC("GraphCanvas_RootVisualService", 0x9ec46d3b));
  34. }
  35. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  36. {
  37. (void)dependent;
  38. }
  39. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  40. {
  41. required.push_back(AZ_CRC("GraphCanvas_SlotService", 0x701eaf6b));
  42. }
  43. void Init() override;
  44. void Activate() override;
  45. void Deactivate() override;
  46. ////
  47. // VisualRequestBus
  48. QGraphicsItem* AsGraphicsItem() override;
  49. QGraphicsLayoutItem* AsGraphicsLayoutItem() override;
  50. bool Contains(const AZ::Vector2& position) const override;
  51. void SetVisible(bool visible) override;
  52. bool IsVisible() const override;
  53. ////
  54. protected:
  55. void SetLayout(QGraphicsLayout* layout);
  56. QGraphicsLayout* GetLayout();
  57. private:
  58. QGraphicsWidget* m_layoutWidget;
  59. QGraphicsLayout* m_layout;
  60. bool m_isVisible = true;
  61. };
  62. }