From e454eab1a822cf97277720507ea294be077c2768 Mon Sep 17 00:00:00 2001 From: Karim Date: Sun, 5 Jul 2026 15:24:45 +0200 Subject: [PATCH] Werkzeuge: Kreis-Toolbar verdrahtet (circleCommand gekoppelt, Icon, i18n) --- src/App.tsx | 1 + src/i18n/de.ts | 2 ++ src/i18n/en.ts | 2 ++ src/panels/ToolsPanel.tsx | 7 +++++++ src/tools/tools.ts | 17 +++++++++++++++++ src/tools/types.ts | 3 ++- 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index b769544..bc6acb3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -212,6 +212,7 @@ const TOOL_COMMAND: Partial> = { line: "line", polyline: "polyline", rect: "rect", + circle: "circle", }; /** Befehlsname für ein gekoppeltes Werkzeug (oder null, wenn keiner). */ function coupledCommandFor(id: ToolId): string | null { diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 7324497..e4c93e8 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -116,6 +116,8 @@ export const de = { "tool.line": "Linie", "tool.polyline": "Polylinie", "tool.rect": "Rechteck", + "tool.circle": "Kreis", + "tool.circle.hint": "Kreis: Mittelpunkt setzen, dann Radius", "tool.select.hint": "Auswahl — Elemente klicken/aufziehen", "tool.window.hint": "Fenster: Wand wählen, dann Position setzen", "tool.door.hint": "Tür: Wand wählen, dann Position setzen", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index d1940dc..a12e868 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -115,6 +115,8 @@ export const en: Record = { "tool.line": "Line", "tool.polyline": "Polyline", "tool.rect": "Rectangle", + "tool.circle": "Circle", + "tool.circle.hint": "Circle: set center, then radius", "tool.select.hint": "Select — click/drag elements", "tool.window.hint": "Window: pick a wall, then set the position", "tool.door.hint": "Door: pick a wall, then set the position", diff --git a/src/panels/ToolsPanel.tsx b/src/panels/ToolsPanel.tsx index 4278df9..c22ce97 100644 --- a/src/panels/ToolsPanel.tsx +++ b/src/panels/ToolsPanel.tsx @@ -111,6 +111,13 @@ function ToolIcon({ id }: { id: ToolId }) { ); + case "circle": + // Kreis-Umriss. + return ( + + + + ); default: return null; } diff --git a/src/tools/tools.ts b/src/tools/tools.ts index 5e6916e..433a7a1 100644 --- a/src/tools/tools.ts +++ b/src/tools/tools.ts @@ -526,6 +526,21 @@ const rectTool: Tool = { 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 ───────────────────────────────────────────────────────────────── const TOOLS: Record = { @@ -539,6 +554,7 @@ const TOOLS: Record = { line: lineTool, polyline: polylineTool, rect: rectTool, + circle: circleTool, }; /** Liefert das Werkzeug zur ID. */ @@ -558,4 +574,5 @@ export const TOOL_ORDER: ToolId[] = [ "line", "polyline", "rect", + "circle", ]; diff --git a/src/tools/types.ts b/src/tools/types.ts index f6a39b2..1b0cb76 100644 --- a/src/tools/types.ts +++ b/src/tools/types.ts @@ -18,7 +18,8 @@ export type ToolId = | "room" | "line" | "polyline" - | "rect"; + | "rect" + | "circle"; // ── Snapping ───────────────────────────────────────────────────────────────