Werkzeuge: Kreis-Toolbar verdrahtet (circleCommand gekoppelt, Icon, i18n)

This commit is contained in:
2026-07-05 15:24:45 +02:00
parent 67195d7dd5
commit e454eab1a8
6 changed files with 31 additions and 1 deletions
+1
View File
@@ -212,6 +212,7 @@ const TOOL_COMMAND: Partial<Record<ToolId, string>> = {
line: "line", line: "line",
polyline: "polyline", polyline: "polyline",
rect: "rect", rect: "rect",
circle: "circle",
}; };
/** Befehlsname für ein gekoppeltes Werkzeug (oder null, wenn keiner). */ /** Befehlsname für ein gekoppeltes Werkzeug (oder null, wenn keiner). */
function coupledCommandFor(id: ToolId): string | null { function coupledCommandFor(id: ToolId): string | null {
+2
View File
@@ -116,6 +116,8 @@ export const de = {
"tool.line": "Linie", "tool.line": "Linie",
"tool.polyline": "Polylinie", "tool.polyline": "Polylinie",
"tool.rect": "Rechteck", "tool.rect": "Rechteck",
"tool.circle": "Kreis",
"tool.circle.hint": "Kreis: Mittelpunkt setzen, dann Radius",
"tool.select.hint": "Auswahl — Elemente klicken/aufziehen", "tool.select.hint": "Auswahl — Elemente klicken/aufziehen",
"tool.window.hint": "Fenster: Wand wählen, dann Position setzen", "tool.window.hint": "Fenster: Wand wählen, dann Position setzen",
"tool.door.hint": "Tür: Wand wählen, dann Position setzen", "tool.door.hint": "Tür: Wand wählen, dann Position setzen",
+2
View File
@@ -115,6 +115,8 @@ export const en: Record<TranslationKey, string> = {
"tool.line": "Line", "tool.line": "Line",
"tool.polyline": "Polyline", "tool.polyline": "Polyline",
"tool.rect": "Rectangle", "tool.rect": "Rectangle",
"tool.circle": "Circle",
"tool.circle.hint": "Circle: set center, then radius",
"tool.select.hint": "Select — click/drag elements", "tool.select.hint": "Select — click/drag elements",
"tool.window.hint": "Window: pick a wall, then set the position", "tool.window.hint": "Window: pick a wall, then set the position",
"tool.door.hint": "Door: pick a wall, then set the position", "tool.door.hint": "Door: pick a wall, then set the position",
+7
View File
@@ -111,6 +111,13 @@ function ToolIcon({ id }: { id: ToolId }) {
<rect x="2.5" y="3.5" width="11" height="9" /> <rect x="2.5" y="3.5" width="11" height="9" />
</svg> </svg>
); );
case "circle":
// Kreis-Umriss.
return (
<svg {...common}>
<circle cx="8" cy="8" r="5.5" />
</svg>
);
default: default:
return null; return null;
} }
+17
View File
@@ -526,6 +526,21 @@ const rectTool: Tool = {
onCancel: () => [{ phase: "idle" }, { draft: null, done: true }], onCancel: () => [{ phase: "idle" }, { draft: null, done: true }],
}; };
// Kreis: Platzhalter-Werkzeug (analog window/door), gekoppelt an den
// `circle`-Befehl (TOOL_COMMAND in App.tsx). Der eigentliche Ablauf
// (Mittelpunkt → Radius) läuft über die Command-Engine — EIN Pfad für
// Toolbar-Klick und getipptes „circle". Nicht floorOnly (freie 2D-Zeichnung).
const circleTool: Tool = {
id: "circle",
labelKey: "tool.circle",
hintKey: () => "tool.circle.hint",
init: () => ({ phase: "idle" }),
onClick: (s) => [s, { draft: null }],
onMove: (s) => [s, { draft: null }],
onCommitGesture: (s) => [s, { draft: null, done: true }],
onCancel: (s) => [s, { draft: null, done: true }],
};
// ── Registry ───────────────────────────────────────────────────────────────── // ── Registry ─────────────────────────────────────────────────────────────────
const TOOLS: Record<ToolId, Tool> = { const TOOLS: Record<ToolId, Tool> = {
@@ -539,6 +554,7 @@ const TOOLS: Record<ToolId, Tool> = {
line: lineTool, line: lineTool,
polyline: polylineTool, polyline: polylineTool,
rect: rectTool, rect: rectTool,
circle: circleTool,
}; };
/** Liefert das Werkzeug zur ID. */ /** Liefert das Werkzeug zur ID. */
@@ -558,4 +574,5 @@ export const TOOL_ORDER: ToolId[] = [
"line", "line",
"polyline", "polyline",
"rect", "rect",
"circle",
]; ];
+2 -1
View File
@@ -18,7 +18,8 @@ export type ToolId =
| "room" | "room"
| "line" | "line"
| "polyline" | "polyline"
| "rect"; | "rect"
| "circle";
// ── Snapping ─────────────────────────────────────────────────────────────── // ── Snapping ───────────────────────────────────────────────────────────────