/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include #include #include #include class QGraphicsLayout; namespace GraphCanvas { //! Base class for internal Node Layouts to help deal with some book keeping class NodeLayoutComponent : public AZ::Component , public NodeLayoutRequestBus::Handler { public: AZ_COMPONENT(NodeLayoutComponent, "{D3152CCC-1C6D-4E95-829D-0441002440AB}"); static void Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serializeContext = azrtti_cast(context); if (serializeContext) { serializeContext->Class() ->Version(1) ; } } NodeLayoutComponent() : m_layout(nullptr) { } virtual ~NodeLayoutComponent() { } // AZ::Component static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) { provided.push_back(NodeLayoutServiceCrc); } static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) { incompatible.push_back(NodeLayoutServiceCrc); } static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) { dependent.push_back(NodeLayoutServiceCrc); } static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) { required.push_back(AZ_CRC("GraphCanvas_NodeService", 0xcc0f32cc)); required.push_back(AZ_CRC("GraphCanvas_StyledGraphicItemService", 0xeae4cdf4)); } void Init() override { } void Activate() override { NodeLayoutRequestBus::Handler::BusConnect(GetEntityId()); } void Deactivate() override { NodeLayoutRequestBus::Handler::BusDisconnect(); } //// // NodeLayoutRequestBus QGraphicsLayout* GetLayout() override { return m_layout; } //// protected: // Methods to simplify casting in other components template T* GetLayoutAs() { return static_cast(m_layout); } template const T* GetLayoutAs() const { return static_cast(m_layout); } QGraphicsLayout* m_layout; }; }