diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp index 12d676a0b4..8f14429cd0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp index 71b1e04ec8..80ac86c974 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceUpdateExecutor.cpp @@ -21,9 +21,9 @@ #include #include #include +#include #include #include -#include namespace AzToolsFramework { @@ -90,17 +90,13 @@ namespace AzToolsFramework if (instanceCountToUpdateInBatch > 0) { + // Notify Propagation has begun + PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotifications::OnPrefabInstancePropagationBegin); + EntityIdList selectedEntityIds; ToolsApplicationRequestBus::BroadcastResult(selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, EntityIdList()); - // Disable the Outliner to avoid showing the propagation steps - EntityOutlinerWidgetInterface* entityOutlinerWidgetInterface = AZ::Interface::Get(); - if (entityOutlinerWidgetInterface) - { - entityOutlinerWidgetInterface->SetUpdatesEnabled(false); - } - for (int i = 0; i < instanceCountToUpdateInBatch; ++i) { Instance* instanceToUpdate = m_instancesUpdateQueue.front(); @@ -168,18 +164,8 @@ namespace AzToolsFramework } ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selectedEntityIds); - // Enable the Outliner - if (entityOutlinerWidgetInterface) - { - entityOutlinerWidgetInterface->SetUpdatesEnabled(true); - - auto prefabPublicInterface = AZ::Interface::Get(); - if (prefabPublicInterface) - { - AZ::EntityId rootEntityId = prefabPublicInterface->GetLevelInstanceContainerEntityId(); - entityOutlinerWidgetInterface->ExpandEntityChildren(rootEntityId); - } - } + // Notify Propagation has ended + PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotifications::OnPrefabInstancePropagationEnd); } m_updatingTemplateInstancesInQueue = false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h new file mode 100644 index 0000000000..fc5879f776 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h @@ -0,0 +1,34 @@ +/* + * 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 + +namespace AzToolsFramework +{ + namespace Prefab + { + class PrefabPublicNotifications + : public AZ::EBusTraits + { + public: + virtual ~PrefabPublicNotifications() = default; + + virtual void OnPrefabInstancePropagationBegin() {} + virtual void OnPrefabInstancePropagationEnd() {} + }; + + using PrefabPublicNotificationBus = AZ::EBus; + + } // namespace Prefab +} // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp index 3ee8a14285..cc65b61908 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp @@ -286,12 +286,12 @@ namespace AzToolsFramework ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect( GetEntityContextId()); EditorEntityInfoNotificationBus::Handler::BusConnect(); - AZ::Interface::Register(this); + Prefab::PrefabPublicNotificationBus::Handler::BusConnect(); } EntityOutlinerWidget::~EntityOutlinerWidget() { - AZ::Interface::Unregister(this); + Prefab::PrefabPublicNotificationBus::Handler::BusDisconnect(); ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect(); EditorEntityInfoNotificationBus::Handler::BusDisconnect(); EditorPickModeNotificationBus::Handler::BusDisconnect(); @@ -1109,25 +1109,18 @@ namespace AzToolsFramework setEnabled(true); SetEntityOutlinerState(m_gui, true); } - - void EntityOutlinerWidget::SetUpdatesEnabled(bool enable) + + void EntityOutlinerWidget::OnPrefabInstancePropagationBegin() { - if (enable) - { - QTimer::singleShot(1, this, [this]() { - m_gui->m_objectTree->setUpdatesEnabled(true); - }); - } - else - { - m_gui->m_objectTree->setUpdatesEnabled(false); - } + m_gui->m_objectTree->setUpdatesEnabled(false); } - void EntityOutlinerWidget::ExpandEntityChildren(AZ::EntityId entityId) + void EntityOutlinerWidget::OnPrefabInstancePropagationEnd() { - QModelIndex index = GetIndexFromEntityId(entityId); - m_gui->m_objectTree->expand(index); + QTimer::singleShot(1, this, [this]() { + m_gui->m_objectTree->setUpdatesEnabled(true); + m_gui->m_objectTree->expand(m_proxyModel->index(0,0)); + }); } void EntityOutlinerWidget::OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId childId) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx index f225bb49b8..9a02febab2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx @@ -20,10 +20,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -62,7 +62,7 @@ namespace AzToolsFramework , private EditorEntityContextNotificationBus::Handler , private EditorEntityInfoNotificationBus::Handler , private ComponentModeFramework::EditorComponentModeNotificationBus::Handler - , private EntityOutlinerWidgetInterface + , private Prefab::PrefabPublicNotificationBus::Handler { Q_OBJECT; public: @@ -106,9 +106,9 @@ namespace AzToolsFramework void EnteredComponentMode(const AZStd::vector& componentModeTypes) override; void LeftComponentMode(const AZStd::vector& componentModeTypes) override; - // EntityOutlinerWidgetInterface - void SetUpdatesEnabled(bool enable) override; - void ExpandEntityChildren(AZ::EntityId entityId) override; + // PrefabPublicNotificationBus + void OnPrefabInstancePropagationBegin() override; + void OnPrefabInstancePropagationEnd() override; // Build a selection object from the given entities. Entities already in the Widget's selection buffers are ignored. template diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidgetInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidgetInterface.h deleted file mode 100644 index afbb790c1a..0000000000 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidgetInterface.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -* 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 - -namespace AzToolsFramework -{ - class EntityOutlinerWidgetInterface - { - public: - AZ_RTTI(EntityOutlinerWidgetInterface, "{30C0F252-EC84-4196-BF59-EB9E73B8ADCB}"); - - virtual void SetUpdatesEnabled(bool enable) = 0; - virtual void ExpandEntityChildren(AZ::EntityId entityId) = 0; - }; - -} // namespace AzToolsFramework - diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 96eaab3009..627c2ea6ed 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -652,6 +652,7 @@ set(FILES Prefab/PrefabPublicHandler.h Prefab/PrefabPublicHandler.cpp Prefab/PrefabPublicInterface.h + Prefab/PrefabPublicNotificationBus.h Prefab/PrefabUndo.h Prefab/PrefabUndo.cpp Prefab/PrefabUndoCache.cpp @@ -687,7 +688,6 @@ set(FILES UI/Outliner/EntityOutlinerDisplayOptionsMenu.cpp UI/Outliner/EntityOutlinerTreeView.hxx UI/Outliner/EntityOutlinerTreeView.cpp - UI/Outliner/EntityOutlinerWidgetInterface.h UI/Outliner/EntityOutlinerWidget.hxx UI/Outliner/EntityOutlinerWidget.cpp UI/Outliner/EntityOutlinerCacheBus.h