Refine new_editor scene viewport flow

This commit is contained in:
2026-04-18 23:56:17 +08:00
parent f544b2792b
commit 7dfdda2b11
15 changed files with 1425 additions and 296 deletions

View File

@@ -15,9 +15,6 @@ namespace {
using ::XCEngine::UI::Editor::BuildEditorShellShortcutManager;
using ::XCEngine::UI::Editor::UIEditorWorkspacePanelPresentationModel;
using ::XCEngine::UI::Editor::Widgets::UIEditorViewportSlotToolItem;
using ::XCEngine::UI::Editor::Widgets::UIEditorViewportSlotToolSlot;
std::string ComposeStatusText(
std::string_view status,
std::string_view message) {
@@ -44,52 +41,6 @@ UIEditorWorkspacePanelPresentationModel* FindMutablePresentation(
return nullptr;
}
UIEditorViewportSlotToolItem BuildSceneToolItem(
std::string itemId,
std::string label,
UIEditorViewportSlotToolSlot slot,
bool selected,
float desiredWidth) {
UIEditorViewportSlotToolItem item = {};
item.itemId = std::move(itemId);
item.label = std::move(label);
item.slot = slot;
item.enabled = true;
item.selected = selected;
item.desiredWidth = desiredWidth;
return item;
}
std::vector<UIEditorViewportSlotToolItem> BuildSceneViewportTopBarItems(
const EditorSceneRuntime& sceneRuntime) {
return {
BuildSceneToolItem(
"scene.pivot.pivot",
"Pivot",
UIEditorViewportSlotToolSlot::Leading,
sceneRuntime.GetToolPivotMode() == SceneToolPivotMode::Pivot,
52.0f),
BuildSceneToolItem(
"scene.pivot.center",
"Center",
UIEditorViewportSlotToolSlot::Leading,
sceneRuntime.GetToolPivotMode() == SceneToolPivotMode::Center,
58.0f),
BuildSceneToolItem(
"scene.space.world",
"World",
UIEditorViewportSlotToolSlot::Leading,
sceneRuntime.GetToolSpaceMode() == SceneToolSpaceMode::World,
58.0f),
BuildSceneToolItem(
"scene.space.local",
"Local",
UIEditorViewportSlotToolSlot::Leading,
sceneRuntime.GetToolSpaceMode() == SceneToolSpaceMode::Local,
56.0f)
};
}
} // namespace
bool EditorContext::Initialize(const std::filesystem::path& repoRoot) {
@@ -214,13 +165,14 @@ UIEditorShellInteractionDefinition EditorContext::BuildShellDefinition(
if (UIEditorWorkspacePanelPresentationModel* scenePresentation =
FindMutablePresentation(definition.workspacePresentations, kScenePanelId);
scenePresentation != nullptr) {
scenePresentation->viewportShellModel.spec.chrome.showTopBar = true;
scenePresentation->viewportShellModel.spec.toolItems =
BuildSceneViewportTopBarItems(m_sceneRuntime);
scenePresentation->viewportShellModel.spec.chrome.showTopBar = false;
scenePresentation->viewportShellModel.spec.chrome.title = {};
scenePresentation->viewportShellModel.spec.chrome.subtitle = {};
scenePresentation->viewportShellModel.spec.toolItems.clear();
scenePresentation->viewportShellModel.spec.visualState.hoveredToolIndex =
m_sceneRuntime.GetToolState().toolbarHoveredIndex;
Widgets::UIEditorViewportSlotInvalidIndex;
scenePresentation->viewportShellModel.spec.visualState.activeToolIndex =
m_sceneRuntime.GetToolState().toolbarActiveIndex;
Widgets::UIEditorViewportSlotInvalidIndex;
}
return definition;