refactor(new_editor): continue architecture closeout

This commit is contained in:
2026-04-15 22:47:42 +08:00
parent a458f2838c
commit dde03c5241
225 changed files with 4214 additions and 5196 deletions

View File

@@ -1,21 +1,23 @@
#include "Platform/Win32/EditorWindow.h"
#include "Platform/Win32/EditorWindowConstants.h"
#include "Platform/Win32/EditorWindowInputSupport.h"
#include "Platform/Win32/EditorWindowRuntimeSupport.h"
#include "Platform/Win32/EditorWindowInputInternal.h"
#include "Platform/Win32/EditorWindowRuntimeInternal.h"
#include "Platform/Win32/EditorWindowStyle.h"
#include "State/EditorContext.h"
#include <sstream>
#include <utility>
namespace XCEngine::UI::Editor::App {
using namespace EditorWindowSupport;
using namespace EditorWindowInternal;
using namespace EditorWindowInputInternal;
using ::XCEngine::UI::UIDrawList;
using ::XCEngine::UI::UIInputEvent;
using ::XCEngine::UI::UIPoint;
using ::XCEngine::UI::UIRect;
void EditorWindow::RenderRuntimeFrame(
EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
EditorContext& editorContext,
bool globalTabDragActive,
const UIRect& workspaceBounds,
@@ -59,7 +61,8 @@ void EditorWindow::RenderRuntimeFrame(
.dockHostInteractionState;
LogFrameInteractionTrace(editorContext, frameEvents, shellFrame);
QueueShellTransferRequests(globalTabDragActive, dockHostInteractionState, shellFrame);
const EditorWindowFrameTransferRequests transferRequests =
BuildShellTransferRequests(globalTabDragActive, dockHostInteractionState, shellFrame);
ApplyHostCaptureRequests(shellFrame.result);
for (const WorkspaceTraceEntry& entry : m_composition.shellRuntime.GetTraceEntries()) {
@@ -71,6 +74,7 @@ void EditorWindow::RenderRuntimeFrame(
if (frameContext.canRenderViewports) {
m_composition.shellRuntime.RenderRequestedViewports(frameContext.renderContext);
}
return transferRequests;
}
void EditorWindow::RenderInvalidFrame(
@@ -79,14 +83,14 @@ void EditorWindow::RenderInvalidFrame(
drawList.AddText(
UIPoint(28.0f, 28.0f),
"Editor shell asset invalid.",
EditorWindowSupport::kShellTextColor,
EditorWindowInternal::kShellTextColor,
16.0f);
drawList.AddText(
UIPoint(28.0f, 54.0f),
editorContext.GetValidationMessage().empty()
? std::string("Unknown validation error.")
: editorContext.GetValidationMessage(),
EditorWindowSupport::kShellMutedTextColor,
EditorWindowInternal::kShellMutedTextColor,
12.0f);
}
@@ -115,23 +119,93 @@ void EditorWindow::LogFrameInteractionTrace(
LogRuntimeTrace("frame", frameTrace.str());
}
void EditorWindow::QueueShellTransferRequests(
EditorWindowFrameTransferRequests EditorWindow::BuildShellTransferRequests(
bool globalTabDragActive,
const UIEditorDockHostInteractionState& dockHostInteractionState,
const UIEditorShellInteractionFrame& shellFrame) {
const UIEditorShellInteractionFrame& shellFrame) const {
EditorWindowFrameTransferRequests transferRequests = {};
POINT screenPoint = {};
const bool hasScreenPoint = GetCursorPos(&screenPoint) != FALSE;
if (!globalTabDragActive &&
!dockHostInteractionState.activeTabDragNodeId.empty() &&
!dockHostInteractionState.activeTabDragPanelId.empty()) {
QueuePendingTabDragStart(
!dockHostInteractionState.activeTabDragPanelId.empty() &&
hasScreenPoint) {
transferRequests.beginGlobalTabDrag = EditorWindowPanelTransferRequest{
dockHostInteractionState.activeTabDragNodeId,
dockHostInteractionState.activeTabDragPanelId);
dockHostInteractionState.activeTabDragPanelId,
screenPoint,
};
}
if (shellFrame.result.workspaceResult.dockHostResult.detachRequested) {
QueuePendingDetachRequest(
if (shellFrame.result.workspaceResult.dockHostResult.detachRequested &&
hasScreenPoint) {
transferRequests.detachPanel = EditorWindowPanelTransferRequest{
shellFrame.result.workspaceResult.dockHostResult.detachedNodeId,
shellFrame.result.workspaceResult.dockHostResult.detachedPanelId);
shellFrame.result.workspaceResult.dockHostResult.detachedPanelId,
screenPoint,
};
}
return transferRequests;
}
std::string EditorWindow::BuildCaptureStatusText() const {
if (m_render.autoScreenshot.HasPendingCapture()) {
return "Shot pending...";
}
if (!m_render.autoScreenshot.GetLastCaptureError().empty()) {
return TruncateText(m_render.autoScreenshot.GetLastCaptureError(), 38u);
}
if (!m_render.autoScreenshot.GetLastCaptureSummary().empty()) {
return TruncateText(m_render.autoScreenshot.GetLastCaptureSummary(), 38u);
}
return {};
}
void EditorWindow::ApplyHostCaptureRequests(const UIEditorShellInteractionResult& result) {
if (result.requestPointerCapture && GetCapture() != m_window.hwnd) {
SetCapture(m_window.hwnd);
}
if (result.releasePointerCapture && GetCapture() == m_window.hwnd) {
ReleaseCapture();
}
}
void EditorWindow::ApplyHostedContentCaptureRequests() {
if (m_composition.shellRuntime.WantsHostPointerCapture() &&
GetCapture() != m_window.hwnd) {
SetCapture(m_window.hwnd);
}
if (m_composition.shellRuntime.WantsHostPointerRelease() &&
GetCapture() == m_window.hwnd &&
!m_composition.shellRuntime.HasShellInteractiveCapture()) {
ReleaseCapture();
}
}
std::string EditorWindow::DescribeInputEvents(
const std::vector<UIInputEvent>& events) const {
std::ostringstream stream = {};
stream << "events=[";
for (std::size_t index = 0; index < events.size(); ++index) {
if (index > 0u) {
stream << " | ";
}
const UIInputEvent& event = events[index];
stream << DescribeInputEventType(event)
<< '@'
<< static_cast<int>(event.position.x)
<< ','
<< static_cast<int>(event.position.y);
}
stream << ']';
return stream.str();
}
} // namespace XCEngine::UI::Editor::App