diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp index 024300c0d..a42971b6d 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp +++ b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp @@ -4445,7 +4445,8 @@ bool web_engine_blend_main_edit_editor_context(WebBlendMainState *state, * show_one_level). They rewrite TSE_CLOSED on the whole tree. */ const std::string operation = edit.value("operation", ""); if (operation != "EXPANDED_TOGGLE" && operation != "SHOW_HIERARCHY" && - operation != "SHOW_ONE_LEVEL" && operation != "HIDE_ONE_LEVEL") { + operation != "SHOW_ONE_LEVEL" && operation != "HIDE_ONE_LEVEL" && + operation != "SHOW_ACTIVE") { error = "EDITOR_DATA_INVALID: unsupported Outliner view operation"; return false; } @@ -4453,6 +4454,7 @@ bool web_engine_blend_main_edit_editor_context(WebBlendMainState *state, if (!refresh_outliner_tree(C, native_desktop)) return false; const char *operator_id = operation == "EXPANDED_TOGGLE" ? "OUTLINER_OT_expanded_toggle" : operation == "SHOW_HIERARCHY" ? "OUTLINER_OT_show_hierarchy" + : operation == "SHOW_ACTIVE" ? "OUTLINER_OT_show_active" : "OUTLINER_OT_show_one_level"; if (!WM_operatortype_find(operator_id, true) && area->type && area->type->operatortypes) { area->type->operatortypes(); @@ -4483,6 +4485,7 @@ bool web_engine_blend_main_edit_editor_context(WebBlendMainState *state, if (feedback) { *feedback = operation == "EXPANDED_TOGGLE" ? "已展开或折叠全部" : operation == "SHOW_HIERARCHY" ? "已显示对象层级" + : operation == "SHOW_ACTIVE" ? "已显示活动对象" : operation == "SHOW_ONE_LEVEL" ? "已展开一层" : "已折叠一层"; } focus_outliner_region(C, native_desktop); diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index 665f65dfc..c64b0aa3f 100644 --- a/tools/web/check-outliner-headed.mjs +++ b/tools/web/check-outliner-headed.mjs @@ -19,7 +19,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); -const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web"]; +const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web", "outliner-show-active-web"]; /* Desktop Layout geometry the metrics case must reproduce (batch 2: UI sizes). */ const GEOMETRY_GOLDEN = path.join(REPO_ROOT, "tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json"); const errors = []; diff --git a/tools/web/run-outliner-headed.mjs b/tools/web/run-outliner-headed.mjs index 4de926e36..a0aa0564c 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -60,6 +60,7 @@ const KNOWN_CASES = [ { id: "outliner-collection-instance-web", title: /\[outliner-collection-instance-web\]/ }, { id: "outliner-collection-color-tag-web", title: /\[outliner-collection-color-tag-web\]/ }, { id: "outliner-view-ops-web", title: /\[outliner-view-ops-web\]/ }, + { id: "outliner-show-active-web", title: /\[outliner-show-active-web\]/ }, ]; function usage() { diff --git a/web/app/public/vendor/blender/web_engine.wasm b/web/app/public/vendor/blender/web_engine.wasm index e0f74576e..0fed0fae4 100644 Binary files a/web/app/public/vendor/blender/web_engine.wasm and b/web/app/public/vendor/blender/web_engine.wasm differ diff --git a/web/app/public/wasm-module-manifest.json b/web/app/public/wasm-module-manifest.json index 0d4782127..f5d2060c6 100644 --- a/web/app/public/wasm-module-manifest.json +++ b/web/app/public/wasm-module-manifest.json @@ -10,7 +10,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "6caf556361e813ffe2323a2ce531a36dc61533ff899fbb861be03abc47660985" + "sha256": "79d319aa0ba79ba7f1e34909a1c655680d9721a0f85d3ab85b8700753507babf" }, "pthread": { "fileName": "web_engine.wasm", @@ -27,7 +27,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "6caf556361e813ffe2323a2ce531a36dc61533ff899fbb861be03abc47660985" + "sha256": "79d319aa0ba79ba7f1e34909a1c655680d9721a0f85d3ab85b8700753507babf" }, "pthread": { "fileName": "web_engine.wasm", @@ -44,7 +44,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "6caf556361e813ffe2323a2ce531a36dc61533ff899fbb861be03abc47660985" + "sha256": "79d319aa0ba79ba7f1e34909a1c655680d9721a0f85d3ab85b8700753507babf" }, "pthread": { "fileName": "web_engine.wasm", @@ -61,7 +61,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "6caf556361e813ffe2323a2ce531a36dc61533ff899fbb861be03abc47660985" + "sha256": "79d319aa0ba79ba7f1e34909a1c655680d9721a0f85d3ab85b8700753507babf" }, "pthread": { "fileName": "web_engine.wasm", diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index bc76e8d20..19fba56db 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2541,7 +2541,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o onSetRestrictColumns?: (columns: NativeOutlinerRestrict, areaId?: string) => void; onSelectBox?: (firstRowId: string, lastRowId: string, mode: 'SET' | 'ADD' | 'SUB' | 'XOR', areaId: string) => void; onIdOperation?: (rowId: string, operation: 'UNLINK' | 'SINGLE' | 'LOCAL' | 'SELECT_HIERARCHY' | 'SELECT' | 'DESELECT' | 'COPY' | 'PASTE' | 'FAKE_ADD' | 'FAKE_CLEAR' | 'ASSET_MARK' | 'ASSET_CLEAR' | 'ASSET_CLEAR_FAKE' | 'LIBOVERRIDE_MAKE' | 'LIBOVERRIDE_RESET' | 'LIBOVERRIDE_CLEAR' | 'COLLECTION_NEW' | 'COLLECTION_SELECT' | 'COLLECTION_DESELECT' | 'COLLECTION_DUPLICATE' | 'COLLECTION_DUPLICATE_LINKED' | 'COLLECTION_INSTANCE' | 'COLLECTION_COLOR_TAG' | 'PURGE', areaId: string, colorTag?: 'NONE' | 'COLOR_01' | 'COLOR_02' | 'COLOR_03' | 'COLOR_04' | 'COLOR_05' | 'COLOR_06' | 'COLOR_07' | 'COLOR_08') => void; - onViewOperation?: (operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL', areaId: string) => void; + onViewOperation?: (operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL' | 'SHOW_ACTIVE', areaId: string) => void; onModeToggle?: (rowId: string, extend: boolean, areaId: string) => void; onReparent?: (objectIds: string[], parentId: string | null, keepTransform: boolean) => void; onMoveToCollection?: (objectIds: string[], collectionId: string, keepExistingLinks: boolean) => void; @@ -2856,6 +2856,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o /* Desktop OUTLINER_MT_context_menu_view (space_outliner.py): Show Active / Expand-Collapse All / Show Hierarchy / One Level. */ {label: '视图 (View)', disabled: treeRenameBusy || remapBusy || !onViewOperation || !nativeArea, reason: '树形显示操作(桌面 OUTLINER_MT_context_menu_view)', children: [ + {label: '显示活动 (Show Active)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ACTIVE', nativeArea.id); }}, {label: '展开/折叠全部 (Expand/Collapse All)', action: () => { if (nativeArea) onViewOperation?.('EXPANDED_TOGGLE', nativeArea.id); }}, {label: '显示层级 (Show Object Hierarchy)', action: () => { if (nativeArea) onViewOperation?.('SHOW_HIERARCHY', nativeArea.id); }}, {label: '展开一层 (Show One Level)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ONE_LEVEL', nativeArea.id); }}, @@ -6462,7 +6463,7 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A screenId: nativeWorkspace.screenId, areaId: outlinerArea.id, rowId, operation, ...(colorTag ? { colorTag } : {}) } }); }; - const setOutlinerViewOperation = (operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL', areaId: string): void => { + const setOutlinerViewOperation = (operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL' | 'SHOW_ACTIVE', areaId: string): void => { const workflow = snapshot?.editorWorkflow; const nativeWorkspace = workflow?.workspaces.find(item => item.id === workflow.context.workspaceId); const outlinerArea = nativeWorkspace?.areas.find(item => item.editor === 'OUTLINER' && @@ -6473,7 +6474,21 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A } void applyEditCommand({ type: 'editEditorContext', baseRevision: snapshot.revision, edit: { action: 'OUTLINER_VIEW_OPERATION', workspaceId: nativeWorkspace.id, - screenId: nativeWorkspace.screenId, areaId: outlinerArea.id, operation } }); + screenId: nativeWorkspace.screenId, areaId: outlinerArea.id, operation } }, + operation === 'SHOW_ACTIVE' ? (applied) => { + /* Desktop centers the native region on the active row; the web tree is + * DOM-rendered, so scroll the active object's row into view once the + * expansion snapshot has rendered. */ + const target = applied.activeObjectId; + if (!target) return; + const deadline = Date.now() + 1500; + const scroll = () => { + const row = document.querySelector(`.outliner-tree .tree-row[data-node-id="${CSS.escape(target)}"]`); + if (row) row.scrollIntoView({ block: 'center', inline: 'nearest' }); + else if (Date.now() < deadline) requestAnimationFrame(scroll); + }; + requestAnimationFrame(scroll); + } : undefined); }; const setOutlinerRestrictColumns = (columns: NativeOutlinerRestrict, areaId?: string): void => { const workflow = snapshot?.editorWorkflow; diff --git a/web/app/src/vendor/blender/web_engine.wasm b/web/app/src/vendor/blender/web_engine.wasm index e0f74576e..0fed0fae4 100644 Binary files a/web/app/src/vendor/blender/web_engine.wasm and b/web/app/src/vendor/blender/web_engine.wasm differ diff --git a/web/app/src/workers/web-engine.worker.ts b/web/app/src/workers/web-engine.worker.ts index a2bcda6da..6a3fcf7d9 100644 --- a/web/app/src/workers/web-engine.worker.ts +++ b/web/app/src/workers/web-engine.worker.ts @@ -1532,7 +1532,7 @@ function assertFutureCapability(payload: Extract item.kind === 'MAIN' && item.visible) || - !['EXPANDED_TOGGLE', 'SHOW_HIERARCHY', 'SHOW_ONE_LEVEL', 'HIDE_ONE_LEVEL'].includes(edit.operation)) { + !['EXPANDED_TOGGLE', 'SHOW_HIERARCHY', 'SHOW_ONE_LEVEL', 'HIDE_ONE_LEVEL', 'SHOW_ACTIVE'].includes(edit.operation)) { throw report('EDITOR_LAYOUT_INVALID', 'Native Outliner view operation requires a current visible tree'); } return; diff --git a/web/protocol/editor-workflow.ts b/web/protocol/editor-workflow.ts index 9f5c6ca06..dfe2ec5dd 100644 --- a/web/protocol/editor-workflow.ts +++ b/web/protocol/editor-workflow.ts @@ -468,7 +468,7 @@ export type EditorContextEdit = { workspaceId: string; screenId: string } & ( | { action: 'OUTLINER_SET_DISPLAY_MODE'; areaId: string; displayMode: string } | { action: 'OUTLINER_SET_FILTER'; areaId: string; filter: NativeOutlinerFilter } | { action: 'OUTLINER_SET_SYNC_SELECT'; areaId: string; sync: boolean } - | { action: 'OUTLINER_VIEW_OPERATION'; areaId: string; operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL' } + | { action: 'OUTLINER_VIEW_OPERATION'; areaId: string; operation: 'EXPANDED_TOGGLE' | 'SHOW_HIERARCHY' | 'SHOW_ONE_LEVEL' | 'HIDE_ONE_LEVEL' | 'SHOW_ACTIVE' } | { action: 'OUTLINER_SET_RESTRICTION'; areaId: string; rowId: string; column: keyof NativeOutlinerRestrict; value: boolean; extend: boolean; isolate: boolean } | { action: 'OUTLINER_SET_RESTRICT_COLUMNS'; areaId: string; columns: NativeOutlinerRestrict } | { action: "SET_EDITOR_TYPE"; areaId: string; editorType: string } diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index 6dcd8d42f..b1489d047 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -1156,4 +1156,28 @@ test.describe("Outliner headed baseline", () => { await viewOperation("折叠一层 (Hide One Level)"); await expect(keyLightRow).toHaveCount(0, { timeout: 30_000 }); }); + + test("[outliner-show-active-web] the Data menu reveals the active object", async ({ page }) => { + test.setTimeout(180_000); + await page.goto("/?ui=web"); + const status = page.locator('[data-testid="engine-status"]'); + await page.locator('[data-testid="blend-file-input"]').setInputFiles(HIERARCHY_SCENE); + await expect(page.locator(".blender-app")).toHaveAttribute("data-project-id", /.+/, { timeout: 60_000 }); + await expect(page.getByText(/Engine: SceneIR/).first()).toBeVisible({ timeout: 60_000 }); + const webTools = page.locator('[data-testid="native-web-tools-toggle"]'); + if (await webTools.count()) await webTools.click(); + const payloadRow = page.locator('.tree-row[aria-label="Payload"]'); + await expect(page.locator('.tree-row[aria-label="Scene Collection"]').first()).toBeVisible({ timeout: 30_000 }); + /* The fixture's active object is Payload; it sits under Mount and the + * object rows start closed, so its row is not in the tree yet. */ + await expect(payloadRow).toHaveCount(0); + + /* Desktop OUTLINER_OT_show_active opens the active object's path and + * centers the view on its row (outliner_edit.cc outliner_show_active_exec). */ + await page.getByRole("button", { name: "Data", exact: true }).click(); + await page.getByRole("menuitem", { name: "视图 (View)", exact: true }).click(); + await page.getByRole("menuitem", { name: "显示活动 (Show Active)", exact: true }).click(); + await expect(payloadRow.first()).toBeVisible({ timeout: 30_000 }); + await expect(payloadRow.first()).toHaveAttribute("data-selected", "true"); + }); });