Align SRP boundaries and editor windowing

This commit is contained in:
2026-04-26 17:14:32 +08:00
parent a8256b05cd
commit b8599a8aff
38 changed files with 696 additions and 650 deletions

View File

@@ -1,9 +1,9 @@
#include "Platform/Win32/Chrome/EditorWindowChromeController.h"
#include "Platform/Win32/Windowing/EditorWindow.h"
#include "Platform/Win32/Runtime/EditorWindowFrameDriver.h"
#include "Platform/Win32/Runtime/EditorWindowRuntimeController.h"
#include "Platform/Win32/Windowing/EditorWindowSupport.h"
#include "Windowing/Host/EditorWindowHostCoordinator.h"
#include "Windowing/Runtime/EditorWindowRuntimeController.h"
#include <XCEditor/Foundation/UIEditorTheme.h>
#include <XCEngine/UI/DrawData.h>
@@ -250,17 +250,16 @@ void EditorWindowChromeController::InitializeWindowChrome(EditorWindow& window)
bool EditorWindowChromeController::HandleSystemCommand(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive,
EditorWindowHostCoordinator& hostCoordinator,
WPARAM wParam) {
const HWND hwnd = window.GetHwnd();
switch (wParam & 0xFFF0u) {
case SC_MAXIMIZE:
ToggleMaximizeRestore(window, editorContext, globalTabDragActive);
ToggleMaximizeRestore(window, hostCoordinator);
return true;
case SC_RESTORE:
if (hwnd != nullptr && !IsIconic(hwnd)) {
ToggleMaximizeRestore(window, editorContext, globalTabDragActive);
ToggleMaximizeRestore(window, hostCoordinator);
return true;
}
return false;
@@ -338,8 +337,7 @@ bool EditorWindowChromeController::HandleResizeButtonUp(EditorWindow& window) {
bool EditorWindowChromeController::HandleResizePointerMove(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive) {
EditorWindowHostCoordinator& hostCoordinator) {
const HWND hwnd = window.GetHwnd();
if (!IsBorderlessResizeActive() || hwnd == nullptr) {
return false;
@@ -372,10 +370,7 @@ bool EditorWindowChromeController::HandleResizePointerMove(
if (window.ApplyWindowResize(static_cast<UINT>(width), static_cast<UINT>(height))) {
const auto immediateFrameBegin = std::chrono::steady_clock::now();
window.QueueCompletedImmediateFrame(
EditorWindowFrameDriver::DriveImmediateFrame(
window,
editorContext,
globalTabDragActive));
hostCoordinator.DriveImmediateWindowFrame(window));
const auto immediateFrameEnd = std::chrono::steady_clock::now();
MarkPredictedClientPixelSizePresented();
if (IsVerboseResizeTraceEnabled()) {
@@ -535,8 +530,7 @@ bool EditorWindowChromeController::HandleChromeButtonDown(EditorWindow& window,
bool EditorWindowChromeController::HandleChromeButtonUp(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive,
EditorWindowHostCoordinator& hostCoordinator,
LPARAM lParam) {
if (IsBorderlessWindowDragRestoreArmed()) {
ClearChromeDragRestoreState(window);
@@ -554,15 +548,14 @@ bool EditorWindowChromeController::HandleChromeButtonUp(
window.InvalidateHostWindow();
if (pressedTarget == releasedTarget) {
ExecuteChromeAction(window, editorContext, globalTabDragActive, pressedTarget);
ExecuteChromeAction(window, hostCoordinator, pressedTarget);
}
return true;
}
bool EditorWindowChromeController::HandleChromeDoubleClick(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive,
EditorWindowHostCoordinator& hostCoordinator,
LPARAM lParam) {
if (IsBorderlessWindowDragRestoreArmed()) {
ClearChromeDragRestoreState(window);
@@ -574,16 +567,14 @@ bool EditorWindowChromeController::HandleChromeDoubleClick(
ExecuteChromeAction(
window,
editorContext,
globalTabDragActive,
hostCoordinator,
Host::BorderlessWindowChromeHitTarget::MaximizeRestoreButton);
return true;
}
bool EditorWindowChromeController::HandleChromeDragRestorePointerMove(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive) {
EditorWindowHostCoordinator& hostCoordinator) {
const HWND hwnd = window.GetHwnd();
if (!IsBorderlessWindowDragRestoreArmed() || hwnd == nullptr) {
return false;
@@ -647,7 +638,7 @@ bool EditorWindowChromeController::HandleChromeDragRestorePointerMove(
};
SetBorderlessWindowMaximized(false);
ApplyPredictedWindowRectTransition(window, editorContext, globalTabDragActive, targetRect);
ApplyPredictedWindowRectTransition(window, hostCoordinator, targetRect);
ClearChromeDragRestoreState(window);
SendMessageW(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
return true;
@@ -891,8 +882,7 @@ bool EditorWindowChromeController::QueryBorderlessWindowWorkAreaRect(
bool EditorWindowChromeController::ApplyPredictedWindowRectTransition(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive,
EditorWindowHostCoordinator& hostCoordinator,
const RECT& targetRect) {
const HWND hwnd = window.GetHwnd();
if (hwnd == nullptr) {
@@ -908,10 +898,7 @@ bool EditorWindowChromeController::ApplyPredictedWindowRectTransition(
SetPredictedClientPixelSize(static_cast<UINT>(width), static_cast<UINT>(height));
if (window.ApplyWindowResize(static_cast<UINT>(width), static_cast<UINT>(height))) {
window.QueueCompletedImmediateFrame(
EditorWindowFrameDriver::DriveImmediateFrame(
window,
editorContext,
globalTabDragActive));
hostCoordinator.DriveImmediateWindowFrame(window));
MarkPredictedClientPixelSizePresented();
}
SetWindowPos(
@@ -957,8 +944,7 @@ bool EditorWindowChromeController::ApplyWindowTopmost(EditorWindow& window, bool
void EditorWindowChromeController::ToggleMaximizeRestore(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive) {
EditorWindowHostCoordinator& hostCoordinator) {
if (window.GetHwnd() == nullptr) {
return;
}
@@ -973,7 +959,7 @@ void EditorWindowChromeController::ToggleMaximizeRestore(
SetBorderlessWindowRestoreRect(currentRect);
SetBorderlessWindowMaximized(true);
ApplyPredictedWindowRectTransition(window, editorContext, globalTabDragActive, workAreaRect);
ApplyPredictedWindowRectTransition(window, hostCoordinator, workAreaRect);
return;
}
@@ -983,13 +969,12 @@ void EditorWindowChromeController::ToggleMaximizeRestore(
}
SetBorderlessWindowMaximized(false);
ApplyPredictedWindowRectTransition(window, editorContext, globalTabDragActive, restoreRect);
ApplyPredictedWindowRectTransition(window, hostCoordinator, restoreRect);
}
void EditorWindowChromeController::ExecuteChromeAction(
EditorWindow& window,
EditorContext& editorContext,
bool globalTabDragActive,
EditorWindowHostCoordinator& hostCoordinator,
Host::BorderlessWindowChromeHitTarget target) {
const HWND hwnd = window.GetHwnd();
if (hwnd == nullptr) {
@@ -1004,7 +989,7 @@ void EditorWindowChromeController::ExecuteChromeAction(
ShowWindow(hwnd, SW_MINIMIZE);
break;
case Host::BorderlessWindowChromeHitTarget::MaximizeRestoreButton:
ToggleMaximizeRestore(window, editorContext, globalTabDragActive);
ToggleMaximizeRestore(window, hostCoordinator);
break;
case Host::BorderlessWindowChromeHitTarget::CloseButton:
PostMessageW(hwnd, WM_CLOSE, 0, 0);