Add shell definition contract
This commit is contained in:
@@ -14,6 +14,12 @@
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorShellInteractionDefinition {
|
||||
UIEditorMenuModel menuModel = {};
|
||||
std::vector<Widgets::UIEditorStatusBarSegment> statusSegments = {};
|
||||
std::vector<UIEditorWorkspacePanelPresentationModel> workspacePresentations = {};
|
||||
};
|
||||
|
||||
struct UIEditorShellInteractionModel {
|
||||
UIEditorResolvedMenuModel resolvedMenuModel = {};
|
||||
std::vector<Widgets::UIEditorStatusBarSegment> statusSegments = {};
|
||||
@@ -41,6 +47,7 @@ struct UIEditorShellInteractionPalette {
|
||||
|
||||
struct UIEditorShellInteractionServices {
|
||||
const UIEditorCommandDispatcher* commandDispatcher = nullptr;
|
||||
const UIEditorShortcutManager* shortcutManager = nullptr;
|
||||
};
|
||||
|
||||
struct UIEditorShellInteractionMenuButtonRequest {
|
||||
@@ -112,6 +119,7 @@ struct UIEditorShellInteractionPopupFrame {
|
||||
};
|
||||
|
||||
struct UIEditorShellInteractionFrame {
|
||||
UIEditorShellInteractionModel model = {};
|
||||
UIEditorShellInteractionRequest request = {};
|
||||
UIEditorShellComposeFrame shellFrame = {};
|
||||
UIEditorWorkspaceInteractionFrame workspaceInteractionFrame = {};
|
||||
@@ -124,6 +132,11 @@ struct UIEditorShellInteractionFrame {
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
UIEditorShellInteractionModel ResolveUIEditorShellInteractionModel(
|
||||
const UIEditorWorkspaceController& controller,
|
||||
const UIEditorShellInteractionDefinition& definition,
|
||||
const UIEditorShellInteractionServices& services = {});
|
||||
|
||||
UIEditorShellInteractionRequest ResolveUIEditorShellInteractionRequest(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorWorkspaceController& controller,
|
||||
@@ -141,6 +154,23 @@ UIEditorShellInteractionFrame UpdateUIEditorShellInteraction(
|
||||
const UIEditorShellInteractionServices& services = {},
|
||||
const UIEditorShellInteractionMetrics& metrics = {});
|
||||
|
||||
UIEditorShellInteractionRequest ResolveUIEditorShellInteractionRequest(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorWorkspaceController& controller,
|
||||
const UIEditorShellInteractionDefinition& definition,
|
||||
const UIEditorShellInteractionState& state = {},
|
||||
const UIEditorShellInteractionMetrics& metrics = {},
|
||||
const UIEditorShellInteractionServices& services = {});
|
||||
|
||||
UIEditorShellInteractionFrame UpdateUIEditorShellInteraction(
|
||||
UIEditorShellInteractionState& state,
|
||||
UIEditorWorkspaceController& controller,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorShellInteractionDefinition& definition,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const UIEditorShellInteractionServices& services = {},
|
||||
const UIEditorShellInteractionMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorShellInteraction(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorShellInteractionFrame& frame,
|
||||
@@ -149,4 +179,11 @@ void AppendUIEditorShellInteraction(
|
||||
const UIEditorShellInteractionPalette& palette = {},
|
||||
const UIEditorShellInteractionMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorShellInteraction(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorShellInteractionFrame& frame,
|
||||
const UIEditorShellInteractionState& state,
|
||||
const UIEditorShellInteractionPalette& palette = {},
|
||||
const UIEditorShellInteractionMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user