52112be1ac
* Introduce Outliner button to simplify Prefab editing Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fix Focus Mode and disabled entities colors Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fix - propagate the event if the OnOutlinerItemClick function returns false. This does not change current behavior but makes more sense in the context of future handlers. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Adjust disabled colors to match UX recommendations. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Display the edit button even if the prefab is disabled. Remove prefabWip check (it will be removed for focus mode by the time this goes in). Default to disabled capsule color for borders to save on checks. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Disable edit button on disabled prefabs as it caused conflicts in nested prefabs. May explore that possibility later. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Change disabled text color to be darker, as asked by UX. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
92 lines
4.1 KiB
C++
92 lines
4.1 KiB
C++
/*
|
|
* 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 <AzCore/Memory/SystemAllocator.h>
|
|
|
|
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
|
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
|
#include <AzToolsFramework/FocusMode/FocusModeInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabFocusPublicInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
|
|
#include <AzToolsFramework/Prefab/Template/Template.h>
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
class ContainerEntityInterface;
|
|
class FocusModeInterface;
|
|
}
|
|
|
|
namespace AzToolsFramework::Prefab
|
|
{
|
|
class InstanceEntityMapperInterface;
|
|
|
|
//! Handles Prefab Focus mode, determining which prefab file entity changes will target.
|
|
class PrefabFocusHandler final
|
|
: private PrefabFocusInterface
|
|
, private PrefabFocusPublicInterface
|
|
, private PrefabPublicNotificationBus::Handler
|
|
, private EditorEntityContextNotificationBus::Handler
|
|
, private EditorEntityInfoNotificationBus::Handler
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(PrefabFocusHandler, AZ::SystemAllocator, 0);
|
|
|
|
PrefabFocusHandler();
|
|
~PrefabFocusHandler();
|
|
|
|
// PrefabFocusInterface overrides ...
|
|
void InitializeEditorInterfaces() override;
|
|
PrefabFocusOperationResult FocusOnPrefabInstanceOwningEntityId(AZ::EntityId entityId) override;
|
|
TemplateId GetFocusedPrefabTemplateId(AzFramework::EntityContextId entityContextId) const override;
|
|
InstanceOptionalReference GetFocusedPrefabInstance(AzFramework::EntityContextId entityContextId) const override;
|
|
|
|
// PrefabFocusPublicInterface overrides ...
|
|
PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override;
|
|
PrefabFocusOperationResult FocusOnPathIndex(AzFramework::EntityContextId entityContextId, int index) override;
|
|
AZ::EntityId GetFocusedPrefabContainerEntityId(AzFramework::EntityContextId entityContextId) const override;
|
|
bool IsOwningPrefabBeingFocused(AZ::EntityId entityId) const override;
|
|
bool IsOwningPrefabInFocusHierarchy(AZ::EntityId entityId) const override;
|
|
const AZ::IO::Path& GetPrefabFocusPath(AzFramework::EntityContextId entityContextId) const override;
|
|
const int GetPrefabFocusPathLength(AzFramework::EntityContextId entityContextId) const override;
|
|
|
|
// EditorEntityContextNotificationBus overrides ...
|
|
void OnContextReset() override;
|
|
|
|
// EditorEntityInfoNotificationBus overrides ...
|
|
void OnEntityInfoUpdatedName(AZ::EntityId entityId, const AZStd::string& name) override;
|
|
|
|
// PrefabPublicNotifications overrides ...
|
|
void OnPrefabInstancePropagationEnd();
|
|
|
|
private:
|
|
PrefabFocusOperationResult FocusOnPrefabInstance(InstanceOptionalReference focusedInstance);
|
|
void RefreshInstanceFocusList();
|
|
void RefreshInstanceFocusPath();
|
|
|
|
void OpenInstanceContainers(const AZStd::vector<InstanceOptionalReference>& instances) const;
|
|
void CloseInstanceContainers(const AZStd::vector<InstanceOptionalReference>& instances) const;
|
|
|
|
//! The instance the editor is currently focusing on.
|
|
InstanceOptionalReference m_focusedInstance;
|
|
//! The templateId of the focused instance.
|
|
TemplateId m_focusedTemplateId;
|
|
//! The list of instances going from the root (index 0) to the focused instance.
|
|
AZStd::vector<InstanceOptionalReference> m_instanceFocusHierarchy;
|
|
//! A path containing the names of the containers in the instance focus hierarchy, separated with a /.
|
|
AZ::IO::Path m_instanceFocusPath;
|
|
|
|
ContainerEntityInterface* m_containerEntityInterface = nullptr;
|
|
FocusModeInterface* m_focusModeInterface = nullptr;
|
|
InstanceEntityMapperInterface* m_instanceEntityMapperInterface = nullptr;
|
|
};
|
|
|
|
} // namespace AzToolsFramework::Prefab
|