release: publish v0.9.0 modeling update

This commit is contained in:
Formsmith
2026-08-02 17:38:53 +03:00
parent ab2f34aa80
commit c5f34422e4
28 changed files with 3099 additions and 402 deletions
@@ -0,0 +1,115 @@
"use client";
import { useEffect, useRef, useState, type CSSProperties, type KeyboardEvent, type PointerEvent } from "react";
import type { MoveDimensionAxis, MoveDimensionOverlayData } from "@/lib/moveDimensionLines";
export function MoveDimensionOverlay({
overlay,
active,
onCommit,
}: {
overlay: MoveDimensionOverlayData;
active: boolean;
onCommit: (axis: MoveDimensionAxis, value: string) => void;
}) {
const [editing, setEditing] = useState<{ axis: MoveDimensionAxis; value: string } | null>(null);
const nextEditingAxisRef = useRef<MoveDimensionAxis | null>(null);
const cancelEditRef = useRef(false);
useEffect(() => {
if (active) {
setEditing(null);
}
}, [active]);
const stopPointerPropagation = (event: PointerEvent<HTMLElement>) => {
event.stopPropagation();
};
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === "Enter") {
event.preventDefault();
event.currentTarget.blur();
} else if (event.key === "Escape") {
event.preventDefault();
cancelEditRef.current = true;
event.currentTarget.blur();
} else if (event.key === "Tab" && overlay.lines.length > 1) {
event.preventDefault();
const currentIndex = overlay.lines.findIndex((line) => line.axis === editing?.axis);
const direction = event.shiftKey ? -1 : 1;
const nextIndex = (currentIndex + direction + overlay.lines.length) % overlay.lines.length;
nextEditingAxisRef.current = overlay.lines[nextIndex].axis;
event.currentTarget.blur();
}
};
const styleForLine = (line: MoveDimensionOverlayData["lines"][number]) => ({
"--overlay-x": `${line.labelX}px`,
"--overlay-y": `${line.labelY}px`,
}) as CSSProperties;
return (
<div className={`move-dimension-overlay ${active ? "active" : "settled"}`} aria-label="Movement dimensions">
{overlay.lines.map((line) => {
if (editing?.axis === line.axis) {
return (
<input
key={`edit-${line.axis}`}
className="dimension-input move-dimension-input"
aria-label={`${line.axis.toUpperCase()} movement`}
value={editing.value}
autoFocus
inputMode="decimal"
spellCheck={false}
style={styleForLine(line)}
onChange={(event) => setEditing({ axis: line.axis, value: event.target.value })}
onBlur={() => {
const nextAxis = nextEditingAxisRef.current;
nextEditingAxisRef.current = null;
if (!cancelEditRef.current) {
onCommit(line.axis, editing.value);
}
cancelEditRef.current = false;
const nextLine = nextAxis ? overlay.lines.find((candidate) => candidate.axis === nextAxis) : null;
setEditing(nextLine ? { axis: nextLine.axis, value: nextLine.label } : null);
}}
onKeyDown={handleKeyDown}
onPointerDown={stopPointerPropagation}
onContextMenu={(event) => {
event.preventDefault();
event.stopPropagation();
}}
/>
);
}
return active ? (
<span
key={line.axis}
className="dimension-label move-dimension-value"
style={styleForLine(line)}
>
{line.label}
</span>
) : (
<button
key={line.axis}
className="dimension-label move-dimension-value"
type="button"
aria-label={`${line.axis.toUpperCase()} movement`}
style={styleForLine(line)}
onClick={() => setEditing({ axis: line.axis, value: line.label })}
onPointerDown={stopPointerPropagation}
onContextMenu={(event) => {
event.preventDefault();
event.stopPropagation();
}}
>
{line.label}
</button>
);
})}
</div>
);
}
@@ -22,7 +22,7 @@ import {
gearToothPitch,
} from "@/lib/gearGeometry";
import { displayStepFromMillimeters, displayToMillimeters, formatMeasurementNumber, lengthDisplayUnit, millimetersToDisplay, parseMeasurementInput } from "@/lib/measurementUnits";
import { fallbackSolidColor, resizedShapeSize, shapeDepth, shapeWidth } from "@/lib/workplaneShapes";
import { resizedShapeSize, shapeDepth, shapeWidth } from "@/lib/workplaneShapes";
import { normalizeSketchRevolveSettings } from "@/lib/sketchRevolve";
import type { GearType, GridSize, MeasurementAccuracy, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
@@ -343,7 +343,7 @@ export function ShapeInspector({
onSeparateParts?: () => void;
onInteractionActiveChange?: (active: boolean) => void;
}) {
const solidColor = shape.hole ? fallbackSolidColor(shape) : shape.color;
const solidColor = shape.color;
const locked = Boolean(shape.locked);
const properties = getShapeProperties(shape, onUpdate);
const gearType = shape.kind === "gear" ? normalizeGearType(shape.gearType) : null;
@@ -427,7 +427,7 @@ export function ShapeInspector({
<button
className={shape.hole ? "active hole-choice" : "hole-choice"}
onClick={() => {
onUpdate({ hole: true, color: "#b8c2cc" });
onUpdate({ hole: true });
setColorOpen(false);
}}
disabled={locked}
@@ -204,7 +204,11 @@ export function TransformOverlay({
<button
key={handle.key}
className={`transform-handle ${handle.className}`}
style={{ "--overlay-x": `${handle.x}px`, "--overlay-y": `${handle.y}px` } as CSSProperties}
style={{
"--overlay-x": `${handle.x}px`,
"--overlay-y": `${handle.y}px`,
"--transform-handle-angle": `${handle.angle ?? 0}deg`,
} as CSSProperties}
title={handle.title}
onPointerEnter={(event) => {
if ((event.buttons & 4) !== 0) {
@@ -48,18 +48,22 @@ export function WorkspaceSettingsModal({
workspace,
snap,
themePreference,
moveDimensionsEnabled,
onWorkspaceChange,
onSnapChange,
onThemePreferenceChange,
onMoveDimensionsEnabledChange,
onMakeDefault,
onClose,
}: {
workspace: WorkspaceSettings;
snap: GridSize;
themePreference: AppThemePreference;
moveDimensionsEnabled: boolean;
onWorkspaceChange: (next: WorkspaceSettings) => void;
onSnapChange: (next: GridSize) => void;
onThemePreferenceChange?: (preference: AppThemePreference) => void;
onMoveDimensionsEnabledChange: (enabled: boolean) => void;
onMakeDefault: () => void;
onClose: () => void;
}) {
@@ -193,6 +197,11 @@ export function WorkspaceSettingsModal({
</select>
</label>
<p className="workspace-global-note">Theme applies across SketchForge and all projects.</p>
<WorkspaceToggle
label="Show movement dimensions"
checked={moveDimensionsEnabled}
onChange={onMoveDimensionsEnabledChange}
/>
<WorkspaceToggle label="Show shadows" checked={workspace.showShadows} onChange={(showShadows) => patchWorkspace({ showShadows })} />
<WorkspaceToggle
label="Cruise when adding new shapes"
@@ -367,7 +376,7 @@ export function WorkspaceSettingsModal({
</label>
) : null}
<p className="workspace-history-note">
Unlimited is the default. Lower limits permanently discard older Undo states from this project.
100 actions is the default. Lower limits permanently discard older Undo states from this project.
</p>
</div>
</>
@@ -45,7 +45,7 @@ export type TransformOverlayState = {
width: number;
height: number;
guides: Array<{ x1: number; y1: number; x2: number; y2: number }>;
handles: Array<{ key: string; className: string; kind: TransformHandleKind; x: number; y: number; title: string }>;
handles: Array<{ key: string; className: string; kind: TransformHandleKind; x: number; y: number; title: string; angle?: number }>;
rotateHandles: Array<{ key: string; className: string; x: number; y: number; angle: number }>;
dimensions: Record<string, DimensionMark[]>;
rotationWheel: RotationWheelView | null;