73 lines
2.7 KiB
C++
73 lines
2.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;
|
|
|
|
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
|