[329] [330] Werkzeug-Tooltips mit Kürzel, Klasse für ganze Mehrfachauswahl, Lauflinie mit Antrittspunkt (SIA 400)
This commit is contained in:
27 files changed
+228
-56
No files matched your search
@@ -15,6 +15,7 @@ import {
|
||||
resolveCombo,
|
||||
SHORTCUT_DEFS,
|
||||
type ShortcutOverrides,
|
||||
toolShortcutLabel,
|
||||
} from "./keyboardShortcuts";
|
||||
|
||||
// Reines Objekt statt `new KeyboardEvent(...)` — Letzteres braucht ein DOM
|
||||
@@ -223,3 +224,13 @@ describe("[170] Datei-Kürzel ausserhalb von Tauri (Browser/Electron-Linux)", ()
|
||||
for (const c of ["mod+s", "mod+shift+s", "mod+o"]) expect(combos).not.toContain(c);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toolShortcutLabel", () => {
|
||||
// [287] (12) Werkzeug-Tooltips mit Kürzel; Übersteuerung gilt, Werkzeug ohne Kürzel `null`.
|
||||
it("zeigt das wirksame Kürzel", () => {
|
||||
const def = toolShortcutLabel("wall", {});
|
||||
expect(def).toBeTruthy();
|
||||
expect(toolShortcutLabel("wall", { toolWall: "shift+w" })).toMatch(/W$/);
|
||||
expect(toolShortcutLabel("gibts-nicht", {})).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -422,3 +422,24 @@ export function formatCombo(combo: string, mac: boolean = isMacPlatform()): stri
|
||||
segs.push(keyLabel);
|
||||
return segs.join(mac ? "" : "+");
|
||||
}
|
||||
|
||||
/** Reihenfolge/Zuordnung Ziffer→Werkzeug — Ids der rebindbaren Kombination in `keyboardShortcuts.ts`. */
|
||||
export const TOOL_SHORTCUT_IDS: { id: ShortcutId; tool: string }[] = [
|
||||
{ id: "toolText", tool: "text" },
|
||||
{ id: "toolLine", tool: "line" },
|
||||
{ id: "toolCircle", tool: "circle" },
|
||||
{ id: "toolRect", tool: "rect" },
|
||||
{ id: "toolPolyline", tool: "polyline" },
|
||||
{ id: "toolWall", tool: "wall" },
|
||||
{ id: "toolCeiling", tool: "ceiling" },
|
||||
{ id: "toolWindow", tool: "window" },
|
||||
{ id: "toolDoor", tool: "door" },
|
||||
{ id: "toolRoom", tool: "room" },
|
||||
];
|
||||
|
||||
/** [287] (12) Tastenkürzel eines Werkzeugs zur Anzeige (Tooltip „Linie (L)“), mit Übersteuerung; ohne Kürzel `null`. */
|
||||
export function toolShortcutLabel(tool: string, overrides: ShortcutOverrides = loadShortcutOverrides()): string | null {
|
||||
const m = TOOL_SHORTCUT_IDS.find((x) => x.tool === tool);
|
||||
const combo = m ? resolveCombo(m.id, overrides) : "";
|
||||
return combo ? formatCombo(combo) : null;
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
import { applyFillMode } from "../fillMode";
|
||||
import { cmdMutation, opsMutation, patchItem, patchItems } from "../../core";
|
||||
import { getState } from "../appStore";
|
||||
import { categoryOpsForSelection, selectionCounts } from "../selectionCategory";
|
||||
import { STYLE_KINDS } from "../mixedValues";
|
||||
import { resolvePenColor } from "../../model/penSets";
|
||||
import type { TransformSelection } from "../../tools/transform";
|
||||
@@ -355,6 +356,12 @@ export function buildSelectionStyleHost(c: FlatHostOpts) {
|
||||
// (VW-Muster „Klasse"/„Ebene"). Je Elementart der passende Store-Weg.
|
||||
onSetSelectionCategory: (code) => {
|
||||
if (!selection || !code) return;
|
||||
// [287] (6) Mehrfachauswahl: Klasse für alle gewählten Elemente, ein Undo-Schritt (Vectorworks-Muster).
|
||||
const all = getState().selection;
|
||||
if (selectionCounts(all).reduce((n, x) => n + x.n, 0) > 1) {
|
||||
applyChange((p) => categoryOpsForSelection(p, all, code));
|
||||
return;
|
||||
}
|
||||
const id = selection.id;
|
||||
switch (selection.kind) {
|
||||
case "wall": updateWall(id, { categoryCode: code }); break;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyOps } from "../core/ops";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { emptySelection } from "./selection";
|
||||
import { categoryOpsForSelection, selectionCounts } from "./selectionCategory";
|
||||
|
||||
describe("categoryOpsForSelection", () => {
|
||||
// [287] (6) Klasse im Objekt-Info-Kopf gilt für die ganze Auswahl, nicht nur für das erste Element.
|
||||
it("setzt die Klasse für alle gewählten Wände und Öffnungen", () => {
|
||||
const p = sampleProject;
|
||||
const walls = p.walls.slice(0, 2).map((w) => w.id);
|
||||
const op = (p.openings ?? [])[0].id;
|
||||
const sel = { ...emptySelection(), walls, openings: [op] };
|
||||
const next = applyOps(p, categoryOpsForSelection(p, sel, "99"));
|
||||
expect(next.walls.filter((w) => w.categoryCode === "99").map((w) => w.id)).toEqual(walls);
|
||||
expect(next.openings?.find((o) => o.id === op)?.categoryCode).toBe("99");
|
||||
expect(selectionCounts(sel)).toEqual([{ kind: "walls", n: 2 }, { kind: "openings", n: 1 }]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
// [287] (6) Objekt-Info bei Mehrfachauswahl (Vectorworks-Muster): die Klasse im Kopf gilt für ALLE gewählten Elemente,
|
||||
// ein Undo-Schritt; dazu die Zusammenfassung „3 Elemente (2 Wände, 1 Tür)“ für den Kopf.
|
||||
|
||||
import type { CoreOp } from "../core";
|
||||
import { patchItems } from "../core";
|
||||
import type { Project } from "../model/types";
|
||||
import type { Selection } from "./selection";
|
||||
|
||||
/** Auswahl-Art → Sammlungen im Projekt (der Kanal „columns“ trägt Stützen UND Träger). */
|
||||
const KIND_COLLECTIONS = [
|
||||
["walls", ["walls"]],
|
||||
["drawings", ["drawings2d"]],
|
||||
["ceilings", ["ceilings"]],
|
||||
["openings", ["openings"]],
|
||||
["stairs", ["stairs"]],
|
||||
["rooms", ["rooms"]],
|
||||
["solids", ["extrudedSolids"]],
|
||||
["columns", ["columns", "beams"]],
|
||||
["roofs", ["roofs"]],
|
||||
["contextObjects", ["context"]],
|
||||
["trees", ["trees"]],
|
||||
["cameras", ["cameras"]],
|
||||
["railings", ["railings"]],
|
||||
] as const;
|
||||
|
||||
/** Ops: Klasse `code` für jedes gewählte Element (ohne Änderung, wo sie schon gilt). */
|
||||
export function categoryOpsForSelection(p: Project, sel: Selection, code: string): CoreOp[] {
|
||||
const ops: CoreOp[] = [];
|
||||
for (const [kind, collections] of KIND_COLLECTIONS) {
|
||||
const ids = sel[kind];
|
||||
if (!ids?.length) continue;
|
||||
for (const col of collections) ops.push(...patchItems(p, col, ids, (e) => ({ ...e, categoryCode: code })));
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
||||
/** Anzahl gewählter Modell-Elemente je Auswahl-Art (ohne Gruppen, Schnittlinien, Lage-Darstellung). */
|
||||
export function selectionCounts(sel: Selection): { kind: (typeof KIND_COLLECTIONS)[number][0]; n: number }[] {
|
||||
return KIND_COLLECTIONS.map(([kind]) => ({ kind, n: sel[kind]?.length ?? 0 })).filter((x) => x.n > 0);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
} from "../editors/elementClipboard";
|
||||
import type { ElementClipboard, ElementSelectionIds, PastedIds } from "../editors/elementClipboard";
|
||||
import { parseClipboardText, serializeClipboardText } from "../editors/elementClipboardSerialize";
|
||||
import { SHORTCUT_DEFS, fileShortcutFor, matchesShortcut, tabKeyAction, type FileShortcut, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
|
||||
import { SHORTCUT_DEFS, TOOL_SHORTCUT_IDS, fileShortcutFor, matchesShortcut, tabKeyAction, type FileShortcut, type ShortcutOverrides } from "./keyboardShortcuts";
|
||||
import { isPrimaryMod } from "./platform";
|
||||
import { isTauriRuntime } from "../native/projectFile";
|
||||
import { isolateSelectionLayerCodes, showAllLayerCodes } from "./layerIsolate";
|
||||
@@ -175,19 +175,6 @@ export function useCommandTabShortcut(
|
||||
* Ebenen-Art über ein Ref (sonst müsste der Effekt bei jedem Render neu
|
||||
* registrieren).
|
||||
*/
|
||||
/** Reihenfolge/Zuordnung Ziffer→Werkzeug — Ids der rebindbaren Kombination in `keyboardShortcuts.ts`. */
|
||||
const TOOL_SHORTCUT_IDS: { id: ShortcutId; tool: ToolId }[] = [
|
||||
{ id: "toolText", tool: "text" },
|
||||
{ id: "toolLine", tool: "line" },
|
||||
{ id: "toolCircle", tool: "circle" },
|
||||
{ id: "toolRect", tool: "rect" },
|
||||
{ id: "toolPolyline", tool: "polyline" },
|
||||
{ id: "toolWall", tool: "wall" },
|
||||
{ id: "toolCeiling", tool: "ceiling" },
|
||||
{ id: "toolWindow", tool: "window" },
|
||||
{ id: "toolDoor", tool: "door" },
|
||||
{ id: "toolRoom", tool: "room" },
|
||||
];
|
||||
|
||||
export function useToolNumberShortcuts(
|
||||
onSelectTool: (id: ToolId) => void,
|
||||
@@ -228,7 +215,7 @@ export function useToolNumberShortcuts(
|
||||
if (!match) return;
|
||||
if (!toolShortcutRef.current.floor) return; // Werkzeuge nur auf Geschossen
|
||||
e.preventDefault();
|
||||
toolShortcutRef.current.onSelectTool(match.tool);
|
||||
toolShortcutRef.current.onSelectTool(match.tool as ToolId);
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
|
||||
Reference in new issue
Block a user