Add shell definition contract

This commit is contained in:
2026-04-07 12:09:26 +08:00
parent 3def94d0e0
commit fb8ef25ff3
4 changed files with 226 additions and 29 deletions

View File

@@ -232,6 +232,12 @@ bool HasMeaningfulInteractionResult(
!result.commandId.empty();
}
bool ShouldRefreshResolvedShellModel(
const UIEditorShellInteractionResult& result) {
return result.commandDispatched ||
result.workspaceResult.dockHostResult.commandExecuted;
}
BuildRequestOutput BuildRequest(
const UIRect& bounds,
const UIEditorWorkspaceController& controller,
@@ -468,6 +474,23 @@ std::vector<UIInputEvent> FilterWorkspaceInputEvents(
} // namespace
UIEditorShellInteractionModel ResolveUIEditorShellInteractionModel(
const UIEditorWorkspaceController& controller,
const UIEditorShellInteractionDefinition& definition,
const UIEditorShellInteractionServices& services) {
UIEditorShellInteractionModel model = {};
if (services.commandDispatcher != nullptr) {
model.resolvedMenuModel = BuildUIEditorResolvedMenuModel(
definition.menuModel,
*services.commandDispatcher,
controller,
services.shortcutManager);
}
model.statusSegments = definition.statusSegments;
model.workspacePresentations = definition.workspacePresentations;
return model;
}
UIEditorShellInteractionRequest ResolveUIEditorShellInteractionRequest(
const UIRect& bounds,
const UIEditorWorkspaceController& controller,
@@ -728,10 +751,67 @@ UIEditorShellInteractionFrame UpdateUIEditorShellInteraction(
interactionResult.workspaceResult.viewportInputFrame;
interactionResult.consumed =
interactionResult.consumed || interactionResult.workspaceResult.consumed;
frame.model = model;
frame.result = std::move(interactionResult);
return frame;
}
UIEditorShellInteractionRequest ResolveUIEditorShellInteractionRequest(
const UIRect& bounds,
const UIEditorWorkspaceController& controller,
const UIEditorShellInteractionDefinition& definition,
const UIEditorShellInteractionState& state,
const UIEditorShellInteractionMetrics& metrics,
const UIEditorShellInteractionServices& services) {
const UIEditorShellInteractionModel model =
ResolveUIEditorShellInteractionModel(controller, definition, services);
return ResolveUIEditorShellInteractionRequest(
bounds,
controller,
model,
state,
metrics,
services);
}
UIEditorShellInteractionFrame UpdateUIEditorShellInteraction(
UIEditorShellInteractionState& state,
UIEditorWorkspaceController& controller,
const UIRect& bounds,
const UIEditorShellInteractionDefinition& definition,
const std::vector<UIInputEvent>& inputEvents,
const UIEditorShellInteractionServices& services,
const UIEditorShellInteractionMetrics& metrics) {
UIEditorShellInteractionModel model =
ResolveUIEditorShellInteractionModel(controller, definition, services);
UIEditorShellInteractionFrame frame =
UpdateUIEditorShellInteraction(
state,
controller,
bounds,
model,
inputEvents,
services,
metrics);
if (!ShouldRefreshResolvedShellModel(frame.result)) {
return frame;
}
UIEditorShellInteractionModel refreshedModel =
ResolveUIEditorShellInteractionModel(controller, definition, services);
UIEditorShellInteractionFrame refreshedFrame =
UpdateUIEditorShellInteraction(
state,
controller,
bounds,
refreshedModel,
{},
services,
metrics);
refreshedFrame.result = frame.result;
return refreshedFrame;
}
void AppendUIEditorShellInteraction(
::XCEngine::UI::UIDrawList& drawList,
const UIEditorShellInteractionFrame& frame,
@@ -773,4 +853,19 @@ void AppendUIEditorShellInteraction(
}
}
void AppendUIEditorShellInteraction(
::XCEngine::UI::UIDrawList& drawList,
const UIEditorShellInteractionFrame& frame,
const UIEditorShellInteractionState& state,
const UIEditorShellInteractionPalette& palette,
const UIEditorShellInteractionMetrics& metrics) {
AppendUIEditorShellInteraction(
drawList,
frame,
frame.model,
state,
palette,
metrics);
}
} // namespace XCEngine::UI::Editor