checkpoint: commit current workspace state

This commit is contained in:
2026-04-25 16:11:01 +08:00
parent 6d43fe5a7d
commit 6002d86a7e
449 changed files with 11303 additions and 100602 deletions

View File

@@ -2,12 +2,12 @@
#include "Bootstrap/EditorResources.h"
#include "System/SystemInteractionService.h"
#include "Composition/EditorContext.h"
#include "Platform/Win32/Windowing/EditorWindowManager.h"
#include "Platform/Win32/Windowing/EditorWindow.h"
#include "Platform/Win32/Content/EditorWorkspaceWindowContentController.h"
#include "Composition/EditorWindowApplicationComposition.h"
#include "Platform/Win32/System/Win32SystemInteractionHost.h"
#include "Support/EnvironmentFlags.h"
#include "Support/ExecutablePath.h"
#include "Platform/Win32/Windowing/EditorWindowPlatformRuntime.h"
#include "Platform/Win32/Windowing/Win32WindowApplicationRuntime.h"
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
#include <XCEngine/Core/Asset/ResourceManager.h>
@@ -123,35 +123,46 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
hostConfig.windowStyle = kBorderlessWindowStyle;
hostConfig.primaryWindowTitle = kWindowTitle;
hostConfig.windowUserData = this;
m_windowManager = std::make_unique<App::EditorWindowManager>(
auto platformRuntime = std::make_unique<App::EditorWindowPlatformRuntime>(
hostConfig,
m_repoRoot,
*m_editorContext);
App::EditorWindowHostAdapters hostAdapters =
platformRuntime->CreateWindowHostAdapters();
m_windowApplicationComposition =
std::make_unique<App::EditorWindowApplicationComposition>(
kWindowTitle,
hostAdapters,
*m_editorContext);
m_windowRuntime = std::make_unique<App::Win32WindowApplicationRuntime>(
std::move(platformRuntime),
m_windowApplicationComposition->GetRuntime(),
*m_editorContext);
m_editorContext->SetExitRequestHandler([this]() {
if (m_windowManager == nullptr) {
if (m_windowRuntime == nullptr) {
return;
}
if (App::EditorWindow* primaryWindow = m_windowManager->FindPrimaryWindow();
primaryWindow != nullptr &&
primaryWindow->GetHwnd() != nullptr) {
PostMessageW(primaryWindow->GetHwnd(), WM_CLOSE, 0, 0);
}
m_windowRuntime->RequestClosePrimaryWindow();
});
m_editorContext->SetReadyStatus();
App::EditorWindowManager::CreateParams createParams = {};
App::EditorWindowCreateParams createParams = {};
createParams.windowId = "main";
createParams.windowType =
::XCEngine::UI::Editor::Windowing::Domain::WindowType::PrimaryWorkspace;
createParams.title = kWindowTitle;
createParams.showCommand = nCmdShow;
createParams.primary = true;
createParams.autoCaptureOnStartup =
App::IsEnvironmentFlagEnabled("XCUI_AUTO_CAPTURE_ON_STARTUP");
if (m_windowManager->CreateEditorWindow(
App::CreateEditorWorkspaceWindowContentController(
m_editorContext->BuildWorkspaceController()),
createParams) == nullptr) {
if (!m_windowRuntime->CreateWindowHost(
App::EditorWorkspaceWindowContentSpec{
.workspaceController = m_editorContext->BuildWorkspaceController(),
},
createParams)) {
AppendUIEditorRuntimeTrace("app", "primary window creation failed");
return false;
}
@@ -163,21 +174,36 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
void Application::Shutdown() {
AppendUIEditorRuntimeTrace("app", "shutdown begin");
if (m_windowManager != nullptr) {
m_windowManager->Shutdown();
m_windowManager.reset();
if (m_windowRuntime != nullptr) {
AppendUIEditorRuntimeTrace("app", "shutdown stage=WindowManager begin");
m_windowRuntime->Shutdown();
m_windowRuntime.reset();
AppendUIEditorRuntimeTrace("app", "shutdown stage=WindowManager end");
}
if (m_windowApplicationComposition != nullptr) {
AppendUIEditorRuntimeTrace("app", "shutdown stage=WindowApplicationComposition begin");
m_windowApplicationComposition.reset();
AppendUIEditorRuntimeTrace("app", "shutdown stage=WindowApplicationComposition end");
}
if (m_editorContext != nullptr) {
AppendUIEditorRuntimeTrace("app", "shutdown stage=EditorContext begin");
m_editorContext->SetSystemInteractionHost(nullptr);
AppendUIEditorRuntimeTrace("app", "shutdown stage=EditorContext end");
}
AppendUIEditorRuntimeTrace("app", "shutdown stage=SystemInteractionHost begin");
m_systemInteractionHost.reset();
AppendUIEditorRuntimeTrace("app", "shutdown stage=SystemInteractionHost end");
AppendUIEditorRuntimeTrace("app", "shutdown stage=ResourceManager begin");
::XCEngine::Resources::ResourceManager::Get().Shutdown();
AppendUIEditorRuntimeTrace("app", "shutdown stage=ResourceManager end");
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
AppendUIEditorRuntimeTrace("app", "shutdown stage=UnregisterClass begin");
UnregisterClassW(kWindowClassName, m_hInstance);
m_windowClassAtom = 0;
AppendUIEditorRuntimeTrace("app", "shutdown stage=UnregisterClass end");
}
AppendUIEditorRuntimeTrace("app", "shutdown end");
@@ -229,17 +255,21 @@ int Application::Run(HINSTANCE hInstance, int nCmdShow) {
TranslateMessage(&message);
DispatchMessageW(&message);
if (m_windowRuntime != nullptr) {
m_windowRuntime->PumpFrames(
App::EditorWindowFramePumpMode::AfterMessage);
}
++processedMessageCount;
}
if (m_windowManager != nullptr) {
if (m_windowRuntime != nullptr) {
::XCEngine::Resources::ResourceManager::Get().UpdateAsyncLoads();
m_windowManager->DestroyClosedWindows();
if (!m_windowManager->HasWindows()) {
m_windowRuntime->DestroyClosedWindows();
if (!m_windowRuntime->HasWindows()) {
break;
}
m_windowManager->RenderAllWindows();
m_windowRuntime->PumpFrames(App::EditorWindowFramePumpMode::SteadyTick);
} else {
break;
}
@@ -326,8 +356,8 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP
? reinterpret_cast<Application*>(createStruct->lpCreateParams)
: nullptr;
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(application));
if (application != nullptr && application->m_windowManager != nullptr) {
application->m_windowManager->HandlePendingNativeWindowCreated(hwnd);
if (application != nullptr && application->m_windowRuntime != nullptr) {
application->m_windowRuntime->HandlePendingNativeWindowCreated(hwnd);
}
return TRUE;
}
@@ -335,8 +365,8 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP
Application* application = GetApplicationFromWindowUserData(hwnd);
LRESULT dispatcherResult = 0;
if (application != nullptr &&
application->m_windowManager != nullptr &&
application->m_windowManager->TryDispatchWindowMessage(
application->m_windowRuntime != nullptr &&
application->m_windowRuntime->TryDispatchWindowMessage(
hwnd,
message,
wParam,
@@ -350,3 +380,4 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP
} // namespace XCEngine::UI::Editor