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 7f2bf2b53..024b2c36e 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 @@ -3702,6 +3702,30 @@ static const char *web_outliner_object_mode_identifier(const eObjectMode mode) return "OBJECT"; } +/* ui::icon_from_library (interface_icons.cc) draws the link / package / broken + * / override marker on Outliner ID rows (outliner_draw.cc). The web row carries + * the same identifier so the React row can draw its badge. */ +static const char *web_outliner_library_icon(const ID &id) +{ + if (ID_IS_LINKED(&id)) { + if (ID_IS_PACKED(&id)) { + return (id.tag & ID_TAG_INDIRECT) ? "PACKAGE_INDIRECT" : "PACKAGE"; + } + if (id.tag & ID_TAG_MISSING) return "BROKEN"; + if (id.tag & ID_TAG_INDIRECT) return "INDIRECT"; + return "DIRECT"; + } + if (ID_IS_OVERRIDE_LIBRARY(&id)) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(&id) || + (id.override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) != 0) { + return "OVERRIDE_NONEDITABLE"; + } + return "OVERRIDE"; + } + if (ID_IS_ASSET(&id)) return "ASSET"; + return ""; +} + /* Desktop display-mode menu order and identifiers * (rna_def_space_outliner()::display_mode_items). */ struct WebOutlinerDisplayMode { @@ -11788,6 +11812,13 @@ bool web_engine_blend_main_merge_editor_snapshot(WebBlendMainState *state, * OUTLINER_OT_scene_operation (outliner_tools.cc). */ kind = "scene"; } + /* Desktop draws the marker only on ID / layer-collection element + * types (outliner_draw.cc ELEM(tselem->type, TSE_SOME_ID, + * TSE_LAYER_COLLECTION, TSE_LINKED_NODE_TREE)); other types + * (e.g. TSE_ID_BASE groups in Unused Data) carry no ID pointer. */ + const char *library_icon = store->id && + ELEM(store->type, TSE_SOME_ID, TSE_LAYER_COLLECTION, TSE_LINKED_NODE_TREE) ? + web_outliner_library_icon(*store->id) : ""; rows.push_back({{"id", key}, {"label", te.name ? te.name : ""}, {"depth", depth}, {"selected", bool(store->flag & TSE_SELECTED)}, {"active", bool(store->flag & TSE_ACTIVE)}, @@ -11821,6 +11852,8 @@ bool web_engine_blend_main_merge_editor_snapshot(WebBlendMainState *state, * id_type_is_supported() allows; desktop greys the menu item out. */ {"assetSupported", store->type == TSE_SOME_ID && store->id ? json(bool(ed::asset::id_type_is_supported(store->id))) : json(nullptr)}, + /* ui::icon_from_library's row marker (outliner_draw.cc). */ + {"libraryIcon", *library_icon ? json(library_icon) : json(nullptr)}, /* Library override entries only apply to linked data or * existing overrides (space_outliner.py OUTLINER_MT_liboverride). */ {"linked", store->type == TSE_SOME_ID && store->id ? diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index 674513f04..09c052193 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", "outliner-show-active-web", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web", "outliner-menu-structure-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", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web", "outliner-menu-structure-web", "outliner-linked-icons-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 88ab9c5db..821c601ce 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -76,6 +76,7 @@ const KNOWN_CASES = [ { id: "outliner-liboverride-troubleshoot-web", title: /\[outliner-liboverride-troubleshoot-web\]/ }, { id: "outliner-row-type-menus-web", title: /\[outliner-row-type-menus-web\]/ }, { id: "outliner-menu-structure-web", title: /\[outliner-menu-structure-web\]/ }, + { id: "outliner-linked-icons-web", title: /\[outliner-linked-icons-web\]/ }, ]; function usage() { diff --git a/web/app/public/vendor/blender/web_engine.wasm b/web/app/public/vendor/blender/web_engine.wasm index fe28aa96a..e29fddd4d 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 cc2ee0f9f..1797649b4 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": "e6ac6677f0be4d3440e182ba53aecf862fbf7765a3a63cf0228eab9ebc5ac850" + "sha256": "70c0757fe91848322704d746a93ca643346a69368737796618448da50748356e" }, "pthread": { "fileName": "web_engine.wasm", @@ -27,7 +27,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "e6ac6677f0be4d3440e182ba53aecf862fbf7765a3a63cf0228eab9ebc5ac850" + "sha256": "70c0757fe91848322704d746a93ca643346a69368737796618448da50748356e" }, "pthread": { "fileName": "web_engine.wasm", @@ -44,7 +44,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "e6ac6677f0be4d3440e182ba53aecf862fbf7765a3a63cf0228eab9ebc5ac850" + "sha256": "70c0757fe91848322704d746a93ca643346a69368737796618448da50748356e" }, "pthread": { "fileName": "web_engine.wasm", @@ -61,7 +61,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "e6ac6677f0be4d3440e182ba53aecf862fbf7765a3a63cf0228eab9ebc5ac850" + "sha256": "70c0757fe91848322704d746a93ca643346a69368737796618448da50748356e" }, "pthread": { "fileName": "web_engine.wasm", diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index b0e2bbde6..9b412875b 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2522,6 +2522,18 @@ const OUTLINER_RESTRICT_POPOVER_LABELS: Record = { + DIRECT: ['⛓', '直接链接数据'], + INDIRECT: ['⛓', '间接链接数据'], + PACKAGE: ['▦', '打包链接数据'], + PACKAGE_INDIRECT: ['▦', '间接打包链接数据'], + BROKEN: ['⚠', '损坏的链接数据'], + OVERRIDE: ['◈', '库覆盖数据'], + OVERRIDE_NONEDITABLE: ['◈', '不可编辑的库覆盖'], + ASSET: ['◆', '资产数据'], +}; function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onToggleExpand, onTreeSelect, onRemap, onSetDisplayMode, onSetFilter, onSetSyncSelect, onSetLibOverrideViewMode, onSetIdTypeFilter, onSetActiveKeyingset, onSelectAll, onSetRestriction, onSetRestrictColumns, onReparent, onMoveToCollection, onMoveCollection, onDeleteObject, onDeleteCollection, onSelectBox, onIdOperation, onRelocate, onLibOperation, onSceneOperation, onLibraryRelocate, onLiboverrideTroubleshoot, onModeToggle, onViewOperation, onEditOperation }: { snapshot: SceneSnapshotIR | null; onSelect: (id: string, additive: boolean, range: boolean) => void; @@ -3408,6 +3420,10 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onToggleExpa {treeRenameError ? {treeRenameError} : null} : { event.stopPropagation(); beginTreeRename(row); }}>{row.label}} + {row.libraryIcon && OUTLINER_LIBRARY_BADGES[row.libraryIcon] ? {OUTLINER_LIBRARY_BADGES[row.libraryIcon][0]} : null} {row.asset === true ? ◆ : null} {/* Desktop's fake-user toggle (outliner_draw.cc * restrictbutton_id_user_toggle): drawn on ID rows, red when the diff --git a/web/app/src/app/app-shell.css b/web/app/src/app/app-shell.css index 056732304..cc2d8ed5a 100644 --- a/web/app/src/app/app-shell.css +++ b/web/app/src/app/app-shell.css @@ -177,6 +177,11 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- .tree-fake-user { width: 14px; min-width: 14px; height: 18px; padding: 0; color: #6f6f6f; background: transparent; border: 0; border-radius: 2px; font-size: 9px; line-height: 18px; } /* Desktop draws the asset marker on ID rows that are registered assets. */ .tree-asset { width: 12px; min-width: 12px; color: #74a7ff; font-size: 8px; line-height: 18px; text-align: center; } +/* ui::icon_from_library link / package / broken / override marker. */ +.tree-library-icon { margin-left: 3px; font-size: 10px; line-height: 18px; color: #c9a14a; } +.tree-library-icon.indirect, .tree-library-icon.package_indirect, .tree-library-icon.override_noneditatable { opacity: .55; } +.tree-library-icon.broken { color: #e06c6c; } +.tree-library-icon.asset { color: #74a7ff; } .tree-fake-user:hover { color: #fff; background: #4a4a4a; } .tree-fake-user[aria-pressed="true"] { color: #dcdcdc; background: #2f2f2f; } .tree-fake-user:disabled { opacity: 0.4; } diff --git a/web/app/src/vendor/blender/web_engine.wasm b/web/app/src/vendor/blender/web_engine.wasm index fe28aa96a..e29fddd4d 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/protocol/editor-workflow.ts b/web/protocol/editor-workflow.ts index 3b5821d92..db0f199a5 100644 --- a/web/protocol/editor-workflow.ts +++ b/web/protocol/editor-workflow.ts @@ -355,7 +355,7 @@ export interface NativeAreaLayout { headerMenusVisible?: boolean; } export interface NativeOutlinerRestrict { enable?: boolean; select?: boolean; hide?: boolean; viewport?: boolean; render?: boolean; holdout?: boolean; indirectOnly?: boolean } -export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; kind?: string; restrict?: NativeOutlinerRestrict; restrictionEditable?: boolean; remapId?: string | null; collectionId?: string | null; objectType?: number | null; mode?: string | null; fakeUser?: boolean | null; users?: number | null; realUsers?: number | null; fakeUserEditable?: boolean | null; asset?: boolean | null; assetSupported?: boolean | null; linked?: boolean | null; libraryOverride?: boolean | null; colorTag?: number | null } +export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; kind?: string; restrict?: NativeOutlinerRestrict; restrictionEditable?: boolean; remapId?: string | null; collectionId?: string | null; objectType?: number | null; mode?: string | null; fakeUser?: boolean | null; users?: number | null; realUsers?: number | null; fakeUserEditable?: boolean | null; asset?: boolean | null; assetSupported?: boolean | null; linked?: boolean | null; libraryOverride?: boolean | null; libraryIcon?: string | null; colorTag?: number | null } export interface NativeOutlinerRemapID { id: string; name: string; idType: number; library: string; editable: boolean } export interface NativeOutlinerTypeAvailability { mesh: boolean; armature: boolean; light: boolean; camera: boolean; greasePencil: boolean; others: boolean } export interface NativeOutlinerFilter { searchString: string; caseSensitive: boolean; complete: boolean; sortAlpha: boolean; invert: boolean; state: 'ALL' | 'VISIBLE' | 'SELECTED' | 'ACTIVE' | 'SELECTABLE'; showObjects: boolean; showObjectContents: boolean; showChildren: boolean; showCollections: boolean; showViewLayers: boolean; showMeshes: boolean; showArmatures: boolean; showEmpties: boolean; showLights: boolean; showCameras: boolean; showGreasePencil: boolean; showOthers: boolean; systemOverrides: boolean; showModeColumn: boolean; scrollToActive: boolean; typeAvailability?: NativeOutlinerTypeAvailability } @@ -804,6 +804,9 @@ export function parseEditorWorkflow(value: unknown): EditorWorkflowIR { throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', 'Invalid native Outliner library state'); } } + if (row.libraryIcon != null && (typeof row.libraryIcon !== 'string' || row.libraryIcon.length > 32)) { + throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', 'Invalid native Outliner library icon'); + } for (const key of ['users', 'realUsers'] as const) { const value = row[key]; if (value != null && (!Number.isSafeInteger(value) || Number(value) < 0 || Number(value) > 0x7fffffff)) { @@ -825,7 +828,8 @@ export function parseEditorWorkflow(value: unknown): EditorWorkflowIR { asset: row.asset == null ? null : row.asset as boolean, assetSupported: row.assetSupported == null ? null : row.assetSupported as boolean, linked: row.linked == null ? null : row.linked as boolean, - libraryOverride: row.libraryOverride == null ? null : row.libraryOverride as boolean }; + libraryOverride: row.libraryOverride == null ? null : row.libraryOverride as boolean, + libraryIcon: row.libraryIcon == null ? null : text(row.libraryIcon, 'outliner.row.libraryIcon', 32) }; }); let remapIds: NativeOutlinerRemapID[] | undefined; if (tree.remapIds !== undefined) { diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index 67e9c441b..1c6fb2943 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -1925,4 +1925,45 @@ test.describe("Outliner headed baseline", () => { expect(collectionSequence).not.toContain("删除 (X)"); expect(collectionSequence).not.toContain("选择 (Select)"); }); + + test("[outliner-linked-icons-web] rows draw the desktop link and override markers", async ({ page }) => { + test.setTimeout(300_000); + await page.goto("/?ui=web"); + await page.locator('[data-testid="blend-file-input"]').setInputFiles(LIBRARY_TARGET); + const libraryPath = page.locator('input[aria-label="原始库路径 1"]'); + await expect(libraryPath).toBeVisible({ timeout: 60_000 }); + if (!(await libraryPath.inputValue()).trim()) await libraryPath.fill(LIBRARY_SOURCE_PATH); + await page.locator('input[aria-label="恢复库文件 1"]').setInputFiles(LIBRARY_SOURCE); + await page.getByRole("button", { name: "读取候选 / 重试打开" }).click(); + await expect(libraryPath).toHaveCount(0, { timeout: 120_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(); + await expect(page.locator(".outliner-tree").first()).toBeVisible({ timeout: 20_000 }); + + /* The Current File object is a local library override: + * ICON_LIBRARY_DATA_OVERRIDE. */ + const overrideRow = page.locator('li[role="treeitem"]:has(> .tree-row[aria-label="M12 Override Object"])').first(); + await expect(overrideRow).toBeVisible({ timeout: 30_000 }); + await expect(overrideRow.locator('[aria-label="库覆盖数据"]')).toHaveCount(1, { timeout: 20_000 }); + + /* Blender File mode: the original under its library is a direct link + * (ICON_LIBRARY_DATA_DIRECT). */ + const modeSelect = page.locator('select[aria-label="大纲显示模式"]').first(); + await modeSelect.selectOption("LIBRARIES"); + const libraryRow = page.locator('.tree-row[aria-label*="m12_override_source"]').first(); + await expect(libraryRow).toBeVisible({ timeout: 60_000 }); + const libraryItem = page.locator('li[role="treeitem"]:has(> .tree-row[aria-label*="m12_override_source"])').first(); + const libraryToggle = libraryRow.locator(".tree-expand").first(); + if (await libraryToggle.count() && ((await libraryToggle.getAttribute("aria-label")) ?? "").startsWith("展开")) await libraryToggle.click(); + const objectsGroup = libraryItem.locator('.tree-row[aria-label="Objects"]').first(); + await expect(objectsGroup).toHaveCount(1, { timeout: 30_000 }); + const objectsToggle = objectsGroup.locator(".tree-expand").first(); + if (await objectsToggle.count() && ((await objectsToggle.getAttribute("aria-label")) ?? "").startsWith("展开")) await objectsToggle.click(); + const linkedRow = libraryItem.locator('.tree-row[aria-label="M12 Override Object"]').first(); + await expect(linkedRow).toBeVisible({ timeout: 30_000 }); + await expect(linkedRow.locator('[aria-label="直接链接数据"]')).toHaveCount(1, { timeout: 20_000 }); + /* The local override keeps its editable badge; the two markers are distinct. */ + await expect(linkedRow.locator('[aria-label="库覆盖数据"]')).toHaveCount(0); + }); });