/* * 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 * */ #include #include #include #include #include namespace GraphCanvas { ////////////////////////// // PropertySlotComponent ////////////////////////// void PropertySlotComponent::Reflect(AZ::ReflectContext* reflectContext) { AZ::SerializeContext* serializeContext = azrtti_cast(reflectContext); if (serializeContext) { serializeContext->Class() ->Version(1) ->Field("PropertyId", &PropertySlotComponent::m_propertyId) ; } } AZ::Entity* PropertySlotComponent::CreatePropertySlot(const AZ::EntityId& nodeId, const AZ::Crc32& propertyId, const SlotConfiguration& slotConfiguration) { AZ::Entity* entity = SlotComponent::CreateCoreSlotEntity(); entity->CreateComponent(propertyId, slotConfiguration); entity->CreateComponent(); AZStd::string styleClass; StyledEntityRequestBus::EventResult(styleClass, nodeId, &StyledEntityRequests::GetClass); entity->CreateComponent(Styling::Elements::PropertySlot, nodeId, styleClass); SlotConnectionFilterComponent* connectionFilter = entity->CreateComponent(); // We don't want to accept any connections. connectionFilter->AddFilter(aznew SlotTypeFilter(ConnectionFilterType::Include)); return entity; } PropertySlotComponent::PropertySlotComponent() : SlotComponent(SlotTypes::PropertySlot) { if (m_slotConfiguration.m_slotGroup == SlotGroups::Invalid) { m_slotConfiguration.m_slotGroup = SlotGroups::PropertyGroup; } } PropertySlotComponent::PropertySlotComponent(const AZ::Crc32& propertyId, const SlotConfiguration& slotConfiguration) : SlotComponent(SlotTypes::PropertySlot, slotConfiguration) , m_propertyId(propertyId) { if (m_slotConfiguration.m_slotGroup == SlotGroups::Invalid) { m_slotConfiguration.m_slotGroup = SlotGroups::PropertyGroup; } } PropertySlotComponent::~PropertySlotComponent() { } void PropertySlotComponent::Init() { SlotComponent::Init(); } void PropertySlotComponent::Activate() { SlotComponent::Activate(); PropertySlotRequestBus::Handler::BusConnect(GetEntityId()); } void PropertySlotComponent::Deactivate() { SlotComponent::Deactivate(); PropertySlotRequestBus::Handler::BusDisconnect(); } int PropertySlotComponent::GetLayoutPriority() const { // Going to want property slots to always be at the top of a display group. return std::numeric_limits().max(); } void PropertySlotComponent::SetLayoutPriority(int priority) { AZ_UNUSED(priority); } const AZ::Crc32& PropertySlotComponent::GetPropertyId() const { return m_propertyId; } AZ::Entity* PropertySlotComponent::ConstructConnectionEntity(const Endpoint&, const Endpoint&, bool) { AZ_Error("Graph Canvas", false, "Property slots cannot have connections."); return nullptr; } }