diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index af1636865..e15f04733 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"]; +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"]; /* 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 65aa557dc..9b8708fd8 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -67,6 +67,7 @@ const KNOWN_CASES = [ { id: "outliner-select-linked-web", title: /\[outliner-select-linked-web\]/ }, { id: "outliner-edit-menu-web", title: /\[outliner-edit-menu-web\]/ }, { id: "outliner-collection-view-layer-gate-web", title: /\[outliner-collection-view-layer-gate-web\]/ }, + { id: "outliner-filter-collection-toggle-web", title: /\[outliner-filter-collection-toggle-web\]/ }, ]; function usage() { diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 6e308c031..c2f727b3c 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2840,7 +2840,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o {/* Desktop SpaceOutliner display_mode selector (View Layer, Blender File, …). */} {onSetDisplayMode && tree?.displayModes?.length ? : null} { setMenuRow(null); setDataMenu(!dataMenu); }} - onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }},{label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选集合内新建子集合,选中对象行时建在主集合内(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, {label: '复制集合 (Duplicate Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合及其全部子集合、对象与对象数据(桌面 OUTLINER_OT_collection_duplicate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE', nativeArea.id); }}, {label: '复制链接 (Duplicate Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合与对象,但对象数据保持链接(桌面 OUTLINER_OT_collection_duplicate_linked)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE_LINKED', nativeArea.id); }}, {label: '实例化到场景 (Instance to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合实例化为活动场景中的空物体(桌面 OUTLINER_OT_collection_instance)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INSTANCE', nativeArea.id); }}, /* Desktop draws Link to Scene only outside the View Layer mode (space_outliner.py OUTLINER_MT_collection). */ ...(tree?.displayMode && tree.displayMode !== 'VIEW_LAYER' ? [{label: '链接到场景 (Link to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合链接到当前场景的活动集合(桌面 OUTLINER_OT_collection_link)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_LINK', nativeArea.id); }}] : []), {label: '颜色标签 (Color Tag)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '为所选集合设置颜色标签(桌面 OUTLINER_MT_collection 的 collection_color_tag_set 色块)', children: [{label: '无颜色 (None)', checked: (menuTarget?.colorTag ?? -1) === -1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'NONE'); }}, {label: '颜色 01 (Color 01)', checked: (menuTarget?.colorTag ?? -1) === 0, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_01'); }}, {label: '颜色 02 (Color 02)', checked: (menuTarget?.colorTag ?? -1) === 1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_02'); }}, {label: '颜色 03 (Color 03)', checked: (menuTarget?.colorTag ?? -1) === 2, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_03'); }}, {label: '颜色 04 (Color 04)', checked: (menuTarget?.colorTag ?? -1) === 3, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_04'); }}, {label: '颜色 05 (Color 05)', checked: (menuTarget?.colorTag ?? -1) === 4, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_05'); }}, {label: '颜色 06 (Color 06)', checked: (menuTarget?.colorTag ?? -1) === 5, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_06'); }}, {label: '颜色 07 (Color 07)', checked: (menuTarget?.colorTag ?? -1) === 6, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_07'); }}, {label: '颜色 08 (Color 08)', checked: (menuTarget?.colorTag ?? -1) === 7, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_08'); }}]}, {label: '可见性 (Visibility)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合可见性操作(桌面 OUTLINER_MT_collection_visibility)', children: [{label: '隔离 (Isolate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ISOLATE', nativeArea.id); }}, {label: '显示 (Show)', disabled: menuTarget?.restrict?.hide !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW', nativeArea.id); }}, {label: '显示内部 (Show All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW_INSIDE', nativeArea.id); }}, {label: '隐藏 (Hide)', disabled: menuTarget?.restrict?.hide === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE', nativeArea.id); }}, {label: '隐藏内部 (Hide All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE_INSIDE', nativeArea.id); }}, {label: '在视口中启用 (Enable in Viewports)', disabled: menuTarget?.restrict?.viewport !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE', nativeArea.id); }}, {label: '在视口中禁用 (Disable in Viewports)', disabled: menuTarget?.restrict?.viewport === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE', nativeArea.id); }}, {label: '在渲染中启用 (Enable in Render)', disabled: menuTarget?.restrict?.render !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE_RENDER', nativeArea.id); }}, {label: '在渲染中禁用 (Disable in Render)', disabled: menuTarget?.restrict?.render === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE_RENDER', nativeArea.id); }},]}, ...(tree?.displayMode === 'VIEW_LAYER' ? [{label: '视图层 (View Layer)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合在视图层中的状态(桌面 OUTLINER_MT_collection_view_layer)', children: [{label: '排除 (Exclude)', disabled: menuTarget?.restrict?.enable === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_SET', nativeArea.id); }}, {label: '取消排除 (Clear Exclude)', disabled: menuTarget?.restrict?.enable !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_CLEAR', nativeArea.id); }}, {label: '阻隔 (Holdout)', disabled: menuTarget?.restrict?.holdout === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_SET', nativeArea.id); }}, {label: '取消阻隔 (Clear Holdout)', disabled: menuTarget?.restrict?.holdout !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_CLEAR', nativeArea.id); }}, ...(outlinerEngineIsCycles ? [{label: '仅间接贡献 (Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_SET', nativeArea.id); }}, {label: '取消仅间接贡献 (Clear Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_CLEAR', nativeArea.id); }}] : []),]}] : []), {label: '选择对象 (Select Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '选中该集合内的全部对象(桌面 OUTLINER_OT_collection_objects_select)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SELECT', nativeArea.id); }}, {label: '取消选择对象 (Deselect Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '取消该集合内全部对象的选择(桌面 OUTLINER_OT_collection_objects_deselect)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DESELECT', nativeArea.id); }},{label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, {label: '选择链接 (Select Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '选中共享同一数据块的全部对象(桌面 OUTLINER_IDOP_SELECT_LINKED)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_LINKED', nativeArea.id); }}, /* Desktop's object menu block (space_outliner.py OUTLINER_MT_object): + onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }},{label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选集合内新建子集合,选中对象行时建在主集合内(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, {label: '复制集合 (Duplicate Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合及其全部子集合、对象与对象数据(桌面 OUTLINER_OT_collection_duplicate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE', nativeArea.id); }}, {label: '复制链接 (Duplicate Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合与对象,但对象数据保持链接(桌面 OUTLINER_OT_collection_duplicate_linked)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE_LINKED', nativeArea.id); }}, {label: '实例化到场景 (Instance to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合实例化为活动场景中的空物体(桌面 OUTLINER_OT_collection_instance)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INSTANCE', nativeArea.id); }}, /* Desktop draws Link to Scene only outside the View Layer mode (space_outliner.py OUTLINER_MT_collection). */ ...(tree?.displayMode && tree.displayMode !== 'VIEW_LAYER' ? [{label: '链接到场景 (Link to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合链接到当前场景的活动集合(桌面 OUTLINER_OT_collection_link)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_LINK', nativeArea.id); }}] : []), {label: '颜色标签 (Color Tag)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '为所选集合设置颜色标签(桌面 OUTLINER_MT_collection 的 collection_color_tag_set 色块)', children: [{label: '无颜色 (None)', checked: (menuTarget?.colorTag ?? -1) === -1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'NONE'); }}, {label: '颜色 01 (Color 01)', checked: (menuTarget?.colorTag ?? -1) === 0, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_01'); }}, {label: '颜色 02 (Color 02)', checked: (menuTarget?.colorTag ?? -1) === 1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_02'); }}, {label: '颜色 03 (Color 03)', checked: (menuTarget?.colorTag ?? -1) === 2, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_03'); }}, {label: '颜色 04 (Color 04)', checked: (menuTarget?.colorTag ?? -1) === 3, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_04'); }}, {label: '颜色 05 (Color 05)', checked: (menuTarget?.colorTag ?? -1) === 4, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_05'); }}, {label: '颜色 06 (Color 06)', checked: (menuTarget?.colorTag ?? -1) === 5, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_06'); }}, {label: '颜色 07 (Color 07)', checked: (menuTarget?.colorTag ?? -1) === 6, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_07'); }}, {label: '颜色 08 (Color 08)', checked: (menuTarget?.colorTag ?? -1) === 7, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_08'); }}]}, {label: '可见性 (Visibility)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合可见性操作(桌面 OUTLINER_MT_collection_visibility)', children: [{label: '隔离 (Isolate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ISOLATE', nativeArea.id); }}, {label: '显示 (Show)', disabled: menuTarget?.restrict?.hide !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW', nativeArea.id); }}, {label: '显示内部 (Show All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW_INSIDE', nativeArea.id); }}, {label: '隐藏 (Hide)', disabled: menuTarget?.restrict?.hide === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE', nativeArea.id); }}, {label: '隐藏内部 (Hide All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE_INSIDE', nativeArea.id); }}, {label: '在视口中启用 (Enable in Viewports)', disabled: menuTarget?.restrict?.viewport !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE', nativeArea.id); }}, {label: '在视口中禁用 (Disable in Viewports)', disabled: menuTarget?.restrict?.viewport === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE', nativeArea.id); }}, {label: '在渲染中启用 (Enable in Render)', disabled: menuTarget?.restrict?.render !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE_RENDER', nativeArea.id); }}, {label: '在渲染中禁用 (Disable in Render)', disabled: menuTarget?.restrict?.render === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE_RENDER', nativeArea.id); }},]}, ...(tree?.displayMode === 'VIEW_LAYER' ? [{label: '视图层 (View Layer)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合在视图层中的状态(桌面 OUTLINER_MT_collection_view_layer)', children: [{label: '排除 (Exclude)', disabled: menuTarget?.restrict?.enable === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_SET', nativeArea.id); }}, {label: '取消排除 (Clear Exclude)', disabled: menuTarget?.restrict?.enable !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_CLEAR', nativeArea.id); }}, {label: '阻隔 (Holdout)', disabled: menuTarget?.restrict?.holdout === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_SET', nativeArea.id); }}, {label: '取消阻隔 (Clear Holdout)', disabled: menuTarget?.restrict?.holdout !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_CLEAR', nativeArea.id); }}, ...(outlinerEngineIsCycles ? [{label: '仅间接贡献 (Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_SET', nativeArea.id); }}, {label: '取消仅间接贡献 (Clear Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_CLEAR', nativeArea.id); }}] : []),]}] : []), {label: '选择对象 (Select Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '选中该集合内的全部对象(桌面 OUTLINER_OT_collection_objects_select)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SELECT', nativeArea.id); }}, {label: '取消选择对象 (Deselect Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '取消该集合内全部对象的选择(桌面 OUTLINER_OT_collection_objects_deselect)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DESELECT', nativeArea.id); }},...(tree?.displayMode === 'VIEW_LAYER' && tree?.filter?.showCollections === false ? [] : [{label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}]), {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, {label: '选择链接 (Select Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '选中共享同一数据块的全部对象(桌面 OUTLINER_IDOP_SELECT_LINKED)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_LINKED', nativeArea.id); }}, /* Desktop's object menu block (space_outliner.py OUTLINER_MT_object): * Select, Select Hierarchy and Deselect run on the outliner selection. */ {label: '选择 (Select)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选中所选对象行对应的对象(桌面 OUTLINER_OT_object_operation type=SELECT)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT', nativeArea.id); }}, {label: '选择层级 (Select Hierarchy)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选择所选对象及其全部子级(桌面 OUTLINER_OT_object_operation type=SELECT_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_HIERARCHY', nativeArea.id); }}, @@ -2899,6 +2899,8 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o {nativeFilter ? <> + + : null} diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index c9ce8c5d2..424a6218e 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -183,8 +183,11 @@ test.describe("Outliner headed baseline", () => { const menu = page.locator(".outliner-filter-menu").first(); await expect(menu).toBeVisible(); const checkboxes = menu.locator('input[type="checkbox"]'); - /* Four filter-state toggles plus the seven View Layer restriction toggles. */ - await expect(checkboxes).toHaveCount(11); + /* Six filter toggles (visible / selected / collections / objects / invert / + * sync) plus the seven View Layer restriction toggles. */ + await expect(checkboxes).toHaveCount(13); + await expect(menu.getByLabel("集合")).toHaveCount(1); + await expect(menu.getByLabel("物体")).toHaveCount(1); await expect(menu.getByLabel("反转")).toHaveCount(1); await expect(menu.getByLabel("同步选择")).toHaveCount(1); await filterButton.click(); @@ -1407,4 +1410,47 @@ test.describe("Outliner headed baseline", () => { await expect(page.getByRole("menuitem", { name: "可见性 (Visibility)", exact: true })).toHaveCount(1, { timeout: 15_000 }); await expect(viewLayerItem).toHaveCount(0); }); + + test("[outliner-filter-collection-toggle-web] the filter hides collections and gates Unlink", async ({ page }) => { + test.setTimeout(180_000); + await page.goto("/?ui=web"); + 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 partsRow = page.locator('.tree-row[aria-label="Parts"]').first(); + await expect(partsRow).toBeVisible({ timeout: 30_000 }); + + /* Desktop default (use_filter_collection on) keeps Unlink in the menu. */ + await partsRow.locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "取消链接", exact: true })).toHaveCount(1, { timeout: 15_000 }); + await page.keyboard.press("Escape"); + + /* Unchecking Collections sets SO_FILTER_NO_COLLECTION; the view-layer tree + * then stops emitting collection rows (tree_display_view_layer.cc). */ + const filterButton = page.locator('button[aria-label="筛选"]').first(); + await filterButton.click(); + const menu = page.locator(".outliner-filter-menu").first(); + await expect(menu).toBeVisible(); + await menu.getByLabel("集合").uncheck(); + await filterButton.click(); + await expect.poll(async () => page.locator('.tree-row[aria-label="Parts"]').count(), { timeout: 30_000 }).toBe(0); + + /* space_outliner.py hides Unlink when display_mode == 'VIEW_LAYER' and + * use_filter_collection is off. */ + const rootRig = page.locator('.tree-row[aria-label="RootRig"]').first(); + await expect(rootRig).toBeVisible({ timeout: 15_000 }); + await rootRig.locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "取消链接", exact: true })).toHaveCount(0, { timeout: 15_000 }); + await page.keyboard.press("Escape"); + + /* Re-enabling collections restores the rows and the menu entry. */ + await filterButton.click(); + await menu.getByLabel("集合").check(); + await filterButton.click(); + await expect.poll(async () => page.locator('.tree-row[aria-label="Parts"]').count(), { timeout: 30_000 }).toBeGreaterThan(0); + await page.locator('.tree-row[aria-label="Parts"]').first().locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "取消链接", exact: true })).toHaveCount(1, { timeout: 15_000 }); + }); });