feat(web): adjustable workspace partitions, floating areas and uncluttered panels
- 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:
@@ -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>
|
||||
|
||||
@@ -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=>{
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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>) => {
|
||||
|
||||
264
web/app/src/app/workspace-layout.tsx
Normal file
264
web/app/src/app/workspace-layout.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user