Refactor new editor state ownership model
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "ProjectPanelInternal.h"
|
||||
|
||||
#include "Project/EditorProjectRuntime.h"
|
||||
#include "State/EditorCommandFocusService.h"
|
||||
|
||||
#include <XCEditor/Collections/UIEditorTreePanelBehavior.h>
|
||||
#include <XCEditor/Fields/UIEditorFieldStyle.h>
|
||||
@@ -212,6 +213,11 @@ void ProjectPanel::SetProjectRuntime(EditorProjectRuntime* projectRuntime) {
|
||||
SyncAssetSelectionFromRuntime();
|
||||
}
|
||||
|
||||
void ProjectPanel::SetCommandFocusService(
|
||||
EditorCommandFocusService* commandFocusService) {
|
||||
m_commandFocusService = commandFocusService;
|
||||
}
|
||||
|
||||
void ProjectPanel::SetBuiltInIcons(const BuiltInIcons* icons) {
|
||||
m_icons = icons;
|
||||
if (EditorProjectRuntime* runtime = ResolveProjectRuntime();
|
||||
@@ -1308,6 +1314,31 @@ void ProjectPanel::ResetTransientFrames() {
|
||||
m_splitterDragging = false;
|
||||
}
|
||||
|
||||
void ProjectPanel::ClaimCommandFocus(
|
||||
const std::vector<UIInputEvent>& inputEvents,
|
||||
const UIRect& bounds,
|
||||
bool allowInteraction) {
|
||||
if (m_commandFocusService == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const UIInputEvent& event : inputEvents) {
|
||||
if (event.type == UIInputEventType::FocusGained) {
|
||||
m_commandFocusService->ClaimFocus(EditorActionRoute::Project);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowInteraction ||
|
||||
event.type != UIInputEventType::PointerButtonDown ||
|
||||
!ContainsPoint(bounds, event.position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_commandFocusService->ClaimFocus(EditorActionRoute::Project);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::Update(
|
||||
const UIEditorPanelContentHostFrame& contentHostFrame,
|
||||
const std::vector<UIInputEvent>& inputEvents,
|
||||
@@ -1364,6 +1395,7 @@ void ProjectPanel::Update(
|
||||
.allowFocusEvents = panelActive || HasActivePointerCapture(),
|
||||
.includePointerLeave = allowInteraction || HasActivePointerCapture()
|
||||
});
|
||||
ClaimCommandFocus(filteredEvents, panelState->bounds, allowInteraction);
|
||||
|
||||
m_navigationWidth = ClampNavigationWidth(m_navigationWidth, panelState->bounds.width);
|
||||
m_layout = BuildLayout(panelState->bounds);
|
||||
|
||||
Reference in New Issue
Block a user