feat(web): workbench Outliner matches the desktop Layout geometry
The desktop golden comes from Blender's own laid-out screen data (tools/web/measure-outliner-desktop.py, blender 5.2.0 LTS, factory Layout at 1920x1080): right column 339 px, Outliner area 339x189 under a 26 px header, 20 px rows, 14 px per-level indent (0.7 * UI_UNIT_X). The workbench derives the right width and the Outliner/timeline split from those ratios so it reproduces the area at the reference size and scales elsewhere. The headed suite grows outliner-metrics-web with +-1 px assertions, and the runner now materializes inline base64 attachments so the checker can compare the measured boxes against the golden. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
191
tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json
Normal file
191
tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json
Normal file
@@ -0,0 +1,191 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"source": {
|
||||
"binary": "/home/mes123456/workinf_Blender_Wasm/build_blender_native/bin/blender",
|
||||
"version": "5.2.0 LTS",
|
||||
"factoryStartup": true,
|
||||
"screen": "Layout"
|
||||
},
|
||||
"preferences": {
|
||||
"dpi": 72.0,
|
||||
"uiScale": 1.0,
|
||||
"widgetUnit": 20
|
||||
},
|
||||
"contentExtent": {
|
||||
"width": 1918,
|
||||
"height": 1054
|
||||
},
|
||||
"areas": [
|
||||
{
|
||||
"type": "PROPERTIES",
|
||||
"x": 1579,
|
||||
"y": 23,
|
||||
"width": 339,
|
||||
"height": 839,
|
||||
"regions": [
|
||||
{
|
||||
"type": "HEADER",
|
||||
"x": 1579,
|
||||
"y": 836,
|
||||
"width": 339,
|
||||
"height": 26
|
||||
},
|
||||
{
|
||||
"type": "NAVIGATION_BAR",
|
||||
"x": 1579,
|
||||
"y": 23,
|
||||
"width": 29,
|
||||
"height": 813
|
||||
},
|
||||
{
|
||||
"type": "WINDOW",
|
||||
"x": 1608,
|
||||
"y": 23,
|
||||
"width": 310,
|
||||
"height": 813
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "OUTLINER",
|
||||
"x": 1579,
|
||||
"y": 865,
|
||||
"width": 339,
|
||||
"height": 189,
|
||||
"regions": [
|
||||
{
|
||||
"type": "HEADER",
|
||||
"x": 1579,
|
||||
"y": 1028,
|
||||
"width": 339,
|
||||
"height": 26
|
||||
},
|
||||
{
|
||||
"type": "WINDOW",
|
||||
"x": 1579,
|
||||
"y": 865,
|
||||
"width": 339,
|
||||
"height": 163
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "DOPESHEET_EDITOR",
|
||||
"x": 2,
|
||||
"y": 23,
|
||||
"width": 1574,
|
||||
"height": 74,
|
||||
"regions": [
|
||||
{
|
||||
"type": "HEADER",
|
||||
"x": 2,
|
||||
"y": 71,
|
||||
"width": 1574,
|
||||
"height": 26
|
||||
},
|
||||
{
|
||||
"type": "FOOTER",
|
||||
"x": 2,
|
||||
"y": 23,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "CHANNELS",
|
||||
"x": 2,
|
||||
"y": 23,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "UI",
|
||||
"x": 1575,
|
||||
"y": 23,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "WINDOW",
|
||||
"x": 2,
|
||||
"y": 23,
|
||||
"width": 1574,
|
||||
"height": 48
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VIEW_3D",
|
||||
"x": 2,
|
||||
"y": 100,
|
||||
"width": 1574,
|
||||
"height": 954,
|
||||
"regions": [
|
||||
{
|
||||
"type": "HEADER",
|
||||
"x": 2,
|
||||
"y": 1028,
|
||||
"width": 1574,
|
||||
"height": 26
|
||||
},
|
||||
{
|
||||
"type": "TOOL_HEADER",
|
||||
"x": 2,
|
||||
"y": 1002,
|
||||
"width": 1574,
|
||||
"height": 26
|
||||
},
|
||||
{
|
||||
"type": "ASSET_SHELF",
|
||||
"x": 2,
|
||||
"y": 100,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "ASSET_SHELF_HEADER",
|
||||
"x": 2,
|
||||
"y": 100,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "TOOLS",
|
||||
"x": 2,
|
||||
"y": 100,
|
||||
"width": 56,
|
||||
"height": 902
|
||||
},
|
||||
{
|
||||
"type": "UI",
|
||||
"x": 1575,
|
||||
"y": 100,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "HUD",
|
||||
"x": 58,
|
||||
"y": 100,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"type": "WINDOW",
|
||||
"x": 2,
|
||||
"y": 100,
|
||||
"width": 1574,
|
||||
"height": 954
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"outliner": {
|
||||
"x": 1579,
|
||||
"y": 865,
|
||||
"width": 339,
|
||||
"height": 189,
|
||||
"headerHeight": 26,
|
||||
"rowHeight": 20,
|
||||
"indentPerLevel": 14
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,9 @@ 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"];
|
||||
const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-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 = [];
|
||||
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||
|
||||
@@ -120,6 +122,36 @@ for (const item of cases) {
|
||||
}
|
||||
}
|
||||
|
||||
/* The metrics case attaches its measured boxes; compare them with the desktop
|
||||
* golden the workbench layout is built from (±1 px at 1920x1080). */
|
||||
const geometryCase = cases.find((item) => item.caseId === "outliner-metrics-web");
|
||||
if (geometryCase) {
|
||||
const artifact = (geometryCase.artifacts ?? []).find((entry) => entry.name === "outliner-metrics-web");
|
||||
if (!artifact) errors.push("outliner-metrics-web attached no geometry artifact");
|
||||
else if (!fs.existsSync(GEOMETRY_GOLDEN)) errors.push(`desktop metrics golden is missing: ${GEOMETRY_GOLDEN}`);
|
||||
else {
|
||||
try {
|
||||
const body = JSON.parse(fs.readFileSync(path.resolve(reportDir, artifact.path ?? ""), "utf8"));
|
||||
const golden = JSON.parse(fs.readFileSync(GEOMETRY_GOLDEN, "utf8")).outliner;
|
||||
const near = (value, expected) => Number.isFinite(value) && Math.abs(value - expected) <= 1;
|
||||
const measured = body.measured ?? {};
|
||||
if (measured.viewport?.width !== 1920 || measured.viewport?.height !== 1080) errors.push(`outliner-metrics-web ran at ${JSON.stringify(measured.viewport)}, expected 1920x1080`);
|
||||
for (const [name, actual, expected] of [
|
||||
["outliner width", measured.outliner?.width, golden.width],
|
||||
["outliner height", measured.outliner?.height, golden.height],
|
||||
["outliner header height", measured.header?.height, golden.headerHeight],
|
||||
["indent per level", measured.indentPerLevel, golden.indentPerLevel],
|
||||
]) {
|
||||
if (!near(actual, expected)) errors.push(`outliner-metrics-web ${name} ${actual} is outside ±1 of desktop ${expected}`);
|
||||
}
|
||||
const heights = Array.isArray(measured.rowHeights) ? measured.rowHeights : [];
|
||||
if (heights.length === 0) errors.push("outliner-metrics-web measured no rows");
|
||||
for (const height of heights) if (!near(height, golden.rowHeight)) errors.push(`outliner-metrics-web row height ${height} is outside ±1 of desktop ${golden.rowHeight}`);
|
||||
}
|
||||
catch (error) { errors.push(`outliner-metrics-web artifact is unreadable: ${error.message}`); }
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
console.error(JSON.stringify({ status: "FAIL", errors }, null, 2));
|
||||
process.exit(1);
|
||||
|
||||
102
tools/web/measure-outliner-desktop.py
Normal file
102
tools/web/measure-outliner-desktop.py
Normal file
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read the desktop Outliner geometry from Blender's own laid-out screen data.
|
||||
|
||||
blender --factory-startup --background \
|
||||
--python tools/web/measure-outliner-desktop.py -- --out <abs json>
|
||||
|
||||
The factory Layout screen is the reference the web workbench mirrors. The rects
|
||||
below come from the screen/region layout Blender itself produced (background mode
|
||||
lays the startup screen out at the factory window size), never from hand-typed
|
||||
numbers. Every value the web side must match is emitted verbatim:
|
||||
|
||||
* the OUTLINER area rect (the user asked for the same area size as desktop),
|
||||
* its HEADER region height,
|
||||
* the widget unit (`U.widget_unit`), which is the tree row height
|
||||
(`UI_UNIT_Y` in interface code) at the factory dpi/scale,
|
||||
* the per-level tree indent (0.7 * UI_UNIT_X, `UI_TREEVIEW_INDENT`).
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def _take(flag: str):
|
||||
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
if flag in argv:
|
||||
index = argv.index(flag)
|
||||
if index + 1 < len(argv):
|
||||
return argv[index + 1]
|
||||
return None
|
||||
|
||||
|
||||
OUT = _take("--out")
|
||||
if not OUT:
|
||||
raise SystemExit("measure-outliner-desktop: pass -- --out <absolute path>")
|
||||
|
||||
screen = bpy.data.screens.get("Layout")
|
||||
if screen is None:
|
||||
raise SystemExit("measure-outliner-desktop: the factory Layout screen is missing")
|
||||
|
||||
areas = []
|
||||
for area in screen.areas:
|
||||
areas.append({
|
||||
"type": area.type,
|
||||
"x": area.x,
|
||||
"y": area.y,
|
||||
"width": area.width,
|
||||
"height": area.height,
|
||||
"regions": [
|
||||
{"type": region.type, "x": region.x, "y": region.y,
|
||||
"width": region.width, "height": region.height}
|
||||
for region in area.regions
|
||||
],
|
||||
})
|
||||
|
||||
outliner = next((area for area in areas if area["type"] == "OUTLINER"), None)
|
||||
if outliner is None:
|
||||
raise SystemExit("measure-outliner-desktop: the Layout screen has no OUTLINER area")
|
||||
if outliner["width"] <= 0 or outliner["height"] <= 0:
|
||||
raise SystemExit(f"measure-outliner-desktop: the OUTLINER rect is empty: {outliner}")
|
||||
|
||||
header = next((region for region in outliner["regions"] if region["type"] == "HEADER"), None)
|
||||
if header is None or header["height"] <= 0:
|
||||
raise SystemExit(f"measure-outliner-desktop: the OUTLINER area has no laid-out HEADER: {outliner}")
|
||||
|
||||
# `U.widget_unit` = round(UI_UNIT_X * ui_scale * dpi / 72); UI_UNIT_X is 20 at
|
||||
# the factory scale. This is the value tree rows use as their height.
|
||||
prefs = bpy.context.preferences
|
||||
dpi = float(prefs.system.dpi)
|
||||
ui_scale = float(prefs.view.ui_scale)
|
||||
widget_unit = round(20.0 * ui_scale * dpi / 72.0)
|
||||
|
||||
metrics = {
|
||||
"schemaVersion": 1,
|
||||
"source": {
|
||||
"binary": bpy.app.binary_path,
|
||||
"version": bpy.app.version_string,
|
||||
"factoryStartup": True,
|
||||
"screen": "Layout",
|
||||
},
|
||||
"preferences": {"dpi": dpi, "uiScale": ui_scale, "widgetUnit": widget_unit},
|
||||
"contentExtent": {
|
||||
"width": max(area["x"] + area["width"] for area in areas),
|
||||
"height": max(area["y"] + area["height"] for area in areas),
|
||||
},
|
||||
"areas": areas,
|
||||
"outliner": {
|
||||
"x": outliner["x"],
|
||||
"y": outliner["y"],
|
||||
"width": outliner["width"],
|
||||
"height": outliner["height"],
|
||||
"headerHeight": header["height"],
|
||||
"rowHeight": widget_unit,
|
||||
"indentPerLevel": round(0.7 * widget_unit),
|
||||
},
|
||||
}
|
||||
|
||||
with open(OUT, "w", encoding="utf-8") as handle:
|
||||
json.dump(metrics, handle, indent=2, sort_keys=False)
|
||||
handle.write("\n")
|
||||
print(f"outliner-metrics -> {OUT} ({outliner['width']}x{outliner['height']}, "
|
||||
f"header {header['height']}, row {widget_unit})")
|
||||
@@ -34,6 +34,7 @@ const KNOWN_CASES = [
|
||||
{ id: "outliner-tree-baseline-web", title: /\[outliner-tree-baseline-web\]/ },
|
||||
{ id: "outliner-tools-baseline-web", title: /\[outliner-tools-baseline-web\]/ },
|
||||
{ id: "outliner-mirror-baseline-web", title: /\[outliner-mirror-baseline-web\]/ },
|
||||
{ id: "outliner-metrics-web", title: /\[outliner-metrics-web\]/ },
|
||||
];
|
||||
|
||||
function usage() {
|
||||
@@ -159,7 +160,7 @@ function flattenSuites(suites, file, output) {
|
||||
const title = spec.title;
|
||||
const tagged = /\[([a-z0-9][a-z0-9-]*)\]/.exec(title);
|
||||
const caseId = tagged ? tagged[1] : title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 60);
|
||||
const attachments = (result?.attachments ?? []).map((attachment) => ({ name: attachment.name, path: attachment.path ?? null, contentType: attachment.contentType ?? null }));
|
||||
const attachments = (result?.attachments ?? []).map((attachment) => ({ name: attachment.name, path: attachment.path ?? null, body: attachment.body ?? null, contentType: attachment.contentType ?? null }));
|
||||
output.push({
|
||||
caseId,
|
||||
title,
|
||||
@@ -180,10 +181,18 @@ function copyArtifacts(cases) {
|
||||
fs.mkdirSync(target, { recursive: true });
|
||||
item.artifacts = [];
|
||||
for (const attachment of item.attachments) {
|
||||
if (!attachment.path || !fs.existsSync(attachment.path)) continue;
|
||||
const extension = path.extname(attachment.path) || (attachment.contentType === "image/png" ? ".png" : ".json");
|
||||
let source = attachment.path && fs.existsSync(attachment.path) ? attachment.path : null;
|
||||
/* Playwright only spills attachments to disk when they are large; a small
|
||||
* `testInfo.attach({ body })` payload stays inline as base64 in the JSON
|
||||
* report, so materialize it here or the receipt loses the evidence. */
|
||||
if (!source && attachment.body) {
|
||||
source = path.join(target, `${attachment.name}${attachment.contentType === "image/png" ? ".png" : attachment.contentType === "application/json" ? ".json" : ".txt"}`);
|
||||
fs.writeFileSync(source, Buffer.from(attachment.body, "base64"));
|
||||
}
|
||||
if (!source) continue;
|
||||
const extension = path.extname(source) || (attachment.contentType === "image/png" ? ".png" : ".json");
|
||||
const file = path.join(target, `${attachment.name}${extension}`);
|
||||
fs.copyFileSync(attachment.path, file);
|
||||
if (source !== file) fs.copyFileSync(source, file);
|
||||
item.artifacts.push({ name: attachment.name, kind: extension.replace(".", ""), path: path.relative(reportDir, file), sha256: sha256File(file), bytes: fs.statSync(file).size });
|
||||
}
|
||||
delete item.attachments;
|
||||
|
||||
@@ -2712,6 +2712,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o
|
||||
};
|
||||
return <div {...nodeProps} ref={attachRow} key={row.id} aria-label={row.label}
|
||||
data-node-id={row.objectId ?? ''} data-active={row.active}
|
||||
style={{paddingLeft: 4 + 14 * Math.min(row.depth, 32)}}
|
||||
className={`tree-row child${row.selected ? ' selected' : ''}`}
|
||||
draggable={Boolean(row.objectId) || Boolean(collectionRows.find(item => item.name === row.label && !item.sourceLibrary && !item.isMaster))}
|
||||
onDragStart={event => {
|
||||
@@ -2814,7 +2815,6 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o
|
||||
event.preventDefault(); onToggleExpand?.(row.id, event.altKey, nativeArea.id);
|
||||
}
|
||||
}}>
|
||||
<span className="tree-depth" aria-hidden="true">{'\u00a0\u00a0'.repeat(row.depth)}</span>
|
||||
{row.hasChildren ? <button type="button" className="tree-expand"
|
||||
aria-label={`${row.expanded ? '折叠' : '展开'} ${row.label}`}
|
||||
onClick={event => { event.stopPropagation(); onToggleExpand?.(row.id, event.altKey, nativeArea.id); }}>
|
||||
@@ -2928,9 +2928,9 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o
|
||||
const node = row.objectId ? nodeById.get(row.objectId) : undefined;
|
||||
if (!node) return null;
|
||||
return <div {...nodeProps} ref={attachRow} key={row.id} aria-label={row.label} data-node-id={node.id} data-parent-id={node.parentId ?? ''} data-data-id={node.dataId ?? ''}
|
||||
style={{paddingLeft: 4 + 14 * Math.min(row.depth, 32)}}
|
||||
className={`tree-row child${row.selected ? ' selected' : ''}`}
|
||||
onClick={(event) => { onSelect(node.id, event.ctrlKey || event.metaKey, event.shiftKey); }}>
|
||||
<span className="tree-depth" aria-hidden="true">{' '.repeat(Math.min(Math.max(row.depth - 1, 0), 32))}</span>
|
||||
{row.hasChildren ? <button type="button" className="tree-expand" aria-label={`${row.expanded ? '折叠' : '展开'} ${row.label}`}
|
||||
onClick={(event) => { event.stopPropagation(); setCollapsed((current) => { const next = new Set(current); if (next.has(node.id)) next.delete(node.id); else next.add(node.id); return next; }); }}>
|
||||
{row.expanded ? '▾' : '▸'}</button> : <span>·</span>}
|
||||
|
||||
@@ -89,13 +89,13 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
|
||||
.area-type-switch { position: absolute; top: 2px; right: 3px; z-index: 6; display: flex; align-items: center; gap: 2px; max-width: calc(100% - 6px); padding: 1px 3px; border-radius: 3px; background: #1d1d1dcc; color: #c9c9c9; font-size: 10px; opacity: 0; pointer-events: none; transition: opacity .12s; }
|
||||
.area-frame:hover > .area-type-switch, .area-frame:focus-within > .area-type-switch { opacity: .9; pointer-events: auto; }
|
||||
/* Areas with a visible header carry the switcher inside it instead. */
|
||||
.editor-header > .area-type-switch { position: relative; z-index: 3; flex: 0 0 auto; min-width: 0; max-width: none; opacity: 1; pointer-events: auto; background: transparent; }
|
||||
.editor-header > .area-type-switch { position: relative; z-index: 3; flex: 0 0 auto; min-width: 0; max-width: none; padding: 0 3px; opacity: 1; pointer-events: auto; background: transparent; }
|
||||
.area-type-switch:hover, .area-type-switch:focus-within { opacity: 1; }
|
||||
@media (hover: none) { .area-type-switch { opacity: .6; pointer-events: auto; } }
|
||||
.area-type-switch select { min-width: 0; max-width: 160px; padding: 1px 2px; border: 1px solid #4a4a4a; border-radius: 2px; background: #2a2a2a; color: #ddd; font-size: 10px; }
|
||||
.area-type-switch select { min-width: 0; max-width: 160px; height: 22px; padding: 0 2px; border: 1px solid #4a4a4a; border-radius: 2px; background: #2a2a2a; color: #ddd; font-size: 10px; }
|
||||
.area-type-switch span { flex: none; }
|
||||
.editor-header { position: relative; z-index: 2; display: flex; align-items: center; gap: 2px; flex: none; min-width: 0; min-height: 27px; padding: 0 4px; background: #292929; border-bottom: 1px solid #151515; box-shadow: inset 0 -1px #333; }
|
||||
.editor-selector, .icon-button { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 24px; min-height: 24px; padding: 4px 6px; background: transparent; color: #e1e3e7; border-radius: 3px; }
|
||||
.editor-header { position: relative; z-index: 2; display: flex; align-items: center; gap: 2px; flex: none; min-width: 0; min-height: 26px; padding: 0 4px; background: #292929; border-bottom: 1px solid #151515; box-shadow: inset 0 -1px #333; }
|
||||
.editor-selector, .icon-button { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 24px; min-height: 24px; padding: 0 6px; background: transparent; color: #e1e3e7; border-radius: 3px; }
|
||||
/* A narrow area must squeeze the label, not push the ⋮ switcher out of the header. */
|
||||
.editor-selector > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.editor-selector:hover, .icon-button:hover { background: #414141; }
|
||||
@@ -160,12 +160,11 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
|
||||
.viewport-sidebar-tabs label { display: flex; align-items: center; gap: 4px; }
|
||||
.viewport-sidebar-tabs label > input { flex: 1; min-width: 0; padding: 1px 3px; color: #ddd; background: #1d1d1d; border: 1px solid #3c3c3c; border-radius: 2px; }
|
||||
.outliner-content { padding: 3px 2px; color: #d0d0d0; }
|
||||
.tree-expand { width:16px;min-width:16px;height:22px;padding:0;background:transparent;color:inherit;border:0; }
|
||||
.tree-depth { white-space:pre;flex-shrink:0; }
|
||||
.tree-expand { width:16px;min-width:16px;height:20px;padding:0;background:transparent;color:inherit;border:0; }
|
||||
.tree-node-name { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
|
||||
.properties-content { position: relative; display: flex; flex-direction: column; min-height: 100%; padding: 4px 7px 12px 40px; color: #d0d0d0; background: #303030; }
|
||||
.outliner-tools { display: flex; gap: 3px; margin: 0 2px 4px; }.outliner-tools input { min-width: 0; height: 23px; flex: 1; padding: 3px 7px; color: #e4e4e4; background: #181818; border: 1px solid #454545; border-radius: 3px; outline: none; }.outliner-tools button { width: 27px; background: #383838; border-radius: 2px; }
|
||||
.tree-row { display: flex; align-items: center; gap: 5px; min-height: 24px; padding: 1px 4px; border-radius: 0; }.tree-row:hover { background: #353535; }.tree-row.child { padding-left: 26px; }.tree-row.selected { color: #fff; background: #4775a3; }.tree-icon { color: #d59b44; }.tree-icon.mesh { color: #6999c8; }.tree-action { width: 24px; min-width: 24px; height: 24px; margin-left: auto; padding: 1px 3px; color: #a6a6a6; background: transparent; border: 0; border-radius: 2px; }.tree-action:hover { color: #fff; background: #4a4a4a; }
|
||||
.tree-row { display: flex; align-items: center; gap: 5px; min-height: 20px; padding: 0 4px; border-radius: 0; }.tree-row:hover { background: #353535; }.tree-row.selected { color: #fff; background: #4775a3; }.tree-icon { height:20px;min-width:16px;padding:0;border:0;background:transparent;color: #d59b44; }.tree-icon.mesh { color: #6999c8; }.tree-action { width: 20px; min-width: 20px; height: 20px; margin-left: auto; padding: 0 2px; color: #a6a6a6; background: transparent; border: 0; border-radius: 2px; }.tree-action:hover { color: #fff; background: #4a4a4a; }
|
||||
.property-tabs { position: absolute; left: 0; top: 0; bottom: 0; display: flex; flex-direction: column; gap: 1px; width: 34px; overflow-y: auto; scrollbar-width: thin; margin: 0; padding: 4px 3px; background: #242424; border-right: 1px solid #151515; }.property-tab { display: grid; place-items: center; width: 27px; height: 27px; padding: 0; color: #aaa; background: transparent; border-radius: 2px; }.property-tab:hover { color: #fff; background: #404040; }.property-tab.active { color: #fff; background: #4775a3; }.property-tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }.property-section { padding: 7px 3px 9px; border-bottom: 1px solid #454545; }.property-section h3 { margin: 0 0 7px; padding: 4px 6px; color: #eee; background: #383838; border-radius: 2px; font-size: 11px; font-weight: 600; }.property-section label { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; min-width: 0; min-height: 23px; color: #b5b5b5; }
|
||||
/* A narrow properties column must not push its controls outside the panel. */
|
||||
.property-section label > select, .property-section label > input, .property-section label > span { min-width: 0; max-width: 100%; }.property-transform-row { display: flex; align-items: center; gap: 3px; margin-bottom: 3px; }.property-transform-row > span { flex: 0 1 26px; min-width: 16px; overflow: hidden; color: #b5b5b5; text-overflow: ellipsis; white-space: nowrap; }.property-transform-row > input { flex: 1 1 0; min-width: 0; width: auto; padding: 2px 3px; color: #e0e2e6; background: #26282c; border: 1px solid #484c53; border-radius: 2px; font-variant-numeric: tabular-nums; }.property-transform-row > input:disabled { color: #7a7d82; background: #202124; }
|
||||
|
||||
@@ -26,13 +26,28 @@ export interface WorkspaceLayoutState {
|
||||
floating: Record<string, FloatingRect>;
|
||||
}
|
||||
|
||||
export const DEFAULT_SPLITS: WorkspaceSplits = { rightWidth: 320, timelineHeight: 108, outlinerShare: 1 / 3 };
|
||||
/** Mid-size windows start with the 290px right column the CSS used to force. */
|
||||
function initialRightWidth(): number {
|
||||
return typeof window !== "undefined" && window.innerWidth <= 1280 ? 290 : DEFAULT_SPLITS.rightWidth;
|
||||
}
|
||||
/* Desktop reference (blender 5.2.0 LTS, factory Layout screen, 1920x1080): the
|
||||
* right column is 339 px, the Outliner 189 px tall below a 26 px header
|
||||
* (tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json). The workbench
|
||||
* keeps that ratio so the area matches Blender's at any window size. */
|
||||
export const DESKTOP_RIGHT_RATIO = 339 / 1920;
|
||||
/* At 1920x1080 the workbench chrome takes 28 (topbar) + 65 (toolbar row, 30 +
|
||||
* the 35 px quick-tools row) + 20 (status bar), leaving a 967 px grid; minus the
|
||||
* 108 px timeline and two 1 px gaps that is 857 px of fr space. The desktop
|
||||
* Outliner is 189 px of it, so 189 / 857 reproduces the area height. */
|
||||
export const DESKTOP_OUTLINER_SHARE = 189 / 857;
|
||||
const MIN_RIGHT = 240;
|
||||
const MIN_TIMELINE = 48;
|
||||
export const DEFAULT_SPLITS: WorkspaceSplits = { rightWidth: Math.round(1920 * DESKTOP_RIGHT_RATIO), timelineHeight: 108, outlinerShare: DESKTOP_OUTLINER_SHARE };
|
||||
/** Mid-size windows start with the 290px right column the CSS used to force. */
|
||||
function initialRightWidth(): number {
|
||||
if (typeof window === "undefined") return DEFAULT_SPLITS.rightWidth;
|
||||
if (window.innerWidth <= 1280) return 290;
|
||||
return Math.max(MIN_RIGHT, Math.round(window.innerWidth * DESKTOP_RIGHT_RATIO));
|
||||
}
|
||||
function defaultSplits(): WorkspaceSplits {
|
||||
return { ...DEFAULT_SPLITS, rightWidth: initialRightWidth() };
|
||||
}
|
||||
const MIN_FLOATING = { width: 240, height: 160 };
|
||||
|
||||
function readState(): WorkspaceLayoutState {
|
||||
@@ -57,7 +72,7 @@ function readState(): WorkspaceLayoutState {
|
||||
floating,
|
||||
};
|
||||
}
|
||||
catch { return { splits: { ...DEFAULT_SPLITS }, floating: {} }; }
|
||||
catch { return { splits: defaultSplits(), floating: {} }; }
|
||||
}
|
||||
|
||||
export function resetWorkspaceLayout(): void {
|
||||
@@ -87,7 +102,7 @@ export function WorkspaceLayoutProvider({ children }: { children: ReactNode }) {
|
||||
}, [state]);
|
||||
|
||||
useEffect(() => {
|
||||
const onReset = () => setState({ splits: { ...DEFAULT_SPLITS }, floating: {} });
|
||||
const onReset = () => setState({ splits: defaultSplits(), floating: {} });
|
||||
window.addEventListener(WORKSPACE_LAYOUT_RESET_EVENT, onReset);
|
||||
return () => window.removeEventListener(WORKSPACE_LAYOUT_RESET_EVENT, onReset);
|
||||
}, []);
|
||||
@@ -104,7 +119,7 @@ export function WorkspaceLayoutProvider({ children }: { children: ReactNode }) {
|
||||
return { ...current, floating };
|
||||
}),
|
||||
dockAll: () => setState((current) => ({ ...current, floating: {} })),
|
||||
resetAll: () => setState({ splits: { ...DEFAULT_SPLITS }, floating: {} }),
|
||||
resetAll: () => setState({ splits: defaultSplits(), floating: {} }),
|
||||
}), [state]);
|
||||
|
||||
return <LayoutContext.Provider value={api}>{children}</LayoutContext.Provider>;
|
||||
@@ -251,12 +266,12 @@ export function WorkspaceSplitters() {
|
||||
role="separator" tabIndex={0} title={`${labels[bar.kind]}(双击复位)`} aria-label={labels[bar.kind]}
|
||||
aria-orientation={bar.kind === "right" ? "vertical" : "horizontal"} data-splitter={bar.kind}
|
||||
onPointerDown={begin(bar.kind)} onPointerMove={move} onPointerUp={end} onPointerCancel={end}
|
||||
onDoubleClick={() => setSplits({ ...DEFAULT_SPLITS })}
|
||||
onDoubleClick={() => setSplits(defaultSplits())}
|
||||
onKeyDown={(event) => {
|
||||
const step = event.shiftKey ? 48 : 16;
|
||||
if (event.key === "ArrowLeft" || event.key === "ArrowUp") { event.preventDefault(); nudge(bar.kind, -step); }
|
||||
else if (event.key === "ArrowRight" || event.key === "ArrowDown") { event.preventDefault(); nudge(bar.kind, step); }
|
||||
else if (event.key === "Home") { event.preventDefault(); setSplits({ ...DEFAULT_SPLITS }); }
|
||||
else if (event.key === "Home") { event.preventDefault(); setSplits(defaultSplits()); }
|
||||
}} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const BASIC_SCENE = path.resolve(HERE, "../../../tests/files/web/basic_scene.blend");
|
||||
/* Desktop geometry measured from Blender's own Layout screen
|
||||
* (tools/web/measure-outliner-desktop.py, blender 5.2.0 LTS, factory startup). */
|
||||
const DESKTOP_METRICS = path.resolve(HERE, "../../../tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json");
|
||||
|
||||
/* Shared entry for the web workbench: open the fixture through the product
|
||||
* input, wait for the engine to own the project, and expose the native tools
|
||||
@@ -88,6 +92,46 @@ test.describe("Outliner headed baseline", () => {
|
||||
await expect.poll(async () => page.locator(`.outliner-tree button[aria-label="隐藏 ${name}"]`).count(), { timeout: 15_000 }).toBe(1);
|
||||
});
|
||||
|
||||
test("[outliner-metrics-web] the workbench Outliner matches the desktop Layout geometry", async ({ page }, testInfo) => {
|
||||
test.setTimeout(150_000);
|
||||
await openWorkbench(page);
|
||||
await expect.poll(async () => page.getByRole("treeitem").count(), { timeout: 20_000 }).toBeGreaterThan(1);
|
||||
const golden = (JSON.parse(readFileSync(DESKTOP_METRICS, "utf8")) as { outliner: { width: number; height: number; headerHeight: number; rowHeight: number; indentPerLevel: number } }).outliner;
|
||||
const measured = await page.evaluate(() => {
|
||||
const rect = (element: Element | null) => {
|
||||
if (!element) return null;
|
||||
const box = element.getBoundingClientRect();
|
||||
return { x: box.x, y: box.y, width: box.width, height: box.height };
|
||||
};
|
||||
const area = document.querySelector(".outliner-area");
|
||||
const header = area?.querySelector(":scope > .editor-header") ?? null;
|
||||
const rows = Array.from(document.querySelectorAll<HTMLElement>(".outliner-tree .tree-row"));
|
||||
const paddingLevels = [...new Set(rows.map((row) => Math.round(parseFloat(getComputedStyle(row).paddingLeft))))].sort((a, b) => a - b);
|
||||
const steps = paddingLevels.slice(1).map((value, index) => value - paddingLevels[index]);
|
||||
return {
|
||||
viewport: { width: window.innerWidth, height: window.innerHeight },
|
||||
outliner: rect(area),
|
||||
header: rect(header),
|
||||
rowHeights: rows.map((row) => row.getBoundingClientRect().height),
|
||||
paddingLevels,
|
||||
indentPerLevel: steps.length ? Math.min(...steps) : null,
|
||||
};
|
||||
});
|
||||
await testInfo.attach("outliner-metrics-web", { body: JSON.stringify({ golden, measured }, null, 2), contentType: "application/json" });
|
||||
expect(measured.viewport).toEqual({ width: 1920, height: 1080 });
|
||||
expect(measured.outliner).not.toBeNull();
|
||||
expect(measured.header).not.toBeNull();
|
||||
/* The desktop Layout at 1920x1080: Outliner area 339x189, header 26,
|
||||
* row 20, indent 14 (UI_TREEVIEW_INDENT = 0.7 * UI_UNIT_X). */
|
||||
expect(Math.abs(measured.outliner!.width - golden.width)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(measured.outliner!.height - golden.height)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(measured.header!.height - golden.headerHeight)).toBeLessThanOrEqual(1);
|
||||
expect(measured.rowHeights.length).toBeGreaterThan(0);
|
||||
for (const height of measured.rowHeights) expect(Math.abs(height - golden.rowHeight)).toBeLessThanOrEqual(1);
|
||||
expect(measured.indentPerLevel).not.toBeNull();
|
||||
expect(Math.abs(measured.indentPerLevel! - golden.indentPerLevel)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
test("[outliner-mirror-baseline-web] the desktop mirror hands the Outliner to the DOM workspace", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.goto("/");
|
||||
|
||||
Reference in New Issue
Block a user