diff --git a/TODO.md b/TODO.md index 78d98998..5f01692c 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* stehen im Archiv („Bewusst nicht übernommen“). - **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat. Steht keine Grösse im Archiv, ist sie hier geschätzt. -- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 242); +- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 244); nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben. - **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt; Messwerte und Befunde gehören in den Commit. @@ -1236,6 +1236,7 @@ Einzeilig mit ID, Titel, Datum (2026). Kleine Reste erledigter Punkte (z. B. [T7 exakte Durchdringung, [61] Zuordnung per Hand, [63] Profil je Kante, [70] Flächentabelle als Layout-Element, [80] Einzelplan-PDF ohne Ebenen, [82] Legende per Ziehen) stehen im Archiv beim jeweiligen Eintrag. +- [244] Darstellungsarten-Menü im 3D übersichtlicher (13.11., Wunsch Maintainer, folgt auf [240]): gemeinsames `Dropdown` rückwärtskompatibel erweitert (optionale `group`, `icon`, `hint`, `shortcut` je Option; `optionRows`/`DropdownRows` exportiert, Überschriften und Trennlinien, Zweitzeile + Tooltip, Kürzel rechts). 3D-Menü (`renderModeOptions` in `TopBar.tsx`): Linien (Drahtgitter, Kanten, Nur Konturen) · Flächen (Schattiert, mit Kanten, Texturiert, Weiss) · Rendern (Pathtracing) mit Material-Symbols-Icons und Erklärung („Pathtracing: Physikalisch, rechnet fortlaufend“); de + en. Kürzel gibt es für die Stile keine. 2D-Plan (Farbig/Tusche) unverändert. Geprüft: tsc, vitest `src/ui src/i18n src/viewport`, e2e overridesTab, roomStamp218, viewTemplates, [212]-Pathtracer-Test (Chromium, Port 5194), Screenshots hell/dunkel vorher/nachher. Nicht in der Tauri-App/macOS geprüft. - [243] Qualität der neuen UI-Texte seit 12.11. (13.11.): Durchsicht aller neuen de/en-Schlüssel ([209] Kosten, [211] Blender, 3D-Bild, Hilfslinien, Körper→Bauteile, Raumstempel …). en: „building parts“ → „components“ (wie übriges en.ts), Kosten-Texte (Subtotal, Key figure, excluding land, attic storeys …), 3D-Bild-Fehler (graphics card returned no image, eye point and target coincide), „Automatic/Common scale“, „To change:“ u. a.; de: „Alt schaltet den Fang aus“, „Standpunkt und Ziel fallen zusammen“, „nicht als Bildschirmfoto“, „Ansichtsvorlage „Präsentation““, „MwSt. (Z)“. Platzhalter de/en geprüft (alle gleich), Schlüssel unverändert. Offen: `vitest src/i18n` und volles tsc im Worktree mangels WASM-Paketen nicht gelaufen - [240] 3D-Viewport: Knöpfe und Anzeigen schöner (13.11., Wunsch Maintainer). Neue Komponente `src/viewport/ViewportToolbar3d.tsx` (eigener CSS-Block `.vp3t-*`; `Wasm3DViewport.tsx` bindet nur noch ein): Icon-Knöpfe (Material Symbols `directions_walk`, `add_a_photo`) in zwei Gruppen oben rechts mit Tooltip diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 9f121cb5..caac4716 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -100,6 +100,17 @@ export const de = { "display.style.wireframe": "Drahtgitter", "display.style.hidden": "Kanten", "display.style.pathtrace": "Pathtracing (Vorschau)", + "display.group.lines": "Linien", + "display.group.faces": "Flächen", + "display.group.render": "Rendern", + "display.style.wireframe.tip": "Alle Kanten, auch verdeckte", + "display.style.hidden.tip": "Nur sichtbare Kanten, verdeckte entfallen", + "display.style.contour.tip": "Nur die Umrisse der Körper", + "display.style.shaded.tip": "Bauteilfarben mit Licht und Schatten", + "display.style.shadedEdges.tip": "Schattiert, Modellkanten obenauf", + "display.style.textured.tip": "Echte Materialien und Texturen", + "display.style.white.tip": "Einheitlich weiss, ohne Material (Studienmodell)", + "display.style.pathtrace.tip": "Physikalisch, rechnet fortlaufend", "viewport.pathtrace.status": "Pathtracing: {samples} Samples · {rate}/s", "viewport.pathtrace.done": "Pathtracing: {samples} Samples (fertig)", "viewport.pathtrace.tooBig": "Pathtracing: Modell zu gross für diese Grafikkarte – nur Himmel", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index a65a560a..3975d0b8 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -99,6 +99,17 @@ export const en: Record = { "display.style.wireframe": "Wireframe", "display.style.hidden": "Hidden line", "display.style.pathtrace": "Path tracing (preview)", + "display.group.lines": "Lines", + "display.group.faces": "Surfaces", + "display.group.render": "Rendering", + "display.style.wireframe.tip": "All edges, including hidden ones", + "display.style.hidden.tip": "Visible edges only, hidden ones removed", + "display.style.contour.tip": "Outlines of the solids only", + "display.style.shaded.tip": "Component colors with light and shadow", + "display.style.shadedEdges.tip": "Shaded, model edges on top", + "display.style.textured.tip": "Real materials and textures", + "display.style.white.tip": "Plain white, no material (study model)", + "display.style.pathtrace.tip": "Physically based, keeps refining", "viewport.pathtrace.status": "Path tracing: {samples} samples · {rate}/s", "viewport.pathtrace.tooBig": "Path tracing: model too large for this graphics card – sky only", "viewport.pathtrace.exposure": "Exposure", diff --git a/src/styles.css b/src/styles.css index 0662ebeb..5fd05a59 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4462,6 +4462,43 @@ body { .tb-dd-check { display: block; } +/* [244] Gruppen, Icons, Zweitzeile, Kürzel */ +.tb-dd-heading { + padding: 6px 12px 2px; + font-size: 10px; + letter-spacing: 0.06em; + text-transform: uppercase; + opacity: 0.55; +} +.tb-dd-icon { + flex: 0 0 auto; + font-size: 18px; + opacity: 0.85; +} +.tb-dd-text { + display: flex; + flex-direction: column; + min-width: 0; + flex: 1 1 auto; + text-align: left; +} +.tb-dd-hint { + font-size: 11px; + opacity: 0.6; + white-space: normal; + line-height: 1.25; +} +.tb-dd-item.has-hint { + padding-top: 5px; + padding-bottom: 5px; +} +.tb-dd-kbd { + flex: 0 0 auto; + margin-left: 12px; + font: inherit; + font-size: 11px; + opacity: 0.55; +} /* ── Kontextmenü (generisch, wiederverwendbar) ─────────────────────────────── 1:1 nach DOSSIER (docs/design/context-menu.md): fixe Position mit diff --git a/src/ui/Dropdown.test.ts b/src/ui/Dropdown.test.ts new file mode 100644 index 00000000..c3366bb7 --- /dev/null +++ b/src/ui/Dropdown.test.ts @@ -0,0 +1,55 @@ +// [244] Dropdown: Gruppen, Icons, Zweitzeile, Kürzel; ohne diese Felder unverändert. Darstellungsarten im 3D gruppiert. +import { createElement } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { describe, expect, it } from "vitest"; +import { DropdownRows, optionRows } from "./Dropdown"; +import { renderModeOptions } from "./TopBar"; +import { t } from "../i18n"; + +const html = (rows: ReturnType) => + renderToStaticMarkup(createElement(DropdownRows, { rows, activeIdx: -1, onHover: () => {}, onSelect: () => {} })); + +describe("Dropdown [244]", () => { + it("ohne Gruppen: keine Überschrift, kein Icon, kein Trenner (rückwärtskompatibel)", () => { + const rows = optionRows([{ value: "a", label: "A" }, { value: "b", label: "B" }], "b"); + expect(rows).toHaveLength(2); + const h = html(rows); + expect(h).not.toContain("tb-dd-heading"); + expect(h).not.toContain("tb-dd-icon"); + expect(h).not.toContain("separator"); + expect(h).toContain('aria-selected="true"'); + }); + + it("Gruppen: Überschrift je Gruppe, Trenner nur dazwischen", () => { + const rows = optionRows([ + { value: "a", label: "A", group: "G1" }, { value: "b", label: "B", group: "G1" }, { value: "c", label: "C", group: "G2" }, + ]); + expect(rows.filter((r) => r.divider)).toHaveLength(1); + expect(rows.filter((r) => r.heading !== undefined).map((r) => r.heading)).toEqual(["G1", "G2"]); + const h = html(rows); + expect(h.match(/role="separator"/g)).toHaveLength(1); + expect(h).toContain(">G1<"); + }); + + it("Icon, Zweitzeile, Tooltip, Kürzel und Häkchen", () => { + const h = html(optionRows([{ value: "a", label: "A", icon: "view_in_ar", hint: "Erklärung", shortcut: "W" }], "a")); + expect(h).toContain("material-symbols-outlined tb-dd-icon"); + expect(h).toContain(">view_in_ar<"); + expect(h).toContain('class="tb-dd-hint">Erklärung<'); + expect(h).toContain('title="Erklärung"'); + expect(h).toContain(">W"); + expect(h).toContain("tb-dd-check"); + }); + + it("3D-Darstellungsarten: alle acht, drei Gruppen, Pathtracing erklärt", () => { + const opts = renderModeOptions(); + expect(opts.map((o) => o.value).sort()).toEqual( + ["contour", "hidden", "pathtrace", "shaded", "shaded-edges", "textured", "white", "wireframe"], + ); + expect(new Set(opts.map((o) => o.group)).size).toBe(3); + expect(opts.every((o) => o.icon && o.hint)).toBe(true); + const h = html(optionRows(opts, "pathtrace")); + expect(h).toContain(t("display.style.pathtrace.tip")); + expect(h).toContain(t("display.group.lines")); + }); +}); diff --git a/src/ui/Dropdown.tsx b/src/ui/Dropdown.tsx index ea28775c..6bed94f0 100644 --- a/src/ui/Dropdown.tsx +++ b/src/ui/Dropdown.tsx @@ -26,6 +26,14 @@ export interface DropdownOption { label: string; /** Ausgegraut, nicht wählbar. */ disabled?: boolean; + /** [244] Material-Symbols-Name (z. B. "view_in_ar") vor dem Label. */ + icon?: string; + /** [244] Zweitzeile (kurze Erklärung); zugleich Tooltip der Zeile. */ + hint?: string; + /** [244] Kürzel, rechts als Taste angezeigt. */ + shortcut?: string; + /** [244] Gruppentitel: aufeinanderfolgende Optionen mit gleicher Gruppe stehen unter einer Überschrift mit Trennlinie. */ + group?: string; } /** @@ -46,6 +54,93 @@ export interface DropdownItem { active?: boolean; /** Reiner Trenner (1px Linie); ignoriert alle anderen Felder. */ divider?: boolean; + /** [244] Gruppenüberschrift (nicht wählbar). */ + heading?: string; + /** [244] Material-Symbols-Name vor dem Label. */ + icon?: string; + /** [244] Zweitzeile + Tooltip. */ + hint?: string; + /** [244] Kürzel rechts. */ + shortcut?: string; +} + +/** Nicht wählbare Zeile (Trenner, Überschrift). */ +const isInert = (r: DropdownItem) => !!r.divider || r.heading !== undefined; + +/** Zeilenliste aus Optionen; bei `group` mit Überschrift und Trennlinie dazwischen ([244]). */ +export function optionRows(options: DropdownOption[], value?: string, onChange?: (v: string) => void): DropdownItem[] { + const rows: DropdownItem[] = []; + let group: string | undefined; + for (const o of options) { + if (o.group !== undefined && o.group !== group) { + if (rows.length > 0) rows.push({ divider: true }); + rows.push({ heading: o.group }); + } + group = o.group; + rows.push({ + label: o.label, + disabled: o.disabled, + active: o.value === value, + icon: o.icon, + hint: o.hint, + shortcut: o.shortcut, + onSelect: () => onChange?.(o.value), + }); + } + return rows; +} + +/** Die Zeilen des Popovers (rein darstellend, damit testbar). */ +export function DropdownRows({ + rows, + activeIdx, + onHover, + onSelect, +}: { + rows: DropdownItem[]; + activeIdx: number; + onHover: (i: number) => void; + onSelect: (row: DropdownItem) => void; +}) { + return ( + <> + {rows.map((row, i) => + row.divider ? ( +
+ ) : row.heading !== undefined ? ( +
+ {row.heading} +
+ ) : ( + + ), + )} + + ); } export interface DropdownProps { @@ -146,21 +241,14 @@ export function Dropdown({ // Einheitliche Zeilenliste: im Wert-Modus aus `options`, im Aktions-Modus aus // `items`. So teilen beide Modi dieselbe Render-/Tastatur-Logik. - const rows: DropdownItem[] = items - ? items - : (options ?? []).map((o) => ({ - label: o.label, - disabled: o.disabled, - active: o.value === value, - onSelect: () => onChange?.(o.value), - })); + const rows: DropdownItem[] = items ? items : optionRows(options ?? [], value, onChange); // Trigger-Label: Wert-Modus → Label der aktiven Option; sonst `placeholder`. const current = options?.find((o) => o.value === value); const triggerLabel = current?.label ?? placeholder ?? ""; // Index der ersten auswählbaren Zeile (für Tastatur-Start). - const firstSelectable = rows.findIndex((r) => !r.divider && !r.disabled); + const firstSelectable = rows.findIndex((r) => !isInert(r) && !r.disabled); const place = () => { const r = btnRef.current?.getBoundingClientRect(); @@ -183,7 +271,7 @@ export function Dropdown({ }; const selectRow = (row: DropdownItem) => { - if (row.disabled || row.divider) return; + if (row.disabled || isInert(row)) return; row.onSelect?.(); close(); }; @@ -244,7 +332,7 @@ export function Dropdown({ for (let n = 0; n < rows.length; n++) { i = (i + dir + rows.length) % rows.length; const row = rows[i]; - if (row && !row.divider && !row.disabled) { + if (row && !isInert(row) && !row.disabled) { setActiveIdx(i); return; } @@ -283,27 +371,7 @@ export function Dropdown({ style={{ left: pos.left, top: pos.top, minWidth: pos.minWidth }} onContextMenu={(e) => e.preventDefault()} > - {rows.map((row, i) => - row.divider ? ( -
- ) : ( - - ), - )} +
) : null; diff --git a/src/ui/TopBar.tsx b/src/ui/TopBar.tsx index 81dd30a9..295596e1 100644 --- a/src/ui/TopBar.tsx +++ b/src/ui/TopBar.tsx @@ -199,6 +199,26 @@ function ComboMenu({ /** Die vier oberen Iso-Oktanten (untere vier bleiben im Hochbau ungenutzt). */ const ISO_VARIANTS: View3d[] = ["iso", "isoFrontLeft", "isoBackRight", "isoBackLeft"]; +/** [244] Darstellungsarten im 3D: gruppiert, mit Icon und Kurzerklärung. */ +export function renderModeOptions(): DropdownOption[] { + const lines = t("display.group.lines"); + const faces = t("display.group.faces"); + const render = t("display.group.render"); + const o = (value: RenderMode, key: string, icon: string, group: string): DropdownOption => ({ + value, label: t(`display.style.${key}`), hint: t(`display.style.${key}.tip`), icon, group, + }); + return [ + o("wireframe", "wireframe", "deployed_code", lines), + o("hidden", "hidden", "visibility_off", lines), + o("contour", "contour", "border_style", lines), + o("shaded", "shaded", "view_in_ar", faces), + o("shaded-edges", "shadedEdges", "select_all", faces), + o("textured", "textured", "texture", faces), + o("white", "white", "circle", faces), + o("pathtrace", "pathtrace", "auto_awesome", render), + ]; +} + /** Häkchen vor der aktiven Iso-Zeile (gleiche Glyphe wie `Dropdown`s Check). */ function IsoCheck() { return ( @@ -1257,16 +1277,7 @@ export const ViewRibbonTab = memo(function ViewRibbonTab({ disabled={!renderModeEnabled} onChange={(v) => onRenderMode(v as RenderMode)} title={t("display.style.hint")} - options={[ - { value: "shaded", label: t("display.style.shaded") }, - { value: "shaded-edges", label: t("display.style.shadedEdges") }, - { value: "white", label: t("display.style.white") }, - { value: "contour", label: t("display.style.contour") }, - { value: "textured", label: t("display.style.textured") }, - { value: "wireframe", label: t("display.style.wireframe") }, - { value: "hidden", label: t("display.style.hidden") }, - { value: "pathtrace", label: t("display.style.pathtrace") }, - ]} + options={renderModeOptions()} /> ) : (