Build XCEditor viewport shell contract foundation
This commit is contained in:
@@ -20,6 +20,7 @@ add_library(XCUIEditorLib STATIC
|
||||
src/Core/UIEditorPanelRegistry.cpp
|
||||
src/Core/UIEditorShortcutManager.cpp
|
||||
src/Core/UIEditorViewportInputBridge.cpp
|
||||
src/Core/UIEditorViewportShell.cpp
|
||||
src/Core/UIEditorWorkspaceLayoutPersistence.cpp
|
||||
src/Core/UIEditorWorkspaceController.cpp
|
||||
src/Core/UIEditorWorkspaceModel.cpp
|
||||
|
||||
57
new_editor/include/XCEditor/Core/UIEditorViewportShell.h
Normal file
57
new_editor/include/XCEditor/Core/UIEditorViewportShell.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Core/UIEditorViewportInputBridge.h>
|
||||
#include <XCEditor/Widgets/UIEditorViewportSlot.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorViewportShellVisualState {
|
||||
std::size_t hoveredToolIndex = Widgets::UIEditorViewportSlotInvalidIndex;
|
||||
std::size_t activeToolIndex = Widgets::UIEditorViewportSlotInvalidIndex;
|
||||
Widgets::UIEditorStatusBarState statusBarState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellSpec {
|
||||
Widgets::UIEditorViewportSlotChrome chrome = {};
|
||||
std::vector<Widgets::UIEditorViewportSlotToolItem> toolItems = {};
|
||||
std::vector<Widgets::UIEditorStatusBarSegment> statusSegments = {};
|
||||
UIEditorViewportInputBridgeConfig inputBridgeConfig = {};
|
||||
UIEditorViewportShellVisualState visualState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellModel {
|
||||
UIEditorViewportShellSpec spec = {};
|
||||
Widgets::UIEditorViewportSlotFrame frame = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellRequest {
|
||||
Widgets::UIEditorViewportSlotLayout slotLayout = {};
|
||||
::XCEngine::UI::UISize requestedViewportSize = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellState {
|
||||
UIEditorViewportInputBridgeState inputBridgeState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellFrame {
|
||||
Widgets::UIEditorViewportSlotLayout slotLayout = {};
|
||||
Widgets::UIEditorViewportSlotState slotState = {};
|
||||
UIEditorViewportInputBridgeFrame inputFrame = {};
|
||||
::XCEngine::UI::UISize requestedViewportSize = {};
|
||||
};
|
||||
|
||||
UIEditorViewportShellRequest ResolveUIEditorViewportShellRequest(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportShellSpec& spec,
|
||||
const Widgets::UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
UIEditorViewportShellFrame UpdateUIEditorViewportShell(
|
||||
UIEditorViewportShellState& state,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportShellModel& model,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
72
new_editor/src/Core/UIEditorViewportShell.cpp
Normal file
72
new_editor/src/Core/UIEditorViewportShell.cpp
Normal 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
|
||||
Reference in New Issue
Block a user