Files
XCEngine/new_editor/src/Viewport/UIEditorViewportShell.cpp
ssdfasd 6e9265e92e checkpoint(new_editor): native d3d12 ui path
Key node 1: move main-window UI presentation onto the D3D12 render loop with native UI renderer, text system, and texture host.

Key node 2: wire frame timing/FPS display, window runtime, swapchain presentation, and native screenshot capture around the new path.

Key node 3: carry editor shell/workspace/viewport/panel interaction updates needed by the new renderer and detached window flow.

Key node 4: pump async resource loads and scene bridge follow-up needed for scene content visibility in new_editor.
2026-04-21 20:49:18 +08:00

108 lines
3.7 KiB
C++

#include <XCEditor/Viewport/UIEditorViewportShell.h>
namespace XCEngine::UI::Editor {
namespace {
using Widgets::BuildUIEditorViewportSlotLayout;
using Widgets::UIEditorViewportSlotFrame;
using Widgets::UIEditorViewportSlotLayout;
using Widgets::UIEditorViewportSlotState;
bool ContainsPoint(
const ::XCEngine::UI::UIRect& rect,
const ::XCEngine::UI::UIPoint& point) {
return point.x >= rect.x &&
point.x <= rect.x + rect.width &&
point.y >= rect.y &&
point.y <= rect.y + rect.height;
}
UIEditorViewportSlotLayout BuildViewportShellLayout(
const ::XCEngine::UI::UIRect& bounds,
const UIEditorViewportShellSpec& spec,
const UIEditorViewportSlotFrame& frame,
const Widgets::UIEditorViewportSlotMetrics& metrics) {
return BuildUIEditorViewportSlotLayout(
bounds,
spec.chrome,
frame,
spec.toolItems,
spec.statusSegments,
metrics);
}
UIEditorViewportSlotState BuildViewportShellSlotState(
const UIEditorViewportShellVisualState& visualState,
const UIEditorViewportInputBridgeFrame& inputFrame,
const UIEditorViewportSlotLayout& slotLayout) {
UIEditorViewportSlotState slotState = {};
slotState.focused = inputFrame.focused;
slotState.surfaceHovered =
inputFrame.hasPointerPosition &&
ContainsPoint(slotLayout.inputRect, inputFrame.screenPointerPosition);
slotState.surfaceActive = inputFrame.focused || inputFrame.captured;
slotState.inputCaptured = inputFrame.captured;
slotState.hoveredToolIndex = visualState.hoveredToolIndex;
slotState.activeToolIndex = visualState.activeToolIndex;
slotState.statusBarState = visualState.statusBarState;
slotState.statusBarState.focused =
slotState.statusBarState.focused || inputFrame.focused;
return slotState;
}
} // namespace
UIEditorViewportShellRequest ResolveUIEditorViewportShellRequest(
const ::XCEngine::UI::UIRect& bounds,
const UIEditorViewportShellSpec& spec,
const Widgets::UIEditorViewportSlotMetrics& metrics) {
UIEditorViewportShellRequest request = {};
request.slotLayout = BuildViewportShellLayout(bounds, spec, {}, metrics);
request.requestedViewportSize = request.slotLayout.requestedSurfaceSize;
return request;
}
UIEditorViewportShellFrame UpdateUIEditorViewportShell(
UIEditorViewportShellState& state,
const UIEditorViewportShellRequest& request,
const UIEditorViewportShellModel& model,
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
const UIEditorViewportInputBridgeRequest& inputRequest) {
UIEditorViewportShellFrame frame = {};
frame.slotLayout = request.slotLayout;
frame.requestedViewportSize = request.requestedViewportSize;
frame.inputFrame = UpdateUIEditorViewportInputBridge(
state.inputBridgeState,
frame.slotLayout.bounds,
frame.slotLayout.inputRect,
inputEvents,
model.spec.inputBridgeConfig,
inputRequest);
frame.slotState =
BuildViewportShellSlotState(
model.spec.visualState,
frame.inputFrame,
frame.slotLayout);
return frame;
}
UIEditorViewportShellFrame UpdateUIEditorViewportShell(
UIEditorViewportShellState& state,
const ::XCEngine::UI::UIRect& bounds,
const UIEditorViewportShellModel& model,
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
const Widgets::UIEditorViewportSlotMetrics& metrics,
const UIEditorViewportInputBridgeRequest& inputRequest) {
const UIEditorViewportShellRequest request =
ResolveUIEditorViewportShellRequest(bounds, model.spec, metrics);
return UpdateUIEditorViewportShell(
state,
request,
model,
inputEvents,
inputRequest);
}
} // namespace XCEngine::UI::Editor