Refresh delegate painting in the Outliner even if the widget is not in focus.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
Danilo Aimini
2021-09-21 17:09:31 -07:00
parent e2c4dbe277
commit 7a0be4ff65
6 changed files with 58 additions and 5 deletions
@@ -0,0 +1,27 @@
/*
* 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/Component/EntityId.h>
#include <AzCore/EBus/EBus.h>
namespace AzToolsFramework
{
class FocusModeNotifications
: public AZ::EBusTraits
{
public:
virtual ~FocusModeNotifications() = default;
virtual void OnEditorFocusChanged(AZ::EntityId entityId) = 0;
};
using FocusModeNotificationBus = AZ::EBus<FocusModeNotifications>;
} // namespace AzToolsFramework
@@ -9,6 +9,7 @@
#include <AzCore/Component/TransformBus.h>
#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
#include <AzToolsFramework/FocusMode/FocusModeNotificationBus.h>
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
namespace AzToolsFramework
@@ -64,7 +65,13 @@ namespace AzToolsFramework
void FocusModeSystemComponent::SetFocusRoot(AZ::EntityId entityId)
{
if (m_focusRoot == entityId)
{
return;
}
m_focusRoot = entityId;
FocusModeNotificationBus::Broadcast(&FocusModeNotifications::OnEditorFocusChanged, m_focusRoot);
// TODO - If m_focusRoot != AZ::EntityId(), activate focus mode via ViewportEditorModeTrackerInterface; else, deactivate focus mode
}
@@ -38,10 +38,14 @@ namespace AzToolsFramework
AZ_Assert((m_editorEntityFrameworkInterface != nullptr),
"EntityOutlinerTreeView requires a EditorEntityFrameworkInterface instance on Construction.");
FocusModeNotificationBus::Handler::BusConnect();
}
EntityOutlinerTreeView::~EntityOutlinerTreeView()
{
FocusModeNotificationBus::Handler::BusDisconnect();
ClearQueuedMouseEvent();
}
@@ -261,6 +265,11 @@ namespace AzToolsFramework
StyledTreeView::StartCustomDrag(indexListSorted, supportedActions);
}
void EntityOutlinerTreeView::OnEditorFocusChanged([[maybe_unused]] AZ::EntityId entityId)
{
viewport()->repaint();
}
}
#include <UI/Outliner/moc_EntityOutlinerTreeView.cpp>
@@ -15,6 +15,7 @@
#include <QBasicTimer>
#include <QEvent>
#include <AzToolsFramework/FocusMode/FocusModeNotificationBus.h>
#include <AzQtComponents/Components/Widgets/TreeView.h>
#endif
@@ -35,6 +36,7 @@ namespace AzToolsFramework
//! of other entities. If the selection updates instantly, this would never be possible.
class EntityOutlinerTreeView
: public AzQtComponents::StyledTreeView
, private FocusModeNotificationBus::Handler
{
Q_OBJECT;
public:
@@ -60,6 +62,9 @@ namespace AzToolsFramework
void dragMoveEvent(QDragMoveEvent* event) override;
void dropEvent(QDropEvent* event) override;
// FocusModeNotificationBus overrides ...
void OnEditorFocusChanged(AZ::EntityId entityId) override;
//! Renders the left side of the item: appropriate background, branch lines, icons.
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override;
@@ -34,11 +34,8 @@ namespace AzToolsFramework::Prefab
m_breadcrumbsWidget = breadcrumbsWidget;
m_backButton = backButton;
m_backButton->setVisible(false);
// If a part of the path is clicked, focus on that instance
connect(
m_breadcrumbsWidget, &AzQtComponents::BreadCrumbs::linkClicked, this,
connect(m_breadcrumbsWidget, &AzQtComponents::BreadCrumbs::linkClicked, this,
[&](const QString&, int linkIndex)
{
m_prefabFocusInterface->FocusOnPathIndex(linkIndex);
@@ -65,7 +62,14 @@ namespace AzToolsFramework::Prefab
m_breadcrumbsWidget->pushPath(m_prefabFocusInterface->GetPrefabFocusPath().c_str());
// Only show the back icon button if the path has more than one element
m_backButton->setVisible(m_prefabFocusInterface->GetPrefabFocusPathLength() > 1);
if(m_prefabFocusInterface->GetPrefabFocusPathLength() > 1)
{
m_backButton->show();
}
else
{
m_backButton->hide();
}
}
} // namespace AzToolsFramework::Prefab
@@ -150,6 +150,7 @@ set(FILES
Fingerprinting/TypeFingerprinter.h
Fingerprinting/TypeFingerprinter.cpp
FocusMode/FocusModeInterface.h
FocusMode/FocusModeNotificationBus.h
FocusMode/FocusModeSystemComponent.h
FocusMode/FocusModeSystemComponent.cpp
Logger/TraceLogger.cpp