Build XCEditor viewport shell contract foundation

This commit is contained in:
2026-04-07 05:33:27 +08:00
parent a53f47e561
commit 044240d2f1
11 changed files with 1141 additions and 1 deletions

View File

@@ -0,0 +1,72 @@
#include <XCEditor/Core/UIEditorViewportShell.h>
namespace XCEngine::UI::Editor {
namespace {
using Widgets::BuildUIEditorViewportSlotLayout;
using Widgets::UIEditorViewportSlotFrame;
using Widgets::UIEditorViewportSlotLayout;
using Widgets::UIEditorViewportSlotState;
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) {
UIEditorViewportSlotState slotState = {};
slotState.focused = inputFrame.focused;
slotState.surfaceHovered = inputFrame.hovered;
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 ::XCEngine::UI::UIRect& bounds,
const UIEditorViewportShellModel& model,
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
const Widgets::UIEditorViewportSlotMetrics& metrics) {
UIEditorViewportShellFrame frame = {};
frame.slotLayout = BuildViewportShellLayout(bounds, model.spec, model.frame, metrics);
frame.requestedViewportSize = frame.slotLayout.requestedSurfaceSize;
frame.inputFrame = UpdateUIEditorViewportInputBridge(
state.inputBridgeState,
frame.slotLayout.inputRect,
inputEvents,
model.spec.inputBridgeConfig);
frame.slotState = BuildViewportShellSlotState(model.spec.visualState, frame.inputFrame);
return frame;
}
} // namespace XCEngine::UI::Editor