feat(web): adjustable workspace partitions, floating areas and uncluttered panels
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

- Add workspace-layout.tsx: three draggable separators (viewport/right column,
  viewport/timeline, outliner/properties) with pointer, arrow-key and
  double-click reset, remembered in one shared localStorage record.
- Areas can pop out of the grid into floating windows from the area menu; the
  same section is only re-positioned, so the WebGL canvas and editor state
  survive. Title-bar drag, corner resize, dock button and grid placeholder.
- Viewport overlays (N-panel, tool shelf, shading/navigation cluster) are
  draggable inside the viewport, with reset and a 视图 menu entry to reopen
  them.
- Remove overlap: the docked quick toolbar gets its own grid band, the area
  switcher moves into the header (and only fades in over headerless areas),
  properties controls wrap when the column narrows, the N-panel stops growing
  to 714px, and the 901-1280px media query no longer freezes the right column
  at 290px over the draggable variable.
- New spec wbv2-workspace-layout-production with evidence in
  tests/golden/WEB-WORKSPACE-LAYOUT-20261123 (NOT_CLAIMED); status doc records
  the local regressions, the A/B that pinned them and the online walk at
  1440x900 and 1280x800 on release 20261124-workinf_blender_wasm-2c8449f42.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-24 04:33:38 +08:00
parent 2c8449f422
commit 570aa2dd54
18 changed files with 1006 additions and 42 deletions

View File

@@ -0,0 +1,61 @@
# WEB-WORKSPACE-LAYOUT-20261124 status
- case: `WEB-WORKSPACE-LAYOUT-20261124`(网页 Blender 面板可拖拽、布局可调整、区域可弹出为浮动窗口、面板内部控件不再互相遮挡)
- 类型:用户案例补缺。用户原话:“完善‘web blender’的页面,实现网页上面的控制面板可以拖拽,面板固定会影响三维设计场景查看。优化面板布局,面板内部控件不要互相遮挡,布局合理,方便使用。”
- 范围(经用户确认):
- **分区可拖**:视口↔右栏、视口↔时间线、大纲↔属性三条分隔条;
- **视口浮层可拖**:N 面板、工具架、着色/导航按钮簇;
- **区域可弹出为浮动窗口**:任意区域菜单「浮动为独立窗口 / 停靠回布局」;
- 位置记忆**全局共用一份**(所有工作区共享),带一键复位。
- 计划:`/home/mes123456/.claude/plans/dynamic-foraging-sundae.md`(已批准);上一批浮层拖动见 `docs/status/WEB-PANEL-DRAG-20261123.md`。
## 改动文件
| 文件 | 改动 |
| --- | --- |
| `web/app/src/app/workspace-layout.tsx`(新增) | 布局状态与持久化(localStorage `web-blender.workspace-layout.v1`,纯 UI 偏好,工程数据仍只走 OPFS)、`splitStyle()` CSS 变量、`<WorkspaceSplitters/>` 三条分隔条(指针拖拽 + 方向键 ±16 / Shift ±48 + Home/双击复位 + `ResizeObserver` 重测)。钳制:右栏 240–50vw、时间线 48–40vh、大纲占比 0.2–0.8。 |
| `web/app/src/app/WasmWorkspace.tsx` | 网页模式 `.workspace-grid` 写入 `splitStyle(splits)` 并渲染 `<WorkspaceSplitters/>`。原生/custom 布局不受影响。 |
| `web/app/src/main.tsx` | `<App>` 外层挂 `WorkspaceLayoutProvider`。 |
| `web/app/src/app/App.tsx` | ① 区域浮动窗口:同一 `section.area-frame` 改为 `position:fixed`(不 portal、不重挂载,WebGL 上下文与文本草稿保留),标题栏拖动、右下角缩放手柄、停靠按钮、网格占位块「已弹出为浮动窗口 · 停靠回布局」;② 区域菜单新增「浮动为独立窗口 / 停靠回布局」;③ 视口浮层接入 `useDraggablePanel`:N 面板(新增关闭 ×)、工具架、着色+导航合并为一个可拖簇;④ 「视图」菜单新增「侧栏 (N)」「工具架 (T)」,为已关闭的浮层提供恢复入口;⑤ 「窗口 → 恢复默认面板位置」同时复位分区尺寸与浮窗;⑥ 区域编辑器切换器改为:有标题栏的区域放进标题栏,无标题栏的区域(视口/时间线/节点/控制台等)才悬浮,且每个区域只保留一个 ⋮ 菜单。 |
| `web/app/src/app/use-draggable-panel.ts` | 新增可选 `bounds` 钳制:视口浮层必须整体留在 `.viewport-placeholder` 内(该容器 `overflow:hidden`,旧的全窗口钳制会把面板推到看不见的位置);泛型化 `panelRef`。 |
| `web/app/src/app/app-shell.css` | 网格轨道改为 `--ws-*` 变量且默认值与旧值逐像素一致;分隔条样式(默认透明,悬停/拖动/聚焦显示 2px 蓝线);浮窗与占位块样式;视口浮层把手样式;**快捷操作栏停靠时占用独立网格行**(不再压住各区域顶部);区域切换器默认只在悬停/聚焦时出现;属性栏窄化换行与 `min-width:0`;N 面板 `max-height` + 滚动;901–1280px 的右栏宽度改用变量(原为写死 290px,会覆盖拖动结果)。 |
| `web/app/src/app/desktop-menus.css` | 状态栏隐藏时的网格行同步快捷操作栏行高。 |
| `web/tests/e2e/wbv2-workspace-layout-production.spec.ts`(新增) | 三条用例:分隔条拖动/持久化/键盘微调/双击复位;区域浮出/拖动/停靠;视口浮层拖动、N 面板关闭与恢复、浮层始终留在视口内。 |
| `tests/golden/WEB-WORKSPACE-LAYOUT-20261123/` | 证据:`splits.json`、`floating-area.json`、`floating-properties.png`、`viewport-overlays.json`,均 `acceptance: "NOT_CLAIMED"`。 |
## 过程中发现并处理的既有或自引入缺口
1. **901–1280px 窗口下右栏宽度写死 `290px`**(`app-shell.css` 媒体查询):会覆盖拖拽变量,使分隔条在这个区间完全无效。改为 `var(--ws-right-width, 290px)`,并让首次加载在 ≤1280px 时仍以 290px 起步,窄窗口观感不变。
2. **区域切换器压住标题栏自己的 ⋮ 菜单**(自引入):首个版本把切换器叠在标题栏右上角,Playwright 报 “subtree intercepts pointer events”,用户也点不到菜单。改为切换器进标题栏;旧用例要求切换器内仍有 ⋮,故保留切换器内的 ⋮、标题栏不再重复渲染一个。
3. **视口标题栏并非所有工作区都隐藏**(自引入后发现):`[data-workspace="Scripting"] .viewport-area > .editor-header { display:flex }`。第一版按类名一刀切删掉视口标题栏,`web-manual-ui-gaps.spec.ts` 在 HEAD 上通过、在我的改动上失败;A/B(`git stash` 后仅跑该用例)确认属回归。改为由 `AreaEditorContext.workspace` 决定。
4. **快捷操作栏停靠时覆盖各区域顶部约 35px**(既有):改为 `.blender-app` 网格里的独立行,折叠时 24px、浮出时为 0;`.render-result-view` 不再需要 `padding-top:35px` 补偿。
5. **N 面板被本身内容撑到 714px 宽**(既有,线上实测发现):`.viewport-sidebar` 没有宽度约束,着色分组的 `select` 把它撑到 509px,整个面板占去视口 70% 以上,正是用户说的“面板影响查看三维场景”。给面板加 `max-width: min(70%, 420px)`、着色分组固定 200px 并允许内部换行;实测宽度 714 → 407px,并加进本次用例断言(`≤424px`)。
## 流程与结果(Chromium,OPFS,开发服务器)
1. `cd web && npm run typecheck`:通过(exit 0,多轮)。
2. `npx playwright test tests/e2e/wbv2-workspace-layout-production.spec.ts --workers=1`:
- `partition splitters resize, persist and reset the workspace areas` — 拖右栏分隔条 → `splits.rightWidth` 由 320 变为 456 → `.properties-area` 加宽、视口变窄 → 拖时间线上移 → 时间线变高 → `reload` 后尺寸保持 → 方向键 → 双击复位回 320。
- `an area pops out as a floating window and docks back` — 属性区菜单「浮动为独立窗口」→ `position:fixed`、`data-floating="true"`、占位块出现、入 localStorage → 拖标题栏 (140,80) → 停靠回网格、`floating` 清空。
- `viewport overlays move out of the model and stay inside the viewport` — N 面板拖动后仍在视口矩形内 → × 关闭 → 「视图 → 侧栏」恢复 → 复位;着色簇与导航簇纵向不重叠;整簇拖动入库;「视图 → 工具架」打开工具架并可拖动标题栏;无 `pageerror`。
3. 回归(`--workers=1`):
- `web-area-layout.spec.ts`(2)、`web-manual-ui-gaps.spec.ts`(2)、`wbv2-panel-drag-production.spec.ts`(3)、`wbv2-adjust-last-operation-production.spec.ts`(1)、`pbr-tutorial-accessibility`(1)、`parts-tutorial-accessibility`(1)→ 全部通过。
- A/B:`web-area-layout` + `web-manual-ui-gaps` 在 HEAD(`git stash` 掉本次全部源码改动)上 4 passed,证明失败来自本次改动,已按源码修正而非改断言。
- `wbv2-pbr-tutorial-production.spec.ts`:`1 passed (2.2m)`(12 个步骤全部演示通过,无 `.blend` 自动下载)。
4. 发布与线上复验:
- `BW_DEPLOY_PASSWORD=… tools/web/deploy-58014.sh` → release `20261124-workinf_blender_wasm-2c8449f42`,`health=200`、`index=200`,wasm 本地/远程哈希一致(`9febac5d…c31a2c`),`studios=200`;N 面板宽度修复后按同一 release id 重新上传切换一次(`current` 指向同一路径,`health=200`)。
- 线上 Chromium 实走(1440×900,`https://49.232.250.35:58014/?ui=web` + `basic_scene.blend`):拖右栏分隔条 → `.properties-area` 320 → 430px,`localStorage` 记录 `rightWidth:430`;属性区「浮动为独立窗口」→ `position:fixed` → 拖标题栏 (120,70) → 位置随之变化 → 「停靠回布局」→ 浮窗记录清空;N 面板拖动入库 `{x:-2,y:50}` 且整体仍在视口内;无 `pageerror`。证据:`tests/golden/WEB-WORKSPACE-LAYOUT-20261123/online-verification.json`、`online-floating-properties.png`、`online-workspace-layout.png`。
- 线上小窗口复验(1280×800,同一 release):右栏初始 290px(媒体查询默认),拖动分隔条后 320→400px 且 `localStorage` 记录 `rightWidth:400`,浮窗与 N 面板同样正常;证据 `online-verification-1280.json`。修复前该区间拖动完全无效。
- 线上检查脚本必须沿用 `tools/web/check-deployed-web-blender.mjs` 的 Chromium 参数(含 `--enable-unsafe-webgpu --use-webgpu-adapter=swiftshader`):缺这些参数时引擎停在 “WASM: starting”,与产品无关。
## 未验证 / 剩余缺口
- 触摸/笔输入下的拖动、分隔条双指缩放未在真机验证(仅 Chromium 鼠标指针)。
- 浮动窗口在多显示器/负坐标(`window.screenX < 0`)下的行为未验证;钳制以当前窗口为准。
- 原生模式(`?ui=desktop` / `localOnly`)下区域由原生屏幕矩形驱动,分隔条按设计不渲染;原生模式下把区域浮动为窗口只改变显示位置,未在原生会话里实测。
- 除 `Layout` 外的工作区使用各自固定模板(如 Modeling 的 `190px` 行),分隔条在这些工作区不渲染;这些模板是否需要同样可调,留给用户使用后决定。
- 「恢复默认面板位置」复位面板偏移、分区尺寸与浮窗,但不复位时间线 dock 的独立位置(沿用上一批的遗留项)。
## 验收
`NOT_CLAIMED`。

View File

