/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** The Space Sketch disclosure popovers — kept out of the default panel flow: * Options (set-once settings) and Help (the full gesture legend). */ import type { BoundaryMode } from '@ifc-lite/create'; export interface OptionsPopoverProps { boundaryMode: BoundaryMode; onBoundaryMode: (m: BoundaryMode) => void; /** Whether this derive carried wall thickness — without it only `center` works. */ hasWallData: boolean; snapDelta: { from: number; to: number } | null; usedTol: number; /** The weld-tolerance control is disabled until a storey is derived. */ snapDisabled: boolean; onSnap: (tol: number | null) => void; snapTol: number | null; showBuilding: boolean; onToggleBuilding: () => void; showDiagnostics: boolean; onToggleDiagnostics: () => void; } export function OptionsPopover(props: OptionsPopoverProps) { const { boundaryMode, onBoundaryMode, hasWallData, snapDelta, usedTol, snapDisabled, onSnap, snapTol, showBuilding, onToggleBuilding, showDiagnostics, onToggleDiagnostics, } = props; return (
Boundary
{(['center', 'inner', 'outer'] as BoundaryMode[]).map((m) => { const noWallData = !hasWallData && m !== 'center'; return ( ); })}
Weld tolerance {snapDelta && ( {snapDelta.from} → {snapDelta.to} )}
onSnap(Number(e.target.value))} /> { const v = Number(e.target.value); if (Number.isFinite(v) && v > 0) onSnap(Math.min(1, Math.max(0.05, v))); }} />
); } const HELP_ROWS: [string, string][] = [ ['Drag a node', 'move it (snaps; Shift = straight)'], ['Click a wall, then another', 'split the room between them'], ['Click empty space', 'draw a room (Enter / dbl-click closes)'], ['⌥/Ctrl/right-click a node', 'remove it (cleans up orphans)'], ['⌥/Ctrl/right-click a wall', 'merge rooms / remove & clean up'], ['Shift-drag / middle-drag', 'pan · scroll = zoom'], ]; export function HelpPopover() { return (
One tool — actions follow the cursor:
{HELP_ROWS.map(([k, v]) => (
{k} — {v}
))}
); }