LYN-7054 + LYN-7704 | Exit Focus Mode when starting Game Mode, correct painting of Prefab capsules in Outliner. (#5280)
* Add RefreshAllContainerEntities function to ContainerEntityInterface. It refreshes all registered containers so that listeners can refresh their state. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Move Prefab border painting to foreground, and invert foreground painting order. This ensures the Prefab capsules are drawn according to UX. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
+4
@@ -58,6 +58,10 @@ namespace AzToolsFramework
|
||||
//! @return The highest closed entity container id if any, or entityId otherwise.
|
||||
virtual AZ::EntityId FindHighestSelectableEntity(AZ::EntityId entityId) const = 0;
|
||||
|
||||
//! Triggers the OnContainerEntityStatusChanged notifications for all registered containers,
|
||||
//! allowing listeners to update correctly.
|
||||
virtual void RefreshAllContainerEntities(AzFramework::EntityContextId entityContextId) const = 0;
|
||||
|
||||
//! Clears all open state information for Container Entities for the EntityContextId provided.
|
||||
//! Used when context is switched, for example in the case of a new root prefab being loaded
|
||||
//! in place of an old one.
|
||||
|
||||
+9
@@ -142,6 +142,15 @@ namespace AzToolsFramework
|
||||
Clear(editorEntityContextId);
|
||||
}
|
||||
|
||||
void ContainerEntitySystemComponent::RefreshAllContainerEntities([[maybe_unused]] AzFramework::EntityContextId entityContextId) const
|
||||
{
|
||||
for (AZ::EntityId containerEntityId : m_containers)
|
||||
{
|
||||
ContainerEntityNotificationBus::Broadcast(
|
||||
&ContainerEntityNotificationBus::Events::OnContainerEntityStatusChanged, containerEntityId, m_openContainers.contains(containerEntityId));
|
||||
}
|
||||
}
|
||||
|
||||
ContainerEntityOperationResult ContainerEntitySystemComponent::Clear(AzFramework::EntityContextId entityContextId)
|
||||
{
|
||||
// We don't yet support multiple entity contexts, so only clear the default.
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ namespace AzToolsFramework
|
||||
ContainerEntityOperationResult SetContainerOpen(AZ::EntityId entityId, bool open) override;
|
||||
bool IsContainerOpen(AZ::EntityId entityId) const override;
|
||||
AZ::EntityId FindHighestSelectableEntity(AZ::EntityId entityId) const override;
|
||||
void RefreshAllContainerEntities(AzFramework::EntityContextId entityContextId) const override;
|
||||
ContainerEntityOperationResult Clear(AzFramework::EntityContextId entityContextId) override;
|
||||
bool IsUnderClosedContainerEntity(AZ::EntityId entityId) const override;
|
||||
|
||||
|
||||
+1
-12
@@ -2180,20 +2180,9 @@ namespace AzToolsFramework
|
||||
|
||||
void EntityOutlinerItemDelegate::PaintAncestorForegrounds(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
// Go through ancestors and add them to the stack
|
||||
AZStd::stack<QModelIndex> handlerStack;
|
||||
|
||||
// Ancestor foregrounds are painted on top of the childrens'.
|
||||
for (QModelIndex ancestorIndex = index.parent(); ancestorIndex.isValid(); ancestorIndex = ancestorIndex.parent())
|
||||
{
|
||||
handlerStack.push(ancestorIndex);
|
||||
}
|
||||
|
||||
// Apply the ancestor overrides from top to bottom
|
||||
while (!handlerStack.empty())
|
||||
{
|
||||
QModelIndex ancestorIndex = handlerStack.top();
|
||||
handlerStack.pop();
|
||||
|
||||
AZ::EntityId ancestorEntityId(ancestorIndex.data(EntityOutlinerListModel::EntityIdRole).value<AZ::u64>());
|
||||
auto ancestorUiHandler = m_editorEntityFrameworkInterface->GetHandler(ancestorEntityId);
|
||||
|
||||
|
||||
+21
@@ -55,6 +55,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollArea>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -151,6 +152,7 @@ namespace AzToolsFramework
|
||||
PrefabInstanceContainerNotificationBus::Handler::BusConnect();
|
||||
AZ::Interface<PrefabIntegrationInterface>::Register(this);
|
||||
AssetBrowser::AssetBrowserSourceDropBus::Handler::BusConnect(s_prefabFileExtension);
|
||||
EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
|
||||
InitializeShortcuts();
|
||||
}
|
||||
@@ -159,6 +161,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
UninitializeShortcuts();
|
||||
|
||||
EditorEntityContextNotificationBus::Handler::BusDisconnect();
|
||||
AssetBrowser::AssetBrowserSourceDropBus::Handler::BusDisconnect();
|
||||
AZ::Interface<PrefabIntegrationInterface>::Unregister(this);
|
||||
PrefabInstanceContainerNotificationBus::Handler::BusDisconnect();
|
||||
@@ -423,6 +426,24 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::OnStartPlayInEditorBegin()
|
||||
{
|
||||
// Focus on the root prefab (AZ::EntityId() will default to it)
|
||||
s_prefabFocusPublicInterface->FocusOnOwningPrefab(AZ::EntityId());
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::OnStopPlayInEditor()
|
||||
{
|
||||
// Refresh all containers when leaving Game Mode to ensure everything is synced.
|
||||
QTimer::singleShot(
|
||||
0,
|
||||
[&]()
|
||||
{
|
||||
s_containerEntityInterface->RefreshAllContainerEntities(s_editorEntityContextId);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::ContextMenu_CreatePrefab(AzToolsFramework::EntityIdList selectedEntities)
|
||||
{
|
||||
// Save a reference to our currently active window since it will be
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserSourceDropBus.h>
|
||||
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
#include <AzToolsFramework/UI/Prefab/LevelRootUiHandler.h>
|
||||
@@ -56,6 +57,7 @@ namespace AzToolsFramework
|
||||
, public PrefabInstanceContainerNotificationBus::Handler
|
||||
, public PrefabIntegrationInterface
|
||||
, public QObject
|
||||
, private EditorEntityContextNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(PrefabIntegrationManager, AZ::SystemAllocator, 0);
|
||||
@@ -76,6 +78,10 @@ namespace AzToolsFramework
|
||||
// EntityOutlinerSourceDropHandlingBus overrides ...
|
||||
void HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const override;
|
||||
|
||||
// EditorEntityContextNotificationBus overrides ...
|
||||
void OnStartPlayInEditorBegin() override;
|
||||
void OnStopPlayInEditor() override;
|
||||
|
||||
// PrefabInstanceContainerNotificationBus overrides ...
|
||||
void OnPrefabComponentActivate(AZ::EntityId entityId) override;
|
||||
void OnPrefabComponentDeactivate(AZ::EntityId entityId) override;
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace AzToolsFramework
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void PrefabUiHandler::PaintDescendantBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index,
|
||||
void PrefabUiHandler::PaintDescendantForeground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index,
|
||||
const QModelIndex& descendantIndex) const
|
||||
{
|
||||
if (!painter)
|
||||
|
||||
@@ -36,9 +36,12 @@ namespace AzToolsFramework
|
||||
QString GenerateItemTooltip(AZ::EntityId entityId) const override;
|
||||
QIcon GenerateItemIcon(AZ::EntityId entityId) const override;
|
||||
void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
void PaintDescendantBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index,
|
||||
const QModelIndex& descendantIndex) const override;
|
||||
void PaintItemForeground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
void PaintDescendantForeground(
|
||||
QPainter* painter,
|
||||
const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index,
|
||||
const QModelIndex& descendantIndex) const override;
|
||||
bool OnOutlinerItemClick(const QPoint& position, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
void OnOutlinerItemCollapse(const QModelIndex& index) const override;
|
||||
bool OnEntityDoubleClick(AZ::EntityId entityId) const override;
|
||||
|
||||
Reference in New Issue
Block a user