/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #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; }; }