new_editor: close editor-layer app boundary

This commit is contained in:
2026-04-22 16:24:59 +08:00
parent a805803858
commit 2c2a8b8669
25 changed files with 1036 additions and 439 deletions

View File

@@ -1,6 +1,5 @@
#include "ProjectPanel.h"
#include "Rendering/Assets/BuiltInIcons.h"
#include "Composition/EditorPanelIds.h"
#include <XCEditor/Collections/UIEditorTreeView.h>
#include <XCEditor/Foundation/UIEditorTheme.h>
#include <algorithm>
@@ -668,17 +667,6 @@ std::optional<ProjectPanel::EditCommandTarget> ProjectPanel::ResolveEditCommandT
forceCurrentFolder);
}
const UIEditorPanelContentHostPanelState* ProjectPanel::FindMountedProjectPanel(
const UIEditorPanelContentHostFrame& contentHostFrame) const {
for (const UIEditorPanelContentHostPanelState& panelState : contentHostFrame.panelStates) {
if (panelState.panelId == kProjectPanelId && panelState.mounted) {
return &panelState;
}
}
return nullptr;
}
void ProjectPanel::SyncCurrentFolderSelection() {
if (!HasProjectRuntime()) {
m_windowTreeItems.clear();
@@ -1088,25 +1076,25 @@ void ProjectPanel::EmitSelectionClearedEvent(EventSource source) {
std::vector<UIInputEvent> ProjectPanel::BuildTreeInteractionInputEvents(
const std::vector<UIInputEvent>& inputEvents,
const UIRect& bounds,
const PanelInputContext& inputContext) const {
const UIEditorHostedPanelDispatchEntry& dispatchEntry) const {
const std::vector<UIInputEvent> rawEvents =
BuildUIEditorPanelInputEvents(
bounds,
inputEvents,
UIEditorPanelInputFilterOptions{
.allowPointerInBounds = inputContext.allowInteraction,
.allowPointerInBounds = dispatchEntry.allowInteraction,
.allowPointerWhileCaptured = HasActivePointerCapture(),
.allowKeyboardInput = inputContext.hasInputFocus,
.allowKeyboardInput = dispatchEntry.focused,
.allowFocusEvents =
inputContext.hasInputFocus ||
dispatchEntry.focused ||
HasActivePointerCapture() ||
inputContext.focusGained ||
inputContext.focusLost,
dispatchEntry.focusGained ||
dispatchEntry.focusLost,
.includePointerLeave =
inputContext.allowInteraction || HasActivePointerCapture()
dispatchEntry.allowInteraction || HasActivePointerCapture()
},
inputContext.focusGained,
inputContext.focusLost);
dispatchEntry.focusGained,
dispatchEntry.focusLost);
const Widgets::UIEditorTreeViewLayout layout =
m_treeFrame.layout.bounds.width > 0.0f
@@ -1490,18 +1478,15 @@ void ProjectPanel::ClaimCommandFocus(
}
void ProjectPanel::Update(
const UIEditorPanelContentHostFrame& contentHostFrame,
const std::vector<UIInputEvent>& inputEvents,
const PanelInputContext& inputContext) {
const UIEditorHostedPanelDispatchEntry& dispatchEntry,
const std::vector<UIInputEvent>& inputEvents) {
m_requestPointerCapture = false;
m_requestPointerRelease = false;
m_frameEvents.clear();
GridDrag::ResetTransientRequests(m_assetDragState);
TreeDrag::ResetTransientRequests(m_treeDragState);
const UIEditorPanelContentHostPanelState* panelState =
FindMountedProjectPanel(contentHostFrame);
if (panelState == nullptr) {
if (!dispatchEntry.mounted) {
if (m_splitterDragging ||
m_assetDragState.dragging ||
m_treeDragState.dragging ||
@@ -1536,26 +1521,29 @@ void ProjectPanel::Update(
SyncAssetSelectionFromRuntime();
const std::vector<UIInputEvent> filteredEvents =
BuildUIEditorPanelInputEvents(
panelState->bounds,
dispatchEntry.bounds,
inputEvents,
UIEditorPanelInputFilterOptions{
.allowPointerInBounds = inputContext.allowInteraction,
.allowPointerInBounds = dispatchEntry.allowInteraction,
.allowPointerWhileCaptured = HasActivePointerCapture(),
.allowKeyboardInput = inputContext.hasInputFocus,
.allowKeyboardInput = dispatchEntry.focused,
.allowFocusEvents =
inputContext.hasInputFocus ||
dispatchEntry.focused ||
HasActivePointerCapture() ||
inputContext.focusGained ||
inputContext.focusLost,
dispatchEntry.focusGained ||
dispatchEntry.focusLost,
.includePointerLeave =
inputContext.allowInteraction || HasActivePointerCapture()
dispatchEntry.allowInteraction || HasActivePointerCapture()
},
inputContext.focusGained,
inputContext.focusLost);
ClaimCommandFocus(filteredEvents, panelState->bounds, inputContext.allowInteraction);
dispatchEntry.focusGained,
dispatchEntry.focusLost);
ClaimCommandFocus(
filteredEvents,
dispatchEntry.bounds,
dispatchEntry.allowInteraction);
m_navigationWidth = ClampNavigationWidth(m_navigationWidth, panelState->bounds.width);
m_layout = BuildLayout(panelState->bounds);
m_navigationWidth = ClampNavigationWidth(m_navigationWidth, dispatchEntry.bounds.width);
m_layout = BuildLayout(dispatchEntry.bounds);
if (m_contextMenu.open) {
RebuildContextMenu();
}
@@ -1583,8 +1571,8 @@ void ProjectPanel::Update(
const std::vector<UIInputEvent> treeEvents =
BuildTreeInteractionInputEvents(
inputEvents,
panelState->bounds,
inputContext);
dispatchEntry.bounds,
dispatchEntry);
m_treeFrame = UpdateUIEditorTreeViewInteraction(
m_treeInteractionState,
m_folderSelection,
@@ -1599,7 +1587,7 @@ void ProjectPanel::Update(
m_treeFrame.result.selectedItemId != GetBrowserModel().GetCurrentFolderId()) {
CloseContextMenu();
NavigateToFolder(m_treeFrame.result.selectedItemId, EventSource::Tree);
m_layout = BuildLayout(panelState->bounds);
m_layout = BuildLayout(dispatchEntry.bounds);
}
if (m_treeFrame.result.renameRequested &&
!m_treeFrame.result.renameItemId.empty()) {
@@ -1685,7 +1673,7 @@ void ProjectPanel::Update(
EmitSelectionClearedEvent(EventSource::Tree);
}
SyncCurrentFolderSelection();
m_layout = BuildLayout(panelState->bounds);
m_layout = BuildLayout(dispatchEntry.bounds);
m_treeFrame.layout = Widgets::BuildUIEditorTreeViewLayout(
m_layout.treeRect,
GetWindowTreeItems(),
@@ -1808,7 +1796,7 @@ void ProjectPanel::Update(
}
}
m_layout = BuildLayout(panelState->bounds);
m_layout = BuildLayout(dispatchEntry.bounds);
m_treeFrame.layout = Widgets::BuildUIEditorTreeViewLayout(
m_layout.treeRect,
GetWindowTreeItems(),
@@ -1859,8 +1847,10 @@ void ProjectPanel::Update(
case UIInputEventType::PointerMove: {
if (m_splitterDragging) {
m_navigationWidth =
ClampNavigationWidth(event.position.x - panelState->bounds.x, panelState->bounds.width);
m_layout = BuildLayout(panelState->bounds);
ClampNavigationWidth(
event.position.x - dispatchEntry.bounds.x,
dispatchEntry.bounds.width);
m_layout = BuildLayout(dispatchEntry.bounds);
}
m_splitterHovered =
@@ -1981,7 +1971,7 @@ void ProjectPanel::Update(
m_layout.breadcrumbItems[releasedBreadcrumbIndex];
if (item.clickable) {
NavigateToFolder(item.targetFolderId, EventSource::Breadcrumb);
m_layout = BuildLayout(panelState->bounds);
m_layout = BuildLayout(dispatchEntry.bounds);
}
}
m_pressedBreadcrumbIndex = kInvalidLayoutIndex;