@@ -0,0 +1,23 @@
{
"schemaVersion": 1,
"browser": "chromium",
"storage": "OPFS",
"workflow": "properties area menu -> 浮动为独立窗口 -> drag title bar -> dock",
"floating": {
"position": "fixed",
"rect": {
"x": 1280,
"y": 353,
"width": 320,
"height": 627
}
},
"moved": {
"x": 1420,
"y": 433,
"width": 320,
"height": 627
},
"status": "PASS",
"acceptance": "NOT_CLAIMED"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

View File

@@ -0,0 +1,59 @@
{
"schemaVersion": 1,
"browser": "chromium",
"storage": "OPFS",
"origin": "https://49.232.250.35:58014",
"workflow": "splitter drag -> properties float + move + dock -> N-panel drag (online release 20261124-workinf_blender_wasm-2c8449f42)",
"beforeProperties": {
"x": 990,
"y": 286,
"width": 290,
"height": 494
},
"afterProperties": {
"x": 880,
"y": 286,
"width": 400,
"height": 494
},
"splits": {
"rightWidth": 400,
"timelineHeight": 108,
"outlinerShare": 0.3333333333333333
},
"floatingPosition": "fixed",
"floatingRect": {
"x": 880,
"y": 286,
"width": 400,
"height": 494
},
"floatedMoved": {
"x": 1000,
"y": 356,
"width": 400,
"height": 494
},
"dockedFloating": 0,
"viewportRect": {
"x": 0,
"y": 93,
"width": 879,
"height": 578
},
"sidebarRect": {
"x": 470,
"y": 411,
"width": 407,
"height": 258
},
"offsets": {
"viewport-n-panel": {
"x": -2,
"y": 6
}
},
"pageErrors": [],
"status": "PASS",
"acceptance": "NOT_CLAIMED"
}

View File

@@ -0,0 +1,59 @@
{
"schemaVersion": 1,
"browser": "chromium",
"storage": "OPFS",
"origin": "https://49.232.250.35:58014",
"workflow": "splitter drag -> properties float + move + dock -> N-panel drag (online release 20261124-workinf_blender_wasm-2c8449f42)",
"beforeProperties": {
"x": 1120,
"y": 320,
"width": 320,
"height": 560
},
"afterProperties": {
"x": 1010,
"y": 320,
"width": 430,
"height": 560
},
"splits": {
"rightWidth": 430,
"timelineHeight": 108,
"outlinerShare": 0.3333333333333333
},
"floatingPosition": "fixed",
"floatingRect": {
"x": 1010,
"y": 320,
"width": 430,
"height": 560
},
"floatedMoved": {
"x": 1130,
"y": 390,
"width": 430,
"height": 560
},
"dockedFloating": 0,
"viewportRect": {
"x": 0,
"y": 93,
"width": 1009,
"height": 678
},
"sidebarRect": {
"x": 600,
"y": 455,
"width": 407,
"height": 293
},
"offsets": {
"viewport-n-panel": {
"x": -2,
"y": 50
}
},
"pageErrors": [],
"status": "PASS",
"acceptance": "NOT_CLAIMED"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@@ -0,0 +1,51 @@
{
"schemaVersion": 1,
"browser": "chromium",
"storage": "OPFS",
"workflow": "/?ui=web + basic_scene.blend -> drag right/timeline splitters -> reload -> ArrowRight -> double-click reset",
"before": {
"viewport": {
"x": 0,
"y": 93,
"width": 1279,
"height": 778
},
"properties": {
"x": 1280,
"y": 353,
"width": 320,
"height": 627
},
"timeline": {
"x": 0,
"y": 872,
"width": 1279,
"height": 108
}
},
"widened": {
"x": 1160,
"y": 353,
"width": 440,
"height": 627
},
"taller": {
"x": 0,
"y": 832,
"width": 1159,
"height": 148
},
"reloaded": {
"x": 1160,
"y": 339.65625,
"width": 440,
"height": 640.34375
},
"splits": {
"rightWidth": 320,
"timelineHeight": 108,
"outlinerShare": 0.3333333333333333
},
"status": "PASS",
"acceptance": "NOT_CLAIMED"
}

View File

@@ -0,0 +1,53 @@
{
"schemaVersion": 1,
"browser": "chromium",
"storage": "OPFS",
"workflow": "drag N-panel -> close/reopen with N -> reset -> drag quick tools -> T shelf -> drag header",
"viewportRect": {
"x": 0,
"y": 93,
"width": 1279,
"height": 778
},
"movedSidebar": {
"x": 870,
"y": 465,
"width": 407,
"height": 293
},
"movedQuick": {
"x": 1102.9375,
"y": 221,
"width": 34.0625,
"height": 354
},
"shading": {
"x": 1229,
"y": 209,
"width": 28,
"height": 61
},
"navigation": {
"x": 1229,
"y": 276,
"width": 28,
"height": 259
},
"offsets": {
"sidebar": {
"x": 0,
"y": 0
},
"quick": {
"x": -120,
"y": 40
},
"shelf": {
"x": 40,
"y": 2
}
},
"pageErrors": [],
"status": "PASS",
"acceptance": "NOT_CLAIMED"
}

View File

@@ -14,6 +14,7 @@ import {recoverDesktop,saveDesktop} from './desktop-workspace-storage';
import {NativeResourceClient} from '../engine-client/NativeResourceClient';
import { COURSES, type AvailableCourseId } from "../tutorial/course";
import { resetAllPanelOffsets, useDraggablePanel } from "./use-draggable-panel";
import { resetWorkspaceLayout, useWorkspaceLayout } from "./workspace-layout";
import { TutorialOverlay } from "../tutorial/TutorialOverlay";
import type { PbrCameraMode, PbrResolution, TutorialApi, TutorialContext, TutorialRenderResult } from "../tutorial/parts/types";
import type {NativeExportFormat} from '../../../protocol/native-workflow';
@@ -49,7 +50,7 @@ import type {NativeSessionCommand} from '../../../protocol/native-workflow';
import type { NativeWorkflowContext, NativeWorkflowInput } from '../../../protocol/native-workflow';
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState, type PointerEvent as ReactPointerEvent } from "react";
import { createPortal, flushSync } from "react-dom";
import { WebEngineClient, type BlendOpenResult } from "../engine-client/WebEngineClient";
import {runEmbeddedRender} from '../engine-client/embedded-render';
@@ -1282,6 +1283,8 @@ const AREA_EDITOR_CHOICES: EditorType[] = [
];
interface AreaEditorContextValue {
/** Current workspace; decides whether an area's header is displayed. */
workspace: WorkspaceId;
overrides: Record<string, EditorType>;
setOverride: (areaKey: string, editor: EditorType | null) => void;
render: (editor: EditorType, areaKey: string) => React.ReactNode;
@@ -1293,6 +1296,9 @@ interface AreaEditorContextValue {
resetLayout: () => void;
}
const AreaEditorContext = createContext<AreaEditorContextValue | null>(null);
/** Areas whose `.editor-header` is hidden by app-shell.css in every workspace. */
const AREA_HEADERLESS = new Set(["image-editor-area", "render-result-area", "node-editor-area", "file-browser-area",
"spreadsheet-area", "text-editor-area", "console-area", "info-area"]);
function activeViewportCanvas():HTMLCanvasElement|null {
return document.querySelector<HTMLCanvasElement>('canvas.viewport-canvas:focus') ??
@@ -1324,6 +1330,9 @@ const EDITOR_ICONS: Record<EditorType, string> = {
function Area({ className = "", editor, children, areaId }: AreaProps) {
const context = useContext(AreaEditorContext);
const workspaceLayout = useWorkspaceLayout();
const floatDrag = useRef<{ pointerId: number; startX: number; startY: number; originX: number; originY: number } | null>(null);
const floatResize = useRef<{ pointerId: number; startX: number; startY: number; startW: number; startH: number } | null>(null);
const areaKey = areaId ?? (className || editor);
const layout = context?.layoutFor(areaKey) ?? null;
const activeDefault = layout?.editor ?? editor;
@@ -1333,13 +1342,56 @@ function Area({ className = "", editor, children, areaId }: AreaProps) {
if (custom && !layout) return null;
if (custom && layout && !layout.maximized && context?.areas.some((area) => area.maximized)) return null;
const rect = layout?.rect;
const style = custom && layout?.maximized ? { left: "0%", top: "0%", width: "100%", height: "100%" } : custom && rect ? {
const targetId = layout?.id ?? areaKey;
/* An area can be pulled out of the grid into its own floating window. It is
* the same React section, only re-positioned, so the WebGL canvas, text
* drafts and scroll positions are never remounted. */
const floatRect = workspaceLayout.state.floating[targetId] ?? null;
/* Mirrors the `editor-header { display: none }` rules in app-shell.css: areas
* without a header keep the floating editor switcher, the rest carry it in
* the header so it cannot sit on top of the header's own buttons. */
const headerHidden = !floatRect && (AREA_HEADERLESS.has(className) ||
((className === "viewport-area" || className === "timeline-area") && context?.workspace !== "Scripting"));
const style = floatRect ? { position: "fixed" as const, left: `${floatRect.x}px`, top: `${floatRect.y}px`, width: `${floatRect.width}px`, height: `${floatRect.height}px`, zIndex: 70 } : custom && layout?.maximized ? { left: "0%", top: "0%", width: "100%", height: "100%" } : custom && rect ? {
left: `${rect.x * 100}%`,
top: `${(1 - rect.y - rect.height) * 100}%`,
width: `${rect.width * 100}%`,
height: `${rect.height * 100}%`,
} : undefined;
const targetId = layout?.id ?? areaKey;
const floatNow = () => {
const node = document.querySelector<HTMLElement>(`[data-web-area-id="${targetId}"]`);
const current = node?.getBoundingClientRect();
workspaceLayout.floatArea(targetId, current
? { x: Math.round(current.left), y: Math.round(current.top), width: Math.round(current.width), height: Math.round(current.height) }
: { x: 80, y: 80, width: 720, height: 480 });
};
const startFloatDrag = (event: ReactPointerEvent<HTMLElement>) => {
if (event.button !== 0 || !floatRect) return;
if ((event.target as HTMLElement).closest("button, select, .desktop-menu-trigger")) return;
floatDrag.current = { pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, originX: floatRect.x, originY: floatRect.y };
event.currentTarget.setPointerCapture(event.pointerId);
};
const moveFloatDrag = (event: ReactPointerEvent<HTMLElement>) => {
const drag = floatDrag.current;
if (!drag || drag.pointerId !== event.pointerId || !floatRect) return;
/* Keep part of the title bar reachable, like the other floating panels. */
const x = Math.round(Math.min(Math.max(drag.originX + event.clientX - drag.startX, 64 - floatRect.width / 2), window.innerWidth - 160));
const y = Math.round(Math.min(Math.max(drag.originY + event.clientY - drag.startY, 0), window.innerHeight - 60));
workspaceLayout.moveFloating(targetId, { x, y, width: floatRect.width, height: floatRect.height });
};
const endFloatDrag = (event: ReactPointerEvent<HTMLElement>) => {
if (floatDrag.current?.pointerId !== event.pointerId && floatResize.current?.pointerId !== event.pointerId) return;
floatDrag.current = null;
floatResize.current = null;
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
};
const moveFloatResize = (event: ReactPointerEvent<HTMLElement>) => {
const drag = floatResize.current;
if (!drag || drag.pointerId !== event.pointerId || !floatRect) return;
const width = Math.round(Math.min(Math.max(drag.startW + event.clientX - drag.startX, 240), window.innerWidth - floatRect.x));
const height = Math.round(Math.min(Math.max(drag.startH + event.clientY - drag.startY, 160), window.innerHeight - floatRect.y));
workspaceLayout.moveFloating(targetId, { x: floatRect.x, y: floatRect.y, width, height });
};
const neighbors = context?.neighbors(targetId) ?? { LEFT: null, RIGHT: null, UP: null, DOWN: null };
const directionLabel: Record<AreaDirection, string> = { LEFT: "左", RIGHT: "右", UP: "上", DOWN: "下" };
const areaMenuItems: DesktopMenuItem[] = context ? [
@@ -1360,44 +1412,59 @@ function Area({ className = "", editor, children, areaId }: AreaProps) {
{ label: "", separator: true },
{ label: layout?.maximized ? "还原大小" : "最大化区域", action: () => context.dispatchArea(targetId, { type: "TOGGLE_MAXIMIZE_AREA", areaId: targetId }) },
{ label: "聚焦模式", action: () => context.dispatchArea(targetId, { type: "TOGGLE_FULLSCREEN_AREA", areaId: targetId }) },
{ label: floatRect ? "停靠回布局" : "浮动为独立窗口", action: () => { if (floatRect) workspaceLayout.dockArea(targetId); else floatNow(); } },
{ label: "关闭区域", disabled: context.areas.length <= 1, reason: "至少保留一个区域", action: () => context.dispatchArea(targetId, { type: "CLOSE_AREA", areaId: targetId }) },
{ label: "", separator: true },
{ label: "重置工作区布局", action: () => context.resetLayout() },
] : [];
const newAreaContent = children === undefined && context ? context.render(activeEditor, areaKey) : children;
const useDefaultContent = override ? false : layout ? (layout.editor === editor && children !== undefined) : children !== undefined;
/* One editor switcher per area: it lives in the header where there is one,
* and floats over the content only where the header is hidden. */
const switcher = (className || areaId) && context ? (
<div className="area-type-switch" title="切换该区域的编辑器类型">
<span aria-hidden="true">{EDITOR_ICONS[activeEditor]}</span>
<select aria-label={`切换 ${editor} 编辑器`} value={activeEditor} onChange={(event) => {
const next = event.target.value as EditorType;
if (custom) context.dispatchArea(targetId, { type: "SET_AREA_EDITOR", areaId: targetId, editor: next });
else context.setOverride(className, next === editor ? null : next);
}}>
{AREA_EDITOR_CHOICES.map((choice) => <option key={choice} value={choice}>{choice}{choice === editor ? "(默认)" : ""}</option>)}
</select>
<DesktopMenu className="area-menu" label="⋮" items={areaMenuItems} />
</div>
) : null;
return (
<>
{floatRect && !custom ? <div className={`area-dock-placeholder ${className}`}><button type="button" onClick={() => workspaceLayout.dockArea(targetId)}>已弹出为浮动窗口 · 停靠回布局</button></div> : null}
<section
className={`area-frame ${className}`}
className={`area-frame ${className}${floatRect ? " is-floating" : ""}`}
data-editor={activeEditor}
data-default-editor={editor}
data-web-area-id={targetId}
data-content-key={className || undefined}
data-floating={floatRect ? "true" : undefined}
style={style}
>
{(className || areaId) && context ? (
<div className="area-type-switch" title="切换该区域的编辑器类型">
<span aria-hidden="true">{EDITOR_ICONS[activeEditor]}</span>
<select aria-label={`切换 ${editor} 编辑器`} value={activeEditor} onChange={(event) => {
const next = event.target.value as EditorType;
if (custom) context.dispatchArea(targetId, { type: "SET_AREA_EDITOR", areaId: targetId, editor: next });
else context.setOverride(className, next === editor ? null : next);
}}>
{AREA_EDITOR_CHOICES.map((choice) => <option key={choice} value={choice}>{choice}{choice === editor ? "(默认)" : ""}</option>)}
</select>
<DesktopMenu className="area-menu" label="⋮" items={areaMenuItems} />
</div>
) : null}
<header className="editor-header">
{headerHidden ? switcher : null}
{headerHidden ? null : <header className="editor-header" title={floatRect ? "拖动标题栏移动浮动窗口" : undefined}
onPointerDown={floatRect ? startFloatDrag : undefined} onPointerMove={floatRect ? moveFloatDrag : undefined}
onPointerUp={floatRect ? endFloatDrag : undefined} onPointerCancel={floatRect ? endFloatDrag : undefined}>
{floatRect ? <span className="area-float-grip" aria-hidden="true">⠿</span> : null}
<button className="editor-selector" type="button" aria-label={`切换 ${editor} 编辑器`}>
<span className="editor-icon" aria-hidden="true">{EDITOR_ICONS[editor]}</span>
<span>{editor}</span>
</button>
<span className="header-spacer" />
<DesktopMenu className="area-menu" label="⋮" items={areaMenuItems} />
</header>
{floatRect ? <button type="button" className="area-float-dock" aria-label="停靠回布局" title="停靠回布局" onClick={() => workspaceLayout.dockArea(targetId)}>⤢</button> : null}
{switcher ?? <DesktopMenu className="area-menu" label="⋮" items={areaMenuItems} />}
</header>}
<div className="area-content">{useDefaultContent ? newAreaContent : context!.render(activeEditor, areaKey)}</div>
{floatRect ? <span className="area-float-resize" role="separator" aria-label="调整浮动窗口大小" title="拖动调整窗口大小"
onPointerDown={(event) => { if (event.button !== 0 || !floatRect) return; floatResize.current = { pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, startW: floatRect.width, startH: floatRect.height }; event.currentTarget.setPointerCapture(event.pointerId); }}
onPointerMove={moveFloatResize} onPointerUp={endFloatDrag} onPointerCancel={endFloatDrag} /> : null}
</section>
</>
);
}
@@ -1709,6 +1776,27 @@ function ViewportPlaceholder({ snapshot, geometryBuffers, nonMeshGeometryBuffers
* region toggles (wm.context_toggle space_data.show_region_*). */
const [toolShelfOpen, setToolShelfOpen] = useState(false);
const [sidePanelOpen, setSidePanelOpen] = useState(true);
/* Viewport overlays: keep them inside the viewport box, which clips overflow. */
const viewportOverlayBounds = (panel: HTMLElement) => {
const host = panel.closest<HTMLElement>(".viewport-placeholder");
if (!host) return null;
const rect = host.getBoundingClientRect();
return { left: rect.left + 2, top: rect.top + 2, right: rect.right - 2, bottom: rect.bottom - 2 };
};
const toolShelfDrag = useDraggablePanel("viewport-tool-shelf", { bounds: viewportOverlayBounds });
const sidePanelDrag = useDraggablePanel("viewport-n-panel", { bounds: viewportOverlayBounds });
const quickToolsDrag = useDraggablePanel<HTMLDivElement>("viewport-quick-tools", { bounds: viewportOverlayBounds });
const overlayDragStyle = (offset: { x: number; y: number }) => offset.x || offset.y ? { transform: `translate(${offset.x}px, ${offset.y}px)` } : undefined;
/* 视图 → 侧栏 / 工具架: the menus live in App, the visibility state here. */
useEffect(() => {
const onToggle = (event: Event) => {
const kind = (event as CustomEvent).detail;
if (kind === "side-panel") setSidePanelOpen(open => !open);
else if (kind === "tool-shelf") setToolShelfOpen(open => !open);
};
window.addEventListener("web-blender:viewport-overlay-toggle", onToggle);
return () => window.removeEventListener("web-blender:viewport-overlay-toggle", onToggle);
}, []);
const cycleShadingModeRef = useRef<() => void>(() => {});
const shadingModeRef = useRef<"WIREFRAME" | "SOLID" | "MATERIAL" | "RENDERED">("MATERIAL");
const xrayRef = useRef(false);
@@ -2084,6 +2172,8 @@ function ViewportPlaceholder({ snapshot, geometryBuffers, nonMeshGeometryBuffers
return <button key={axis+sign} type="button" className={`view-axis axis-${axis.toLowerCase()}${sign<0?' negative':''}`} aria-label={`${sign>0?'+':'-'}${axis} ${command}`} title={`${command} (${sign>0?'+':'-'}${axis})`} style={{left:navHalf+`${(direction[0]*navRadius*sign).toFixed(1)}px`,top:navHalf+`${(-direction[1]*navRadius*sign).toFixed(1)}px`,zIndex:direction[2]*sign>0?2:1}} onClick={()=>navigate(navigationView.view===command?opposite:command)}>{sign>0?axis:'−'+axis}</button>;
})}
</div>; })()}
<div className="viewport-quick-tools" ref={quickToolsDrag.panelRef} data-draggable-panel data-dragging={quickToolsDrag.dragging || undefined} style={overlayDragStyle(quickToolsDrag.offset)}>
<div className="viewport-quick-tools-handle" {...quickToolsDrag.handle} title="拖动视图工具(双击复位)"><span aria-hidden="true">⠿</span><button type="button" aria-label="复位视图工具位置" title="复位位置" disabled={!quickToolsDrag.offset.x && !quickToolsDrag.offset.y} onClick={quickToolsDrag.reset}>⌖</button></div>
<div className="viewport-shading-tools" role="toolbar" aria-label="视口着色">
<button type="button" aria-label="着色模式" title={`着色模式:${{ WIREFRAME: '线框', SOLID: '实体', MATERIAL: '材质', RENDERED: '渲染' }[shadingMode]}`} aria-pressed={shadingMode !== 'MATERIAL'} onClick={() => cycleShadingMode()}>{
{ WIREFRAME: '◫', SOLID: '◼', MATERIAL: '◍', RENDERED: '◉' }[shadingMode]}</button>
@@ -2097,12 +2187,13 @@ function ViewportPlaceholder({ snapshot, geometryBuffers, nonMeshGeometryBuffers
<button type="button" aria-label="相机对齐视图" title="对齐相机到视图 (Ctrl+Alt+小键盘 0)" onClick={()=>navigate('CAMERA_TO_VIEW')}>⌾</button>
<button type="button" aria-label="锁定相机" title="Camera to View(锁定相机到视图)" aria-pressed={Boolean(cameraLocked)} onClick={()=>{const next=!cameraLocked;onCameraLockChangeRef.current?.(next);rendererRef.current?.setCameraLock?.(next);}}>🔒</button>
</div>
</div>
{viewportError ? <div className="viewport-message"><strong>3D Viewport</strong><span>WebGL 不可用,已保留场景编辑界面:{viewportError}</span></div> : null}
{editMode && activeTool === "marquee" && marqueeDrawing ? <div className="grease-pencil-marquee-surface" data-testid="grease-pencil-marquee-surface" data-drawing-id={marqueeDrawing.drawingId} onPointerDown={beginMarquee} onPointerMove={moveMarquee} onPointerUp={finishMarquee} onPointerCancel={finishMarquee}>{marqueeBox ? <span className="grease-pencil-marquee-box" style={{ left: `${marqueeBox.left * 100}%`, top: `${marqueeBox.top * 100}%`, width: `${(marqueeBox.right - marqueeBox.left) * 100}%`, height: `${(marqueeBox.bottom - marqueeBox.top) * 100}%` }} /> : null}</div> : null}
{activeTool === "box" && snapshot ? <div className="viewport-box-select-surface" data-testid="viewport-box-select-surface" onPointerDown={beginBoxSelect} onPointerMove={moveBoxSelect} onPointerUp={finishBoxSelect} onPointerCancel={finishBoxSelect}>{boxSelectRect ? <span className="viewport-box-select-rect" style={{ left: `${boxSelectRect.left}px`, top: `${boxSelectRect.top}px`, width: `${boxSelectRect.width}px`, height: `${boxSelectRect.height}px` }} /> : null}</div> : null}
{brushCursor ? <div className="sculpt-brush-cursor" data-testid="sculpt-brush-cursor" aria-hidden="true" style={{ left: brushCursor.left, top: brushCursor.top, width: brushCursor.radius * 2, height: brushCursor.radius * 2 }} /> : null}
{toolShelfOpen ? <aside className="viewport-tool-shelf" role="toolbar" aria-label="视口工具架" data-tool-shelf-mode={mode}>
<header><strong>工具</strong><button type="button" aria-label="收起工具架" title="收起工具架 (T)" onClick={() => setToolShelfOpen(false)}>×</button></header>
{toolShelfOpen ? <aside className="viewport-tool-shelf" role="toolbar" aria-label="视口工具架" data-tool-shelf-mode={mode} ref={toolShelfDrag.panelRef} data-draggable-panel data-dragging={toolShelfDrag.dragging || undefined} style={overlayDragStyle(toolShelfDrag.offset)}>
<header {...toolShelfDrag.handle} title="拖动工具架(双击复位)"><span className="viewport-overlay-grip" aria-hidden="true">⠿</span><strong>工具</strong><button type="button" aria-label="复位工具架位置" title="复位位置" disabled={!toolShelfDrag.offset.x && !toolShelfDrag.offset.y} onClick={toolShelfDrag.reset}>⌖</button><button type="button" aria-label="收起工具架" title="收起工具架 (T)" onClick={() => setToolShelfOpen(false)}>×</button></header>
{mode === "Edit" ? <>
<fieldset><legend>选择模式</legend>{(["VERT","EDGE","FACE"] as const).map((item, index) => <button key={item} type="button" aria-label={`工具架 ${["顶点","边","面"][index]}选择`} aria-pressed={meshSelection.mode === item} onClick={() => onMeshSelectionMode?.(item)}>{["顶点","边","面"][index]}</button>)}</fieldset>
<fieldset><legend>网格</legend><button type="button" aria-label="工具架 全选" onClick={() => onSelectAllMeshElements?.()}>全选</button>{([["MERGE","合并"],["DISSOLVE","溶解"],["EXTRUDE","挤出"],["INSET","内插"],["BEVEL","倒角"],["SUBDIVIDE","细分"],["FILL","填充"],["TRIANGULATE","三角化"],["DELETE","删除"]] as const).map(([operation, label]) => <button key={operation} type="button" aria-label={`工具架 ${label}`} disabled={!onMeshEdit || meshSelection.indices.size === 0} onClick={() => onMeshEdit?.(operation as MeshEditOperation)}>{label}</button>)}</fieldset>
@@ -2169,7 +2260,8 @@ function ViewportPlaceholder({ snapshot, geometryBuffers, nonMeshGeometryBuffers
target.addEventListener("pointerup", finish);
target.addEventListener("pointercancel", finish);
}}>{"XYZ"[axis]}</button>)}</div> : null}
<aside className="viewport-sidebar" aria-label="视口侧栏">
<aside className="viewport-sidebar" aria-label="视口侧栏" ref={sidePanelDrag.panelRef} data-draggable-panel data-dragging={sidePanelDrag.dragging || undefined} style={overlayDragStyle(sidePanelDrag.offset)}>
<div className="viewport-sidebar-grip" {...sidePanelDrag.handle} title="拖动侧栏(双击复位)"><span aria-hidden="true">⠿</span><button type="button" aria-label="复位侧栏位置" title="复位位置" disabled={!sidePanelDrag.offset.x && !sidePanelDrag.offset.y} onClick={sidePanelDrag.reset}>⌖</button><button type="button" aria-label="关闭侧栏" title="关闭侧栏 (N)" onClick={() => setSidePanelOpen(false)}>×</button></div>
{(() => {
const active = snapshot?.nodes.find((node) => node.id === snapshot.activeObjectId);
if (!active || !onSetObjectTransform) return <span>Item</span>;
@@ -9139,7 +9231,7 @@ else:
'窗口':[menuAction('新建窗口',()=>{window.open(window.location.href,'_blank','noopener');}),{...menuAction('切换全屏',()=>{void toggleBrowserFullscreen();},fullscreenPending||(!browserFullscreen&&!document.fullscreenEnabled)),checked:browserFullscreen,reason:fullscreenPending?'全屏切换进行中':!browserFullscreen&&!document.fullscreenEnabled?'浏览器当前不允许全屏':undefined},separator,
menuAction('完整桌面工作区',()=>{void openFullDesktop();},!hasProject),separator,menuAction('下一个工作区',()=>cycleWorkspace(1)),menuAction('上一个工作区',()=>cycleWorkspace(-1)),{label:'编辑器',children:NATIVE_EDITORS.map(item=>menuAction(item.label,()=>openNativeEditor(item.id),!hasProject))},{label:'显示状态栏',checked:showStatus,action:()=>setShowStatus(!showStatus)},separator,
menuAction('保存视口截图',()=>{const canvas=document.querySelector<HTMLCanvasElement>('canvas.viewport-canvas');if(!canvas)return;canvas.toBlob(blob=>{if(!blob)return;const url=URL.createObjectURL(blob),link=document.createElement('a');link.href=url;link.download='viewport.png';link.click();setTimeout(()=>URL.revokeObjectURL(url),1000);});},workspace==='Rendering'||new URLSearchParams(location.search).get('offscreen')==='1'),
{label:'Web 扩展',children:[menuAction('六轴机器人工具',()=>setRobotToolOpen(true)),menuAction('原生桌面会话',()=>setInteractiveDesktop({context:nativeContext()}),!hasProject),{label:'显示快捷操作栏',checked:quickTools,action:()=>setQuickTools(!quickTools)}]},menuAction('恢复默认面板位置',()=>{resetAllPanelOffsets();setQuickToolsCollapsed(false);})],
{label:'Web 扩展',children:[menuAction('六轴机器人工具',()=>setRobotToolOpen(true)),menuAction('原生桌面会话',()=>setInteractiveDesktop({context:nativeContext()}),!hasProject),{label:'显示快捷操作栏',checked:quickTools,action:()=>setQuickTools(!quickTools)}]},menuAction('恢复默认面板位置',()=>{resetAllPanelOffsets();resetWorkspaceLayout();setQuickToolsCollapsed(false);})],
'帮助':[menuAction('使用手册(网页版)',()=>{window.open('/manuals/index.html','_blank','noopener');}),menuAction('PDF 手册(旧版下载)',()=>{window.open('/manuals/WEB_Blender_Function_User_Guide.pdf','_blank','noopener');}),menuAction('菜单操作对照',()=>{window.open('/manuals/WEB_Blender_Desktop_Menus.pdf','_blank','noopener');}),menuAction('导航操作说明',()=>{window.open('/manuals/WEB_Blender_Viewport_Navigation.pdf','_blank','noopener');}),menuAction('机器人工具说明',()=>{window.open('/manuals/WEB_Blender_Robot_Tool_User_Manual.pdf','_blank','noopener');}),menuAction('零件建模教学',()=>{window.open('/?tutorial=parts','_blank','noopener');}),menuAction('二级减速器教学',()=>{window.open('/?tutorial=reducer','_blank','noopener');}),menuAction('PBR 渲染教学',()=>{window.open('/?ui=web&tutorial=pbr','_blank','noopener');}),menuAction('PBR 渲染图文/视频教案',()=>{window.open('/tutorial/pbr/render-lesson.html','_blank','noopener');}),menuAction('渲染四条通路教案',()=>{window.open('/tutorial/rendering/index.html','_blank','noopener');}),menuAction('渲染入门(四条通路实走)',()=>{window.open('/tutorial/render-basics/index.html','_blank','noopener');}),menuAction('渲染全流程实训',()=>{window.open('/?tutorial=rendering','_blank','noopener');}),menuAction('完整初学者课程(31 项能力)',()=>{window.open('/tutorial/complete/index.html','_blank','noopener');}),separator,
menuAction('导出诊断报告',exportDiagnosticReport,diagnostics.length===0),menuAction('关于 Web Blender',()=>setHeaderDialog('about'))]
};
@@ -9181,7 +9273,9 @@ else:
const viewItems:DesktopMenuItem[]=[
{label:'视角',children:([['FRONT','前视图'],['BACK','后视图'],['RIGHT','右视图'],['LEFT','左视图'],['TOP','顶视图'],['BOTTOM','底视图']] as [ViewportNavigationCommand,string][]).map(([cmd,label])=>menuAction(label,()=>navigateHeader(cmd)))},
menuAction('透视 / 正交',()=>navigateHeader('PROJECTION'),false,'Numpad 5'),menuAction('框显所选',()=>navigateHeader('FRAME_SELECTED'),!selectedObjectIds.size,'Numpad .'),menuAction('显示全部',()=>navigateHeader('FRAME_ALL'),!hasProject,'Home'),
{label:'导航',children:[menuAction('放大',()=>navigateHeader('ZOOM_IN')),menuAction('缩小',()=>navigateHeader('ZOOM_OUT'))]}];
{label:'导航',children:[menuAction('放大',()=>navigateHeader('ZOOM_IN')),menuAction('缩小',()=>navigateHeader('ZOOM_OUT'))]},
menuAction('侧栏',()=>window.dispatchEvent(new CustomEvent('web-blender:viewport-overlay-toggle',{detail:'side-panel'})),false,'N'),
menuAction('工具架',()=>window.dispatchEvent(new CustomEvent('web-blender:viewport-overlay-toggle',{detail:'tool-shelf'})),false,'T')];
const selectionItems:DesktopMenuItem[]=[menuAction('全部',()=>selectHeader('all'),!hasProject,'A'),menuAction('无',()=>selectHeader('none'),!hasProject,'Alt A'),menuAction('反选',()=>selectHeader('invert'),!hasProject,'Ctrl I')];
const parentSelectedObjects = (clear: boolean): void => {
const parent = clear ? null : snapshot?.activeObjectId;
@@ -9648,7 +9742,7 @@ else:
data-grease-pencil-selection-source={greasePencilSelection?.lastSource ?? "NONE"}
data-grease-pencil-selection-drawing-id={greasePencilSelection?.drawing.drawingId ?? ""}
data-diagnostic-count={diagnostics.length} data-last-diagnostic-code={diagnostics.at(-1)?.code} data-last-diagnostic-detail={diagnostics.at(-1)?.detail?.slice(0, 1200)}>
<AreaEditorContext.Provider value={{ overrides: areaEditorOverrides, setOverride: (areaKey, editor) => setAreaEditorOverrides(current => { const next = { ...current }; if (editor === null) delete next[areaKey]; else next[areaKey] = editor; return next; }), render: renderAreaEditor, layoutFor: areaLayoutFor, customLayout: Boolean(workspaceAreaLayout), neighbors: areaNeighbors, areas: workspaceAreaLayout ?? [], dispatchArea, resetLayout: resetAreaLayout }}>
<AreaEditorContext.Provider value={{ workspace: uiState.context.workspaceId, overrides: areaEditorOverrides, setOverride: (areaKey, editor) => setAreaEditorOverrides(current => { const next = { ...current }; if (editor === null) delete next[areaKey]; else next[areaKey] = editor; return next; }), render: renderAreaEditor, layoutFor: areaLayoutFor, customLayout: Boolean(workspaceAreaLayout), neighbors: areaNeighbors, areas: workspaceAreaLayout ?? [], dispatchArea, resetLayout: resetAreaLayout }}>
{nativeRecoveryWarning ? <aside role="alert" aria-label="恢复存储提示" style={{ position: "fixed", right: 12, bottom: 32, zIndex: 10000, maxWidth: 560, padding: 12, background: "#332b16", color: "#ffe4a3", border: "1px solid #a88635" }}><span>{nativeRecoveryWarning}</span><button type="button" aria-label="关闭恢复提示" onClick={() => setNativeRecoveryWarning(null)}>关闭提示</button></aside> : null}
<header className="topbar">
<div className="brand" title="Blender 5.2.0 LTS Web"><span className="brand-mark" aria-hidden="true"><span className="brand-orbit" /></span><span className="brand-name">Blender</span></div>

View File

@@ -1,5 +1,6 @@
import { Children, Fragment, isValidElement, useRef, useState, type ReactElement, type ReactNode } from 'react';
import type { EditorAreaIR, EditorWorkflowIR } from '../../../protocol/editor-workflow';
import { WorkspaceSplitters, splitStyle, useWorkspaceLayout } from './workspace-layout';
function editorName(area: EditorAreaIR): string {
if (area.editor === 'NODE') return area.space?.kind === 'GeometryNodeTree' ? 'Geometry Nodes' : area.space?.kind === 'CompositorNodeTree' ? 'Compositor' : area.space?.kind === 'ShaderNodeTree' ? 'Shader Editor' : 'NODE';
@@ -14,8 +15,12 @@ export function WasmWorkspace({enabled,workflow,children,renderArea,onActivate}:
}) {
const [pending,setPending]=useState(false);
const pendingRef=useRef(false);
const {state:layout}=useWorkspaceLayout();
const workspace=workflow?.workspaces.find(item=>item.id===workflow.context.workspaceId);
if(!enabled)return <div className="workspace-grid">{children}</div>;
/* Web mode: the grid tracks follow the shared split sizes, and the three
* separators let the user drag them. The custom/absolute layout and the
* native screen-rect layout do not use these tracks (splitters hidden in CSS). */
if(!enabled)return <div className="workspace-grid" style={splitStyle(layout.splits)}>{children}<WorkspaceSplitters/></div>;
if(!workspace)return <div className="wasm-source-workspace"><output>Workspace unavailable</output></div>;
const templates=new Map<string,ReactNode>();
const collect=(nodes:ReactNode)=>Children.forEach(nodes,node=>{

View File

@@ -16,7 +16,13 @@ button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #77b9f4; outline-offset: -2px; }
.blender-app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 28px 30px minmax(0, 1fr) 20px; width: 100%; height: 100vh; min-height: 480px; background: #202020; }
.blender-app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 28px calc(30px + var(--quick-tools-row, 0px)) minmax(0, 1fr) 20px; width: 100%; height: 100vh; min-height: 480px; background: #202020; }
/* The docked quick toolbar gets its own band below the toolbar instead of
floating over the top of every area. Floating or collapsed bands collapse. */
.blender-app[data-quick-tools=true]:not([data-native-canvas="true"]) { --quick-tools-row: 35px; --native-desktop-top: calc(58px + var(--quick-tools-row)); }
.blender-app[data-quick-tools=true]:not([data-native-canvas="true"]) > .workspace-toolbar { height: 30px; }
.blender-app[data-quick-tools=true]:has(> .workspace-toolbar > .legacy-quick-toolbar[data-quick-toolbar-floating="true"]) { --quick-tools-row: 0px; }
.blender-app[data-quick-tools=true]:has(> .workspace-toolbar > .legacy-quick-toolbar[data-quick-tools-collapsed="true"]) { --quick-tools-row: 24px; }
/* The native desktop layer is `position: fixed`, so it is not a grid item and
* cannot be pushed down by grid rows. It starts below the bars that stay
* visible, which is 0 only once the canvas actually owns the whole window. */
@@ -66,10 +72,26 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
.mode-chip { min-width: 86px; padding: 2px 8px; color: #e3e3e3; background: #343434 !important; border: 1px solid #484848; }
.segmented { display: inline-flex; flex: none; height: 22px; border: 1px solid #4b4b4b; border-radius: 2px; overflow: hidden; }.segmented button { min-height: 20px; border-radius: 0; border-right: 1px solid #4b4b4b; }.segmented button:last-child { border-right: 0; }.segmented button.active { color: #fff; background: #4775a3; }
.toolbar-spacer, .header-spacer, .status-spacer { flex: 1; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(180px, 1fr) minmax(220px, 2fr) 108px; min-height: 0; gap: 1px; background: #0f0f0f; }
.workspace-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--ws-right-width, 320px); grid-template-rows: minmax(120px, var(--ws-outliner-fr, 1fr)) minmax(160px, var(--ws-props-fr, 2fr)) var(--ws-timeline-height, 108px); min-height: 0; gap: 1px; background: #0f0f0f; }
/* Partition splitters: invisible until the pointer is over them, then a thin blue line. */
.workspace-splitters { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.workspace-splitter { position: absolute; pointer-events: auto; touch-action: none; outline: none; }
.workspace-splitter.is-right { width: 6px; margin-left: -3px; cursor: col-resize; }
.workspace-splitter.is-timeline, .workspace-splitter.is-outliner { height: 6px; margin-top: -3px; cursor: row-resize; }
.workspace-splitter::after { position: absolute; background: #4775a3; opacity: 0; content: ""; transition: opacity .12s; }
.workspace-splitter.is-right::after { inset: 0 auto 0 2px; width: 2px; }
.workspace-splitter.is-timeline::after, .workspace-splitter.is-outliner::after { inset: 2px 0 auto 0; height: 2px; }
.workspace-splitter:hover::after, .workspace-splitter.is-dragging::after, .workspace-splitter:focus-visible::after { opacity: 1; }
.workspace-splitter:focus-visible { box-shadow: inset 0 0 0 1px #7fb2e5; }
.area-frame { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: #252525; }
.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: .55; transition: opacity .12s; }
/* Hidden until the pointer is over the area: docked, it used to sit on top of
the outliner filters and the properties header. */
.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: static; max-width: none; 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 span { flex: none; }
.editor-header { display: flex; align-items: center; flex: none; min-height: 27px; padding: 0 4px; background: #292929; border-bottom: 1px solid #151515; box-shadow: inset 0 -1px #333; }
@@ -110,7 +132,12 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
.transform-gizmo.handle-local::before { position: absolute; left: calc(var(--gizmo-size) * .56px); top: calc(var(--gizmo-size) * .56px); width: 8px; height: 8px; border: 1px solid #fff; border-radius: 50%; background: #24262b; box-shadow: 0 0 0 2px #24262baa; content: ""; }
.gizmo-axis { position: absolute; width: calc(var(--gizmo-size) * .3733px); height: calc(var(--gizmo-size) * .3733px); padding: 0; border: 2px solid currentColor; border-radius: 50%; background: #24262bcc; font-weight: 700; pointer-events: auto; touch-action: none; }
.gizmo-axis.axis-x { left: calc(var(--gizmo-size) * .8px); top: calc(var(--gizmo-size) * .4267px); color: #e35b55; }.gizmo-axis.axis-y { left: calc(var(--gizmo-size) * .4267px); top: calc(var(--gizmo-size) * .0533px); color: #65bb70; }.gizmo-axis.axis-z { left: calc(var(--gizmo-size) * .4267px); top: calc(var(--gizmo-size) * .8px); color: #5d8ee8; }
.viewport-sidebar { position: absolute; top: 312px; right: 0; z-index: 2; display: flex; gap: 1px; padding: 0; color: #c2c2c2; background: #292929e8; border: 1px solid #484848; border-right: 0; border-radius: 3px 0 0 3px; }.viewport-sidebar span { padding: 8px 5px; writing-mode: vertical-rl; }
.viewport-sidebar { position: absolute; top: 312px; right: 0; z-index: 2; display: flex; gap: 1px; max-width: min(70%, 420px); max-height: calc(100% - 320px); padding: 0; overflow: auto; color: #c2c2c2; background: #292929e8; border: 1px solid #484848; border-right: 0; border-radius: 3px 0 0 3px; }.viewport-sidebar span { padding: 8px 5px; writing-mode: vertical-rl; }
/* Blender's N-panel is a narrow column. Without a width the shading group's
* selects grew the panel to 700px and covered most of the viewport. */
.viewport-shading-npanel { width: 200px; min-width: 0; margin: 4px 6px 6px 0; }
.viewport-shading-npanel label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.viewport-shading-npanel select, .viewport-shading-npanel input { min-width: 0; max-width: 100%; }
/* N-panel: real numeric transform fields, matching desktop View3D > Item. */
.viewport-sidebar-tabs { display: flex; flex-direction: column; gap: 4px; width: 168px; padding: 6px; font-size: 11px; }
.viewport-sidebar-tabs strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -125,8 +152,10 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
.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; }
.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; align-items: center; justify-content: space-between; gap: 8px; min-height: 23px; color: #b5b5b5; }.property-transform-row { display: flex; align-items: center; gap: 3px; margin-bottom: 3px; }.property-transform-row > span { flex: 0 0 26px; color: #b5b5b5; }.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; }
.property-section output { display: block; color: #ddd; font-variant-numeric: tabular-nums; }.property-section select { min-width: 118px; padding: 3px 5px; color: #e0e0e0; background: #252525; border: 1px solid #505050; border-radius: 2px; }.property-section input[type="range"] { flex: 1; min-width: 78px; accent-color: #4775a3; }.modifier-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; color: #8e8e8e; font-size: 11px; }.modifier-summary button { padding: 4px 9px; color: #fff; background: #4775a3; border: 1px solid #6193c3; border-radius: 2px; }.modifier-summary button:disabled { color: #777; background: #303030; border-color: #454545; }.swatch { width: 32px; height: 14px; background: #a35d43; border: 1px solid #d18a68; border-radius: 2px; }
.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; }
.property-section output { display: block; color: #ddd; font-variant-numeric: tabular-nums; }.property-section select { flex: 1 1 96px; min-width: 0; max-width: 100%; padding: 3px 5px; color: #e0e0e0; background: #252525; border: 1px solid #505050; border-radius: 2px; }.property-section input[type="range"] { flex: 1; min-width: 78px; accent-color: #4775a3; }.modifier-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; color: #8e8e8e; font-size: 11px; }.modifier-summary button { padding: 4px 9px; color: #fff; background: #4775a3; border: 1px solid #6193c3; border-radius: 2px; }.modifier-summary button:disabled { color: #777; background: #303030; border-color: #454545; }.swatch { width: 32px; height: 14px; background: #a35d43; border: 1px solid #d18a68; border-radius: 2px; }
.properties-content > [data-testid="scene-context-workbench"], .properties-content > [data-testid="editor-workflow-workbench"], .properties-content > [data-testid="capability-family-workbench"] { order: 90; }
.properties-content > [data-testid="feature-route-coverage"], .properties-content > [data-testid="release-status-workbench"] { order: 100; }
.property-section > button { min-height: 24px; margin: 2px; padding: 3px 7px; color: #e2e2e2; background: #454545; border: 1px solid #575757; border-radius: 2px; }
@@ -154,7 +183,8 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
.render-result-empty { display: grid; place-items: center; padding: 12px; font-size: 12px; color: #888; background: #181818; }
/* The floating quick toolbar (default on) overlays the top 35px of every area
and used to hide this editor's own toolbar completely. */
.blender-app[data-quick-tools="true"] .render-result-view { padding-top: 35px; }
/* The quick toolbar has its own grid band now, so render results need no inset. */
.render-result-view { overflow: hidden; }
.node-canvas { position: relative; height: calc(100% - 26px); background-color: #1f1f1f; background-image: linear-gradient(#292929 1px, transparent 1px), linear-gradient(90deg, #292929 1px, transparent 1px); background-size: 20px 20px; overflow: hidden; }
.node-canvas > output { position: absolute; right: 8px; bottom: 6px; color: #aaa; }
.node-card { position: absolute; z-index: 2; display: grid; align-content: start; gap: 10px; width: 150px; height: 88px; padding: 26px 10px 8px; text-align: left; color: #ddd; background: #353535; border: 1px solid #565656; border-radius: 5px; box-shadow: 0 4px 10px #0007; }
@@ -244,7 +274,8 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
@media (min-width: 901px) and (max-width: 1280px) {
.brand-name, .topbar-context { display: none; }
.workspace-grid { grid-template-columns: minmax(0, 1fr) 290px; }
/* Keep the mid-size default, but let a dragged splitter win over it. */
.workspace-grid { grid-template-columns: minmax(0, 1fr) var(--ws-right-width, 290px); }
.workspace-tab { padding-inline: 7px; }
}
@@ -284,6 +315,21 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
.preferences-window > footer span { margin-left: auto; color: #9aa39c; font-size: 11px; }
@media(max-width:700px){.preferences-window{inset:0}.preferences-body{grid-template-columns:110px}.preference-row{grid-template-columns:1fr}}
.blender-app[data-area-layout="custom"] .workspace-grid { position: relative; display: block; background: #0f0f0f; }
/* The custom layout drives areas by absolute rects, so the built-in splitters do not apply. */
.blender-app[data-area-layout="custom"] .workspace-splitters,
.blender-app:not([data-workspace="Layout"]) .workspace-splitters { display: none; }
/* Floating areas: the very same section, only position:fixed, so the WebGL canvas
* and every editor's local state survive the pop-out. z-index stays below modals. */
.area-frame.is-floating { z-index: 70; border: 1px solid #4a4a4a; box-shadow: 0 12px 40px #000a; }
.area-frame.is-floating > .editor-header { display: flex; cursor: grab; touch-action: none; }
.area-frame.is-floating > .editor-header:active { cursor: grabbing; }
.area-float-grip { flex: none; padding: 0 4px; color: #9aa0a8; cursor: grab; }
.area-float-dock { width: 20px; height: 20px; padding: 0; color: #c9cdd3; background: transparent; border: 0; border-radius: 2px; cursor: pointer; }
.area-float-dock:hover { color: #fff; background: #414141; }
.area-float-resize { position: absolute; right: 0; bottom: 0; z-index: 2; width: 14px; height: 14px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 45%, #8a8f96 45% 52%, transparent 52% 64%, #8a8f96 64% 71%, transparent 71%); }
.area-dock-placeholder { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 6px; background: #1a1a1a; border: 1px dashed #454545; }
.area-dock-placeholder button { padding: 4px 10px; font-size: 11px; color: #bfc4cb; background: #2f3439; border: 1px solid #4b525a; border-radius: 3px; cursor: pointer; }
.area-dock-placeholder button:hover { color: #fff; background: #3c4752; }
.blender-app[data-area-layout="custom"] .workspace-grid > .area-frame { position: absolute; margin: 0; }
.blender-app[data-area-layout="custom"] .workspace-grid > .area-frame::after { position: absolute; inset: 0; border: 1px solid #0f0f0f; pointer-events: none; content: ""; }
.area-menu .desktop-menu-trigger > button, .area-type-switch .area-menu > button { width: 18px; height: 18px; padding: 0; line-height: 1; color: #ddd; background: #3a3a3a; border: 1px solid #505050; border-radius: 2px; font-size: 12px; }
@@ -336,6 +382,24 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-
/* Keep the compact tool strip right of the shelf instead of underneath it. */
.viewport-placeholder:has(> .viewport-tool-shelf) > .viewport-toolbar { left: 140px; }
/* Movable viewport overlays: tool shelf, N-panel and the shading/navigation cluster.
* All three are position:absolute inside the viewport, so dragging only sets a
* translate offset; the stored position is a browser preference, not project data. */
.viewport-overlay-grip { flex: none; margin-right: 2px; color: #9aa0a8; letter-spacing: 1px; cursor: grab; }
.viewport-tool-shelf > header { cursor: grab; touch-action: none; }
.viewport-tool-shelf > header strong { flex: 1; text-align: center; }
[data-draggable-panel][data-dragging="true"] { opacity: .92; box-shadow: 0 6px 18px #0008; }
.viewport-quick-tools { position: absolute; right: 22px; top: 88px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.viewport-quick-tools > .viewport-shading-tools, .viewport-quick-tools > .viewport-navigation-tools { position: static; right: auto; top: auto; }
.viewport-quick-tools-handle { display: flex; align-items: center; gap: 2px; padding: 1px 2px; color: #9aa0a8; background: #29322dd9; border: 1px solid #4a5a50; border-radius: 3px; font-size: 11px; cursor: grab; touch-action: none; }
.viewport-quick-tools-handle button { width: 18px; height: 18px; padding: 0; color: #b9bdc4; background: transparent; border: 0; border-radius: 2px; cursor: pointer; }
.viewport-quick-tools-handle button:hover:not(:disabled) { color: #fff; background: #47321f; }
.viewport-quick-tools-handle button:disabled { opacity: .35; cursor: default; }
.viewport-sidebar-grip { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 3px 1px; color: #9aa0a8; background: #1d1d1dcc; border-right: 1px solid #3d3d3d; cursor: grab; touch-action: none; }
.viewport-sidebar-grip span { writing-mode: vertical-rl; letter-spacing: 1px; }
.viewport-sidebar-grip button { width: 16px; height: 16px; padding: 0; line-height: 1; font-size: 11px; color: #c9cdd3; background: #3a3a3a; border: 1px solid #4d4d4d; border-radius: 2px; cursor: pointer; }
.viewport-sidebar-grip button:hover:not(:disabled) { color: #fff; background: #4b4b4b; }
.viewport-sidebar-grip button:disabled { opacity: .35; cursor: default; }
/* Sculpt brush ring: positioned at the projected surface point, sized by the
* projected brush radius (brush_radius_project in desktop paint_cursor). */
.sculpt-brush-cursor { position: absolute; z-index: 5; transform: translate(-50%, -50%); border: 2px solid #f0f0f0; border-radius: 50%; box-shadow: 0 0 0 1px #00000088; pointer-events: none; }

View File

@@ -1,4 +1,4 @@
.desktop-menu-trigger{display:inline-flex;flex:none;position:relative}.desktop-menu-trigger>button{min-height:24px;padding:3px 7px;background:transparent;color:#d3d3d3;white-space:nowrap;border-radius:2px}.desktop-menu-trigger>button[aria-expanded=true]{background:#454545}.desktop-menu-panel{position:fixed;z-index:1500;width:280px;max-width:calc(100vw - 8px);padding:5px;background:#282b2a;color:#e0e3e1;border:1px solid #656b67;box-shadow:0 7px 20px #0007;border-radius:4px;overflow:auto}.desktop-menu-panel>button{display:flex;position:relative;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:7px;width:100%;min-height:28px;text-align:left;padding:5px 9px;color:inherit;background:transparent;border:0;border-radius:2px;font-size:12px}.desktop-menu-panel>button:hover:enabled,.desktop-menu-panel>button:focus-visible{background:#44644f;color:white;outline:1px solid #bdd7c4}.desktop-menu-panel>button:disabled{color:#949c96;cursor:default}.desktop-menu-panel small{display:block;flex-basis:100%;font-size:10px;color:#a7b1a9;white-space:normal;line-height:1.4}.desktop-menu-shortcut{color:#b2beb5;font-size:10px}.desktop-menu-panel [role=separator]{height:1px;background:#49514b;margin:5px 3px}.desktop-menu-back{border-bottom:1px solid #657268!important;margin-bottom:4px}.desktop-header-menus{display:flex;align-items:center;min-width:0;gap:1px}.desktop-selection-controls{display:flex;align-items:center;gap:3px;margin-left:8px}.desktop-header-label{color:#cbd4ce;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:11px}.desktop-dialog-backdrop{position:fixed;inset:0;z-index:1600;background:#0006;display:flex;align-items:center;justify-content:center;padding:14px}.desktop-dialog{background:#292d2a;border:1px solid #87948b;border-radius:5px;width:440px;max-width:100%;max-height:90vh;overflow:auto;padding:14px;color:#e3e8e4}.desktop-dialog header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.desktop-dialog h2{font-size:16px;margin:0}.desktop-dialog button{padding:6px 11px;color:inherit;background:#49534c;border:1px solid #7c8b81;border-radius:3px}.desktop-dialog header button{padding:2px;width:27px;height:27px}.desktop-dialog input:not([type=checkbox]){width:100%;padding:7px;background:#1e211f;border:1px solid #6d7c72;color:inherit}.desktop-dialog p{font-size:12px;line-height:1.7}.desktop-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:15px}.desktop-dialog label{display:flex;gap:8px;align-items:center;margin:12px 0}.workspace-toolbar{overflow:visible}.desktop-header-actions{display:flex;min-width:0;align-items:center;overflow-x:auto;scrollbar-width:none}.legacy-quick-toolbar{display:none}.blender-app[data-quick-tools=true] .legacy-quick-toolbar{display:flex;align-items:center;position:absolute;top:100%;left:0;right:0;z-index:10;background:#303532;overflow-x:auto;gap:4px;padding:4px;touch-action:none;user-select:none}.legacy-quick-toolbar[data-quick-tools-collapsed=true]{display:none!important}.legacy-quick-toolbar .quick-toolbar-grip{flex:none;color:#8d968f;padding:0 2px;cursor:grab;letter-spacing:-1px}.legacy-quick-toolbar.is-floating{position:fixed;top:58px;left:0;right:auto;width:max-content;max-width:calc(100vw - 16px);z-index:55;border:1px solid #4b554d;border-radius:6px;box-shadow:0 10px 28px #0007;cursor:grab}.legacy-quick-toolbar.is-floating:active{cursor:grabbing}.legacy-quick-toolbar .quick-toolbar-actions{display:flex;flex:none;align-items:center;gap:2px;margin-left:auto;padding-left:4px}.legacy-quick-toolbar .quick-toolbar-actions>button{cursor:pointer;min-height:27px;padding:3px 7px;background:#414942}.legacy-quick-toolbar .quick-toolbar-actions>button:disabled{opacity:.4;cursor:default}.quick-toolbar-reopen{position:absolute;top:100%;left:0;z-index:11;background:#303532;color:#d3d3d3;border:1px solid #4b554d;border-radius:0 0 4px 4px;padding:3px 8px;font-size:11px;cursor:pointer}.legacy-quick-toolbar>button{white-space:nowrap;min-height:27px;padding:3px 7px;background:#414942}.blender-app[data-hide-status=true] .status-bar{display:none}.blender-app[data-hide-status=true]{grid-template-rows:28px 30px minmax(0,1fr) 0}.workspace-menu-control{flex:none}.workspace-tabs{min-width:90px}.workspace-tabs .workspace-menu-control{position:sticky;right:0;background:#222}.viewport-header-status{margin-left:auto;display:flex;align-items:center;gap:12px;font-size:11px;white-space:nowrap;padding-right:8px}.topbar-actions .extension-robot{color:#bbd4c3}
.desktop-menu-trigger{display:inline-flex;flex:none;position:relative}.desktop-menu-trigger>button{min-height:24px;padding:3px 7px;background:transparent;color:#d3d3d3;white-space:nowrap;border-radius:2px}.desktop-menu-trigger>button[aria-expanded=true]{background:#454545}.desktop-menu-panel{position:fixed;z-index:1500;width:280px;max-width:calc(100vw - 8px);padding:5px;background:#282b2a;color:#e0e3e1;border:1px solid #656b67;box-shadow:0 7px 20px #0007;border-radius:4px;overflow:auto}.desktop-menu-panel>button{display:flex;position:relative;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:7px;width:100%;min-height:28px;text-align:left;padding:5px 9px;color:inherit;background:transparent;border:0;border-radius:2px;font-size:12px}.desktop-menu-panel>button:hover:enabled,.desktop-menu-panel>button:focus-visible{background:#44644f;color:white;outline:1px solid #bdd7c4}.desktop-menu-panel>button:disabled{color:#949c96;cursor:default}.desktop-menu-panel small{display:block;flex-basis:100%;font-size:10px;color:#a7b1a9;white-space:normal;line-height:1.4}.desktop-menu-shortcut{color:#b2beb5;font-size:10px}.desktop-menu-panel [role=separator]{height:1px;background:#49514b;margin:5px 3px}.desktop-menu-back{border-bottom:1px solid #657268!important;margin-bottom:4px}.desktop-header-menus{display:flex;align-items:center;min-width:0;gap:1px}.desktop-selection-controls{display:flex;align-items:center;gap:3px;margin-left:8px}.desktop-header-label{color:#cbd4ce;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:11px}.desktop-dialog-backdrop{position:fixed;inset:0;z-index:1600;background:#0006;display:flex;align-items:center;justify-content:center;padding:14px}.desktop-dialog{background:#292d2a;border:1px solid #87948b;border-radius:5px;width:440px;max-width:100%;max-height:90vh;overflow:auto;padding:14px;color:#e3e8e4}.desktop-dialog header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.desktop-dialog h2{font-size:16px;margin:0}.desktop-dialog button{padding:6px 11px;color:inherit;background:#49534c;border:1px solid #7c8b81;border-radius:3px}.desktop-dialog header button{padding:2px;width:27px;height:27px}.desktop-dialog input:not([type=checkbox]){width:100%;padding:7px;background:#1e211f;border:1px solid #6d7c72;color:inherit}.desktop-dialog p{font-size:12px;line-height:1.7}.desktop-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:15px}.desktop-dialog label{display:flex;gap:8px;align-items:center;margin:12px 0}.workspace-toolbar{overflow:visible}.desktop-header-actions{display:flex;min-width:0;align-items:center;overflow-x:auto;scrollbar-width:none}.legacy-quick-toolbar{display:none}.blender-app[data-quick-tools=true] .legacy-quick-toolbar{display:flex;align-items:center;position:absolute;top:100%;left:0;right:0;z-index:10;background:#303532;overflow-x:auto;gap:4px;padding:4px;touch-action:none;user-select:none}.legacy-quick-toolbar[data-quick-tools-collapsed=true]{display:none!important}.legacy-quick-toolbar .quick-toolbar-grip{flex:none;color:#8d968f;padding:0 2px;cursor:grab;letter-spacing:-1px}.legacy-quick-toolbar.is-floating{position:fixed;top:58px;left:0;right:auto;width:max-content;max-width:calc(100vw - 16px);z-index:55;border:1px solid #4b554d;border-radius:6px;box-shadow:0 10px 28px #0007;cursor:grab}.legacy-quick-toolbar.is-floating:active{cursor:grabbing}.legacy-quick-toolbar .quick-toolbar-actions{display:flex;flex:none;align-items:center;gap:2px;margin-left:auto;padding-left:4px}.legacy-quick-toolbar .quick-toolbar-actions>button{cursor:pointer;min-height:27px;padding:3px 7px;background:#414942}.legacy-quick-toolbar .quick-toolbar-actions>button:disabled{opacity:.4;cursor:default}.quick-toolbar-reopen{position:absolute;top:100%;left:0;z-index:11;background:#303532;color:#d3d3d3;border:1px solid #4b554d;border-radius:0 0 4px 4px;padding:3px 8px;font-size:11px;cursor:pointer}.legacy-quick-toolbar>button{white-space:nowrap;min-height:27px;padding:3px 7px;background:#414942}.blender-app[data-hide-status=true] .status-bar{display:none}.blender-app[data-hide-status=true]{grid-template-rows:28px calc(30px + var(--quick-tools-row, 0px)) minmax(0,1fr) 0}.workspace-menu-control{flex:none}.workspace-tabs{min-width:90px}.workspace-tabs .workspace-menu-control{position:sticky;right:0;background:#222}.viewport-header-status{margin-left:auto;display:flex;align-items:center;gap:12px;font-size:11px;white-space:nowrap;padding-right:8px}.topbar-actions .extension-robot{color:#bbd4c3}
@media(max-width:700px){.desktop-header-label{display:none}.viewport-header-status{gap:3px;font-size:10px}.desktop-selection-controls{margin-left:0}.desktop-header-menus{max-width:100%;overflow-x:auto;scrollbar-width:none}}
@media(max-width:900px){.topbar .menu-bar{display:flex}.topbar .menu-bar button{padding-inline:5px}.topbar-actions>select,.topbar-actions>.topbar-context,.topbar-actions>.extension-robot{display:none}.workspace-tabs .workspace-tab:nth-child(n+4){display:initial}.workspace-tabs .workspace-tab{flex:none}.workspace-tabs{min-width:40px}.workspace-menu-control>button{font-size:0;width:26px;padding:3px}.workspace-menu-control>button::after{content:'▾';font-size:14px}}
@media(max-width:550px){.topbar-actions{display:none}.workspace-tabs{min-width:48px}.brand{padding:0}.topbar .menu-bar button{padding-inline:4px;font-size:11px}}

View File

@@ -15,6 +15,8 @@ const LEGACY_TUTORIAL_KEY = "web-blender.tutorial-panel-offset.v1";
export const PANEL_OFFSETS_RESET_EVENT = "web-blender:panel-offsets-reset";
export interface PanelOffset { x: number; y: number }
/** Rectangle a draggable panel must stay inside, in viewport coordinates. */
export interface DragBounds { left: number; top: number; right: number; bottom: number }
type OffsetMap = Record<string, PanelOffset>;
@@ -74,12 +76,12 @@ export function resetAllPanelOffsets(): void {
window.dispatchEvent(new CustomEvent(PANEL_OFFSETS_RESET_EVENT));
}
export function useDraggablePanel(id: string, options: { defaultOffset?: PanelOffset } = {}) {
export function useDraggablePanel<T extends HTMLElement = HTMLElement>(id: string, options: { defaultOffset?: PanelOffset; bounds?: (panel: HTMLElement) => DragBounds | null } = {}) {
const [offset, setOffset] = useState<PanelOffset>(() => readPanelOffset(id, options.defaultOffset ?? { x: 0, y: 0 }));
const [dragging, setDragging] = useState(false);
const offsetRef = useRef(offset);
const dragRef = useRef<{ pointerId: number; startX: number; startY: number; originX: number; originY: number } | null>(null);
const panelRef = useRef<HTMLElement | null>(null);
const panelRef = useRef<T | null>(null);
const commit = useCallback((next: PanelOffset) => {
offsetRef.current = next;
@@ -139,9 +141,17 @@ export function useDraggablePanel(id: string, options: { defaultOffset?: PanelOf
const wantedLeft = rect.left + (drag.originX + event.clientX - drag.startX - current.x);
const wantedTop = rect.top + (drag.originY + event.clientY - drag.startY - current.y);
/* Keep the handle grabbable: at least half the panel width (capped) and
* 160px of handle stay on screen, and the handle never leaves the window. */
const left = Math.min(Math.max(wantedLeft, 8 - rect.width * 0.5), window.innerWidth - 160);
const top = Math.min(Math.max(wantedTop, -48), window.innerHeight - 60);
* 160px of handle stay on screen, and the handle never leaves the window.
* Panels whose host clips its own overflow (viewport overlays) pass
* `bounds` so they stay fully visible inside that host instead. */
const limit = options.bounds?.(panel) ?? null;
const clamp = (value: number, low: number, high: number) => Math.min(Math.max(value, low), Math.max(low, high));
const left = limit
? clamp(wantedLeft, limit.left, limit.right - rect.width)
: Math.min(Math.max(wantedLeft, 8 - rect.width * 0.5), window.innerWidth - 160);
const top = limit
? clamp(wantedTop, limit.top, limit.bottom - rect.height)
: Math.min(Math.max(wantedTop, -48), window.innerHeight - 60);
commit({ x: Math.round(current.x + left - rect.left), y: Math.round(current.y + top - rect.top) });
},
onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {

View File

@@ -0,0 +1,264 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
/**
* Workspace layout: partition sizes and areas floated out of the grid.
*
* The built-in workspace is a fixed CSS grid, and every area also sits on top
* of the 3D viewport. Both are browser comfort settings, not project data: one
* localStorage record, shared by every workspace. Project files stay OPFS-only.
*/
const LAYOUT_KEY = "web-blender.workspace-layout.v1";
export const WORKSPACE_LAYOUT_RESET_EVENT = "web-blender:workspace-layout-reset";
export interface WorkspaceSplits {
/** Width in px of the right-hand column (outliner + properties). */
rightWidth: number;
/** Height in px of the timeline row. */
timelineHeight: number;
/** Share of the right column's height given to the outliner. */
outlinerShare: number;
}
export interface FloatingRect { x: number; y: number; width: number; height: number }
export interface WorkspaceLayoutState {
splits: WorkspaceSplits;
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;
}
const MIN_RIGHT = 240;
const MIN_TIMELINE = 48;
const MIN_FLOATING = { width: 240, height: 160 };
function readState(): WorkspaceLayoutState {
try {
const raw = JSON.parse(window.localStorage.getItem(LAYOUT_KEY) ?? "null") as unknown;
const record = raw as Partial<WorkspaceLayoutState> | null;
const splits = record?.splits;
const floating: Record<string, FloatingRect> = {};
if (record?.floating && typeof record.floating === "object") {
for (const [key, value] of Object.entries(record.floating as Record<string, unknown>)) {
const rect = value as FloatingRect | null;
if (!rect || !["x", "y", "width", "height"].every((field) => Number.isFinite((rect as unknown as Record<string, number>)[field]))) continue;
floating[key] = { x: rect.x, y: rect.y, width: Math.max(MIN_FLOATING.width, rect.width), height: Math.max(MIN_FLOATING.height, rect.height) };
}
}
return {
splits: {
rightWidth: Number.isFinite(splits?.rightWidth) ? Math.max(MIN_RIGHT, splits!.rightWidth!) : initialRightWidth(),
timelineHeight: Number.isFinite(splits?.timelineHeight) ? Math.max(MIN_TIMELINE, splits!.timelineHeight!) : DEFAULT_SPLITS.timelineHeight,
outlinerShare: Number.isFinite(splits?.outlinerShare) ? Math.min(0.8, Math.max(0.2, splits!.outlinerShare!)) : DEFAULT_SPLITS.outlinerShare,
},
floating,
};
}
catch { return { splits: { ...DEFAULT_SPLITS }, floating: {} }; }
}
export function resetWorkspaceLayout(): void {
try { window.localStorage.removeItem(LAYOUT_KEY); }
catch { /* nothing to clear */ }
window.dispatchEvent(new CustomEvent(WORKSPACE_LAYOUT_RESET_EVENT));
}
interface WorkspaceLayoutApi {
state: WorkspaceLayoutState;
setSplits: (next: WorkspaceSplits) => void;
floatArea: (key: string, rect: FloatingRect) => void;
moveFloating: (key: string, rect: FloatingRect) => void;
dockArea: (key: string) => void;
dockAll: () => void;
resetAll: () => void;
}
const LayoutContext = createContext<WorkspaceLayoutApi | null>(null);
export function WorkspaceLayoutProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<WorkspaceLayoutState>(readState);
useEffect(() => {
try { window.localStorage.setItem(LAYOUT_KEY, JSON.stringify(state)); }
catch { /* A read-only profile keeps the layout for this page only. */ }
}, [state]);
useEffect(() => {
const onReset = () => setState({ splits: { ...DEFAULT_SPLITS }, floating: {} });
window.addEventListener(WORKSPACE_LAYOUT_RESET_EVENT, onReset);
return () => window.removeEventListener(WORKSPACE_LAYOUT_RESET_EVENT, onReset);
}, []);
const api = useMemo<WorkspaceLayoutApi>(() => ({
state,
setSplits: (splits) => setState((current) => ({ ...current, splits })),
floatArea: (key, rect) => setState((current) => ({ ...current, floating: { ...current.floating, [key]: rect } })),
moveFloating: (key, rect) => setState((current) => ({ ...current, floating: { ...current.floating, [key]: rect } })),
dockArea: (key) => setState((current) => {
if (!current.floating[key]) return current;
const floating = { ...current.floating };
delete floating[key];
return { ...current, floating };
}),
dockAll: () => setState((current) => ({ ...current, floating: {} })),
resetAll: () => setState({ splits: { ...DEFAULT_SPLITS }, floating: {} }),
}), [state]);
return <LayoutContext.Provider value={api}>{children}</LayoutContext.Provider>;
}
export function useWorkspaceLayout(): WorkspaceLayoutApi {
const api = useContext(LayoutContext);
if (!api) throw new Error("useWorkspaceLayout must be used inside WorkspaceLayoutProvider");
return api;
}
/** CSS variables that turn the workspace grid's fixed tracks into adjustable ones.
* The share maps onto the built-in 1fr : 2fr row weights (share 1/3 → 1fr / 2fr),
* so the untouched layout keeps the pixel sizes it always had. */
export function splitStyle(splits: WorkspaceSplits): CSSProperties {
const total = 3;
return {
"--ws-right-width": `${Math.round(splits.rightWidth)}px`,
"--ws-timeline-height": `${Math.round(splits.timelineHeight)}px`,
"--ws-outliner-fr": `${(splits.outlinerShare * total).toFixed(4)}fr`,
"--ws-props-fr": `${((1 - splits.outlinerShare) * total).toFixed(4)}fr`,
} as CSSProperties;
}
type SplitKind = "right" | "timeline" | "outliner";
/**
* Draggable splitters between the built-in areas.
*
* Track sizes mix px (right column, timeline) and fr weights (outliner vs
* properties), so the bar positions are measured from the laid-out area frames
* rather than derived from CSS alone, and re-measured on resize.
*/
export function WorkspaceSplitters() {
const { state, setSplits } = useWorkspaceLayout();
const hostRef = useRef<HTMLDivElement>(null);
const [bars, setBars] = useState<Array<{ kind: SplitKind; style: CSSProperties }>>([]);
const splitsRef = useRef(state.splits);
splitsRef.current = state.splits;
const dragRef = useRef<{ kind: SplitKind; pointerId: number; startX: number; startY: number; start: WorkspaceSplits; total: number } | null>(null);
const [dragging, setDragging] = useState<SplitKind | null>(null);
const measure = useCallback(() => {
const grid = hostRef.current?.closest<HTMLElement>(".workspace-grid");
if (!grid) return;
/* Only the default Layout grid uses the adjustable tracks; every other
* workspace has its own fixed template (see app-shell.css), where dragging
* these bars could not move anything. */
if (grid.closest<HTMLElement>(".blender-app")?.dataset.workspace !== "Layout") { setBars([]); return; }
const frame = (selector: string) => grid.querySelector<HTMLElement>(selector)?.getBoundingClientRect() ?? null;
const viewport = frame(".viewport-area");
const outliner = frame(".outliner-area");
const timeline = frame(".timeline-area");
const gridRect = grid.getBoundingClientRect();
const next: Array<{ kind: SplitKind; style: CSSProperties }> = [];
if (viewport && outliner) {
const x = outliner.left - gridRect.left;
next.push({ kind: "right", style: { left: `${x}px`, top: 0, height: `${gridRect.height}px` } });
}
if (viewport && timeline) {
const y = timeline.top - gridRect.top;
next.push({ kind: "timeline", style: { top: `${y}px`, left: 0, width: `${gridRect.width}px` } });
}
const props = grid.querySelector<HTMLElement>(".properties-area")?.getBoundingClientRect() ?? null;
if (outliner && props) {
next.push({ kind: "outliner", style: { top: `${outliner.bottom - gridRect.top}px`, left: `${outliner.left - gridRect.left}px`, width: `${outliner.width}px` } });
}
setBars(next);
}, []);
useEffect(() => {
measure();
const grid = hostRef.current?.closest<HTMLElement>(".workspace-grid");
if (!grid) return;
const observer = new ResizeObserver(() => measure());
observer.observe(grid);
for (const area of Array.from(grid.querySelectorAll(".area-frame"))) observer.observe(area);
window.addEventListener("resize", measure);
return () => { observer.disconnect(); window.removeEventListener("resize", measure); };
}, [measure]);
useEffect(() => {
/* A split change reflows the grid: re-measure on the next frame. */
const id = requestAnimationFrame(measure);
return () => cancelAnimationFrame(id);
}, [state.splits, measure]);
const clampSplits = useCallback((next: WorkspaceSplits, kind: SplitKind, total: number): WorkspaceSplits => {
const grid = hostRef.current?.closest<HTMLElement>(".workspace-grid");
const gridWidth = grid?.clientWidth ?? window.innerWidth;
if (kind === "right") return { ...next, rightWidth: Math.round(Math.min(Math.max(next.rightWidth, MIN_RIGHT), gridWidth * 0.5)) };
if (kind === "timeline") return { ...next, timelineHeight: Math.round(Math.min(Math.max(next.timelineHeight, MIN_TIMELINE), total * 0.4 || 400)) };
return { ...next, outlinerShare: Math.min(0.8, Math.max(0.2, next.outlinerShare)) };
}, []);
const begin = (kind: SplitKind) => (event: ReactPointerEvent<HTMLDivElement>) => {
if (event.button !== 0) return;
const grid = hostRef.current?.closest<HTMLElement>(".workspace-grid");
dragRef.current = { kind, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, start: { ...splitsRef.current }, total: grid?.clientHeight ?? 0 };
setDragging(kind);
event.currentTarget.setPointerCapture(event.pointerId);
};
const move = (event: ReactPointerEvent<HTMLDivElement>) => {
const drag = dragRef.current;
if (!drag || drag.pointerId !== event.pointerId) return;
const dx = event.clientX - drag.startX;
const dy = event.clientY - drag.startY;
const grid = hostRef.current?.closest<HTMLElement>(".workspace-grid");
let next: WorkspaceSplits;
if (drag.kind === "right") next = { ...drag.start, rightWidth: drag.start.rightWidth - dx };
else if (drag.kind === "timeline") next = { ...drag.start, timelineHeight: drag.start.timelineHeight - dy };
else {
const outliner = grid?.querySelector<HTMLElement>(".outliner-area")?.clientHeight ?? 0;
const properties = grid?.querySelector<HTMLElement>(".properties-area")?.clientHeight ?? 0;
const column = outliner + properties;
if (column <= 0) return;
next = { ...drag.start, outlinerShare: (outliner + dy) / column };
}
setSplits(clampSplits(next, drag.kind, drag.total));
};
const end = (event: ReactPointerEvent<HTMLDivElement>) => {
if (dragRef.current?.pointerId !== event.pointerId) return;
dragRef.current = null;
setDragging(null);
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
};
/* The arrow keys move the divider itself, so a right/down nudge shrinks the
* column above or left of it. */
const nudge = (kind: SplitKind, step: number) => setSplits(clampSplits((() => {
const current = splitsRef.current;
if (kind === "right") return { ...current, rightWidth: current.rightWidth - step };
if (kind === "timeline") return { ...current, timelineHeight: current.timelineHeight + step };
return { ...current, outlinerShare: current.outlinerShare + step / 400 };
})(), kind, 0));
const labels: Record<SplitKind, string> = { right: "调整右侧面板宽度", timeline: "调整时间线高度", outliner: "调整大纲与属性高度" };
return (
<div ref={hostRef} className="workspace-splitters" aria-hidden={bars.length === 0 ? "true" : undefined}>
{bars.map((bar) => (
<div key={bar.kind} className={`workspace-splitter is-${bar.kind}${dragging === bar.kind ? " is-dragging" : ""}`} style={bar.style}
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 })}
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 }); }
}} />
))}
</div>
);
}

View File

@@ -2,6 +2,7 @@ import { StrictMode, Suspense, lazy } from "react";
import { createRoot } from "react-dom/client";
import {DesktopWorkspace} from './app/DesktopWorkspace';
import {COURSES, isAvailableCourseId} from './tutorial/course';
import {WorkspaceLayoutProvider} from './app/workspace-layout';
const App=lazy(()=>import('./app/App').then(module=>({default:module.App})));
const TutorialLanding=lazy(()=>import('./tutorial/TutorialLanding').then(module=>({default:module.TutorialLanding})));
@@ -18,7 +19,7 @@ createRoot(root).render(
manualEngine ? <main data-testid="engine-manual-host" /> : (
<StrictMode>
<Suspense fallback={<output>正在打开工作区…</output>}>
{ui==='desktop'?<DesktopWorkspace/>:tutorialCourse&&!tutorialStarted?<TutorialLanding course={COURSES[tutorialCourse]}/>:<App localOnly={ui!=='web'} course={tutorialStarted?tutorialCourse:undefined}/>}
{ui==='desktop'?<DesktopWorkspace/>:tutorialCourse&&!tutorialStarted?<TutorialLanding course={COURSES[tutorialCourse]}/>:<WorkspaceLayoutProvider><App localOnly={ui!=='web'} course={tutorialStarted?tutorialCourse:undefined}/></WorkspaceLayoutProvider>}
</Suspense>
</StrictMode>
),

View File

@@ -0,0 +1,220 @@
import { expect, test, type Locator, type Page } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";
import { observeNative } from "../fixtures/native-ui-workflow";
/* Wide enough that the responsive 290px column does not apply. */
test.use({ viewport: { width: 1600, height: 1000 } });
const root = path.resolve(import.meta.dirname, "../../..");
const outputDir = path.join(root, "tests/golden/WEB-WORKSPACE-LAYOUT-20261123");
fs.mkdirSync(outputDir, { recursive: true });
const LAYOUT_KEY = "web-blender.workspace-layout.v1";
const OFFSET_KEY = "web-blender.panel-offsets.v1";
async function storedLayout(page: Page): Promise<{ splits?: Record<string, number>; floating?: Record<string, unknown> }> {
return page.evaluate((key) => {
try { return JSON.parse(window.localStorage.getItem(key) ?? "{}"); }
catch { return {}; }
}, LAYOUT_KEY);
}
async function panelOffset(page: Page, id: string): Promise<{ x: number; y: number } | null> {
return page.evaluate(([key, panelId]) => {
try {
const map = JSON.parse(window.localStorage.getItem(key as string) ?? "{}") as Record<string, { x: number; y: number }>;
return map[panelId as string] ?? null;
}
catch { return null; }
}, [OFFSET_KEY, id] as const);
}
function rectOf(locator: Locator): Promise<{ x: number; y: number; width: number; height: number }> {
return locator.evaluate((element) => {
const rect = element.getBoundingClientRect();
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
});
}
/** Drag `handle` by (dx, dy) with real pointer input. */
async function dragBy(page: Page, handle: Locator, dx: number, dy: number): Promise<void> {
const box = await handle.boundingBox();
expect(box, "drag handle must be laid out").toBeTruthy();
/* Start on the grip itself: the handles also hold small buttons. */
const startX = box!.x + Math.min(6, box!.width / 2);
const startY = box!.y + box!.height / 2;
await page.mouse.move(startX, startY);
await page.mouse.down();
await page.mouse.move(startX + dx / 2, startY + dy / 2, { steps: 4 });
await page.mouse.move(startX + dx, startY + dy, { steps: 4 });
await page.mouse.up();
}
async function openScene(page: Page): Promise<void> {
await observeNative(page);
await page.goto("/?ui=web");
await page.getByTestId("blend-file-input").setInputFiles(path.join(root, "tests/files/web/basic_scene.blend"));
await expect(page.getByTestId("engine-status")).toContainText(/SceneIR r\d+/, { timeout: 120_000 });
}
test("partition splitters resize, persist and reset the workspace areas", async ({ page }) => {
test.setTimeout(240_000);
await openScene(page);
const viewport = page.locator(".viewport-area").first();
const properties = page.locator(".area-frame.properties-area").first();
const timeline = page.locator(".timeline-area").first();
const rightSplitter = page.locator('.workspace-splitter[data-splitter="right"]');
const timelineSplitter = page.locator('.workspace-splitter[data-splitter="timeline"]');
await expect(rightSplitter).toBeVisible({ timeout: 60_000 });
await expect(timelineSplitter).toBeVisible();
const before = { viewport: await rectOf(viewport), properties: await rectOf(properties), timeline: await rectOf(timeline) };
expect(before.properties.width).toBeCloseTo(320, 0);
/* Right column: widen the properties area by dragging the bar left. */
await dragBy(page, rightSplitter, -120, 0);
await expect.poll(async () => (await storedLayout(page)).splits?.rightWidth ?? 0, { timeout: 10_000 }).toBeGreaterThan(400);
const widened = await rectOf(properties);
expect(widened.width).toBeGreaterThan(before.properties.width + 100);
expect((await rectOf(viewport)).width).toBeLessThan(before.viewport.width - 100);
/* Timeline: taller by dragging up. */
await dragBy(page, timelineSplitter, 0, -40);
await expect.poll(async () => (await storedLayout(page)).splits?.timelineHeight ?? 0, { timeout: 10_000 }).toBeGreaterThan(120);
const taller = await rectOf(timeline);
expect(taller.height).toBeGreaterThan(before.timeline.height + 30);
/* The size is a browser preference: it survives a reload. */
const layout = await storedLayout(page);
await page.reload();
/* The unsaved test scene is not restored, but the layout preference is: the
* right column must come back at the dragged width. */
await expect(page.locator(".area-frame.properties-area").first()).toBeVisible({ timeout: 120_000 });
const reloaded = await rectOf(page.locator(".area-frame.properties-area").first());
expect(reloaded.width).toBeCloseTo(widened.width, 0);
expect((await storedLayout(page)).splits?.rightWidth).toBe(layout.splits?.rightWidth);
/* Keyboard nudge and double-click reset both return to the built-in sizes. */
await page.locator('.workspace-splitter[data-splitter="right"]').focus();
await page.keyboard.press("ArrowRight");
await expect.poll(async () => (await storedLayout(page)).splits?.rightWidth ?? 0, { timeout: 10_000 }).toBe(layout.splits!.rightWidth! - 16);
await page.locator('.workspace-splitter[data-splitter="right"]').dblclick();
await expect.poll(async () => (await storedLayout(page)).splits?.rightWidth ?? 0, { timeout: 10_000 }).toBe(320);
await expect.poll(async () => (await rectOf(page.locator(".area-frame.properties-area").first())).width, { timeout: 10_000 }).toBeCloseTo(before.properties.width, 0);
fs.writeFileSync(path.join(outputDir, "splits.json"), JSON.stringify({
schemaVersion: 1, browser: "chromium", storage: "OPFS",
workflow: "/?ui=web + basic_scene.blend -> drag right/timeline splitters -> reload -> ArrowRight -> double-click reset",
before, widened, taller, reloaded, splits: (await storedLayout(page)).splits ?? null,
status: "PASS", acceptance: "NOT_CLAIMED",
}, null, 2));
});
test("an area pops out as a floating window and docks back", async ({ page }) => {
test.setTimeout(240_000);
await openScene(page);
const properties = page.locator(".area-frame.properties-area").first();
const placeholder = page.locator(".area-dock-placeholder");
await expect(placeholder).toHaveCount(0);
await properties.locator(".editor-header .desktop-menu-trigger > button").first().click();
await page.getByRole("menuitem", { name: "浮动为独立窗口" }).click();
await expect(properties).toHaveAttribute("data-floating", "true", { timeout: 10_000 });
const floating = await properties.evaluate((element) => {
const style = getComputedStyle(element);
const rect = element.getBoundingClientRect();
return { position: style.position, rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height } };
});
expect(floating.position).toBe("fixed");
await expect(placeholder).toBeVisible();
expect((await storedLayout(page)).floating?.["properties-area"]).toBeTruthy();
/* Drag the title bar: the window moves and the new rect is remembered. */
await dragBy(page, properties.locator(".editor-header"), 140, 80);
const moved = await rectOf(properties);
expect(moved.x).toBeGreaterThan(floating.rect.x + 100);
expect(moved.y).toBeGreaterThan(floating.rect.y + 50);
/* The viewport keeps rendering while an area floats over the grid. */
await page.screenshot({ path: path.join(outputDir, "floating-properties.png") });
await expect(page.getByTestId("engine-status")).toContainText(/SceneIR r\d+/, { timeout: 30_000 });
await properties.getByLabel("停靠回布局").click();
await expect(page.locator(".area-frame.properties-area").first()).not.toHaveAttribute("data-floating", "true");
await expect(placeholder).toHaveCount(0);
await expect.poll(async () => Object.keys((await storedLayout(page)).floating ?? {}).length, { timeout: 10_000 }).toBe(0);
fs.writeFileSync(path.join(outputDir, "floating-area.json"), JSON.stringify({
schemaVersion: 1, browser: "chromium", storage: "OPFS",
workflow: "properties area menu -> 浮动为独立窗口 -> drag title bar -> dock",
floating, moved, status: "PASS", acceptance: "NOT_CLAIMED",
}, null, 2));
});
test("viewport overlays move out of the model and stay inside the viewport", async ({ page }) => {
test.setTimeout(240_000);
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(String(error)));
await openScene(page);
const viewport = page.locator(".viewport-placeholder").first();
const viewportRect = await rectOf(viewport);
/* N-panel: drag by its grip, then close it with the new × button. */
const sidebar = page.locator(".viewport-sidebar").first();
await expect(sidebar).toBeVisible({ timeout: 60_000 });
await dragBy(page, sidebar.locator(".viewport-sidebar-grip"), 60, 60);
await expect.poll(async () => (await panelOffset(page, "viewport-n-panel"))?.x ?? 0, { timeout: 10_000 }).not.toBe(0);
const movedSidebar = await rectOf(sidebar);
expect(movedSidebar.x).toBeGreaterThanOrEqual(viewportRect.x - 1);
expect(movedSidebar.y).toBeGreaterThanOrEqual(viewportRect.y - 1);
expect(movedSidebar.x + movedSidebar.width).toBeLessThanOrEqual(viewportRect.x + viewportRect.width + 1);
expect(movedSidebar.y + movedSidebar.height).toBeLessThanOrEqual(viewportRect.y + viewportRect.height + 1);
/* The N-panel stays a column; it used to grow to ~714px and hide the model. */
expect(movedSidebar.width).toBeLessThanOrEqual(424);
await sidebar.getByLabel("关闭侧栏").click();
await expect(viewport).toHaveAttribute("data-side-panel", "closed", { timeout: 10_000 });
/* 视图 → 侧栏 is the reopen path (the N shortcut only fires from the canvas). */
await page.getByRole("button", { name: "视图", exact: true }).click();
await page.getByRole("menuitem", { name: "侧栏" }).click();
await expect(viewport).toHaveAttribute("data-side-panel", "open", { timeout: 10_000 });
await page.getByLabel("复位侧栏位置").click();
await expect.poll(async () => (await panelOffset(page, "viewport-n-panel"))?.x ?? -1, { timeout: 10_000 }).toBe(0);
/* Shading + navigation cluster: one draggable group, no overlapping columns. */
const quick = page.locator(".viewport-quick-tools").first();
await expect(quick).toBeVisible();
const shading = await rectOf(page.locator(".viewport-shading-tools").first());
const navigation = await rectOf(page.locator(".viewport-navigation-tools").first());
expect(navigation.y).toBeGreaterThanOrEqual(shading.y + shading.height - 1);
await dragBy(page, quick.locator(".viewport-quick-tools-handle"), -120, 40);
await expect.poll(async () => (await panelOffset(page, "viewport-quick-tools"))?.x ?? 0, { timeout: 10_000 }).not.toBe(0);
const movedQuick = await rectOf(quick);
expect(movedQuick.x).toBeLessThan(viewportRect.x + viewportRect.width);
/* Tool shelf: 视图 → 工具架 opens it, its header drags it off the model. */
await page.getByRole("button", { name: "视图", exact: true }).click();
await page.getByRole("menuitem", { name: "工具架" }).click();
const shelf = page.locator(".viewport-tool-shelf").first();
await expect(shelf).toBeVisible({ timeout: 30_000 });
await dragBy(page, shelf.locator("header").first(), 40, 30);
await expect.poll(async () => (await panelOffset(page, "viewport-tool-shelf"))?.x ?? 0, { timeout: 10_000 }).not.toBe(0);
expect(errors).toEqual([]);
fs.writeFileSync(path.join(outputDir, "viewport-overlays.json"), JSON.stringify({
schemaVersion: 1, browser: "chromium", storage: "OPFS",
workflow: "drag N-panel -> close/reopen with N -> reset -> drag quick tools -> T shelf -> drag header",
viewportRect, movedSidebar, movedQuick, shading, navigation,
offsets: {
sidebar: await panelOffset(page, "viewport-n-panel"),
quick: await panelOffset(page, "viewport-quick-tools"),
shelf: await panelOffset(page, "viewport-tool-shelf"),
},
pageErrors: errors, status: "PASS", acceptance: "NOT_CLAIMED",
}, null, 2));
});