[195b] Objekteinstellungen als natives Nebenfenster (Tauri), Spiegel-Store + Ops zurück

Unter Tauri öffnet T das Fenster „object-settings“ (wie Einstellungen/Ressourcen); Browser/Electron
behalten das schwebende Panel. Schlankste Lösung ohne Doppelspur: das Fenster lädt denselben Store als
Spiegel (Projekt per projectDelta + eigenes Kern-Dokument, Auswahl, aktive Ebene, Host-Wertfelder, Fokus
von T) und rendert unverändert ObjectSettingsPanel. Store-Änderungen rechnen dort ihre Ops auf dem Spiegel
und gehen über state/changeSink.ts ans Hauptfenster (applyChange, Undo je Änderung, coalesceKey bleibt);
Host-Handler per Proxy (remoteHost). Cmd+Z im Fenster wirkt auf den Verlauf des Hauptfensters.
Mehrfachwerte: Schraffur, Wandtyp/Dicke „gemischt“; Wandtyp gilt für alle gewählten Wände.
Nicht auf macOS gebaut/getestet (nur tsc/vitest im Linux-Container).
This commit is contained in:
Claude committed 2026-11-12 03:29:45 +00:00
1 parent 2119bbd51c
commit 2954a6d296
22 files changed
+790 -37

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
- ○ **[198]** T-Stoss: gleiche Schichten verschmelzen (12.11., Maintainer): Innenputz zweier Wände am T zeigt noch eine Trennlinie. Am T-Stoss (und Ecken/Kreuzungen prüfen) gleiche Materialien/Schichten vereinigen, keine Fugenlinie zwischen gleichen Schichten — Grundriss und Schnitt (`joins.rs`, Wand-Bänder, [141]/[166]). Bild 1:20/1:50 vorher/nachher. · M
- ○ **[197]** Cmd+3/4 Nachbesserung (12.11., Maintainer): (1) Kamera bleibt bei Cmd+3/Cmd+4 exakt stehen (kein Einpassen; Einpassen nur mit Cmd+Shift+F); (2) Dachfenster/Deckenöffnungen bleiben bei „nur Auswahl“ (eine Wand) sichtbar → Öffnungen nur mit sichtbarem Wirt (Wand, Dach, Decke) oder selbst gewählt (`model3d::ElementSelection`). e2e. · S
- ○ **[196]** (12.11., Maintainer, PRIO) (1) Raster-Bodenschraffur in Gebäudeform (mit Loch an der Wendeltreppe) im EG-Grundriss lässt sich weder anwählen noch löschen — Vermutung: Ansichtsschraffur der Decke des darunterliegenden Geschosses (UG-Decke von oben) bzw. Bodenbelag; klären (Musterhaus komplex EG), Pick wählt das Quell-Element (auch wenn es zu einem anderen Geschoss gehört), Entf löscht es bzw. Hinweis. (2) Zeichnungsebenen-Panel: Auge/„sichtbar“ bei einer Ansicht blendet bei den Grundrissen alle Geschosse ein → Auge schaltet nur die eigene Ebene. (3) Auge eines Geschosses aus → Geschoss fehlt auch im 3D (heute zeigt 3D immer alle Geschosse; Filter wie Klassen [180] im 3D-Cache-Ausgang). e2e für alles. · S
- ○ **[195b]** Objekteinstellungen als ECHTES Nebenfenster (Wunsch Maintainer, 12.11.): heute schwebendes Panel im Hauptfenster ([195]); natives Fenster braucht eine Store-Spiegelung über die Sync-Brücke (Projekt-Leseansicht per applyOps + Auswahl hin, Ops zurück) ohne zweite Abschnitts-Implementierung — Architektur-Entscheid, Opus. Danach Mehrfachwerte für Füllung/Typ/Masse; OpeningEditorDialog in den Bereich „Objekt“ übernehmen. · L
- ◐ **[195b]** Objekteinstellungen als ECHTES Nebenfenster (Wunsch Maintainer, 12.11.). **Stand 12.11.:** Unter Tauri öffnet T (bzw. Menü) das native Fenster `object-settings` (`native/objectSettingsWindow.ts`, Fensterseite `ObjectSettingsWindowApp.tsx`, Protokoll `objectSettingsSync.ts`); Browser/Electron behalten das schwebende Panel. Architektur (schlankste ohne Doppelspur): das Fenster lädt denselben Store als SPIEGEL (Projekt-Leseansicht als Feld-Differenz `projectDelta` + Laden ins eigene Kern-Dokument, Auswahl, aktive Ebene, Wert-Felder des Panel-Hosts, Fokus-Abschnitt von T) und rendert unverändert `ObjectSettingsPanel`; Store-Änderungen dort rechnen ihre Ops auf dem Spiegel und gehen über `state/changeSink.ts` ans Hauptfenster (`applyChange`, Undo je Änderung, `coalesceKey` bleibt), Host-Handler per Proxy (`remoteHost`) ebenso; Cmd+Z/Shift+Cmd+Z im Fenster wirken auf den Verlauf des Hauptfensters, Meldungen erscheinen dort. Auswahlwechsel und Undo im Hauptfenster kommen als Sync (30 ms gebündelt, nur bei offenem Fenster, ohne React-Abo in `App`). Mehrfachwerte: Schraffur (Attribute) und Wandtyp/Dicke („gemischt“), Wandtyp gilt für alle gewählten Wände (ein Schritt). Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`. **Offen:** NICHT auf macOS gebaut/getestet (nur vitest/tsc im Linux-Container; Capability `object-settings` ergänzt, kein Rust); jede Projektänderung lädt das Projekt im Fenster ganz ins Kern-Dokument (bei grossen Projekten ggf. Ops-Strom statt Feld-Differenz); kein Messwert (Live-Mass) im Fenster; Mehrfachwerte für weitere Felder (Decke/Dach/Öffnung, Höhen) und Setzen für alle bei weiteren Handlern; OpeningEditorDialog in den Bereich „Objekt“ übernehmen. · L
- ○ **[195]** Objekt-Einstellungsfenster (12.11., Maintainer): T öffnet ein EIGENES Fenster (macOS-Nebenfenster wie Einstellungen/Ressourcen über die Sync-Brücke, Browser: verschiebbares Fenster), für ALLE Bauteile (Wand, Decke, Dach, Treppe, Stütze, Öffnung, Raum, Körper, Gelände/Baugrube, 2D, Bemassung), mit Abschnitten Objektspezifisch (Typ/Aufbau/Masse/Parameter) + Darstellung (Stift, Füllung, Schraffur, Linienstil, Modelldarstellung). Mehrfachauswahl gleicher Art, live mit Undo je Änderung; dieselben Abschnitts-Komponenten wie Objekt-Info (keine Doppelspur). Ersetzt den bisherigen Öffnungs-Dialog bei T. · L
- ◐ **[194]** Texte exakt synchron beim Zoomen (12.11., Maintainer Mac: Texte immer leicht verzögert; Nachfolger [145]).
12.11.: Die native Fläche zeichnet die Plan-Texte selbst im selben Frame wie die Linien: Raumstempel und waagrechte
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Basis-Permissions + Fenstersteuerung fuer die randlose (decorations:false) Titelleiste: Minimieren/Maximieren/Schliessen + Ziehen der eigenen Titelleiste (data-tauri-drag-region). Menu: fuer die native macOS-Systemmenueleiste (src/native/appMenu.ts). Webview/Event: fuer die nativen Ressourcen-/Einstellungs-/Zeichnungsebenen-/Ebeneneinstellungs-Fenster + ihre Sync-Bruecken (src/native/*Window.ts) - gilt fuer alle Fensterlabels, da jedes Events senden/empfangen muss. Dialog/Fs: nativer Oeffnen- UND Speichern-Dialog fuer Projektdateien (.obp/.json) plus Lesen/Schreiben der gewaehlten Datei (io/projectFile.ts, io/saveFile.ts) - open+read fuer Projekt laden, save+write fuer Projekt/Export speichern. fs:allow-read-file (eng auf EINEN festen Pfad beschraenkt): liest macOS mitgeliefertes Generic-CMYK-Profil (ColorSync) fuer echtes ICC-Farbmanagement im Farbmischer (model/colorIcc.ts) - bewusst kein gebuendeltes Fremd-Profil, nur diese eine System-Datei zur Laufzeit gelesen. Updater/Process: Selbst-Update-Check beim Start (src/update/checkForUpdate.ts) + Neustart nach Installation. Http: Versionsverlauf (versions.json vom Gitea-Release) ohne Browser-CORS, Scope auf den eigenen Gitea-Host begrenzt. Shell:allow-open: oeffnet den DMG-Download einer aelteren Version im System-Browser (Rollback). allow-set-size/allow-center: kompaktes Splash-/Startbildschirm-Fenster vor dem Editor (App.tsx bootPhase).",
"windows": ["main", "resources", "settings", "drawing-levels", "layer-settings", "context-import"],
"windows": ["main", "resources", "settings", "drawing-levels", "layer-settings", "context-import", "object-settings"],
"permissions": [
"core:default",
"core:window:allow-minimize",
+11 -2
View File
@@ -60,6 +60,8 @@ import { useCommandEngineHost } from "./state/useCommandEngineHost";
import { TRANSFORM_COMMANDS, useToolInput } from "./state/useToolInput";
import { useSelectionCommands } from "./state/useSelectionCommands";
import { openObjectSettings } from "./state/objectSettings";
import { openObjectSettingsWindowNative, useObjectSettingsWindowHost } from "./native/objectSettingsWindow";
import { isTauriRuntime } from "./native/projectFile";
import {
useActiveToolKeys,
useElementClipboardShortcut,
@@ -499,11 +501,15 @@ export default function App() {
pa,
});
// [195] Taste T / Menü „Objekteinstellungen…": schwebendes Fenster (state/objectSettings.ts).
// [195] Taste T / Menü „Objekteinstellungen…" (state/objectSettings.ts): unter Tauri natives Nebenfenster ([195b]),
// sonst schwebendes Panel.
const openSettingsOfObject = () =>
openObjectSettings({
activeTool,
revealObjectSettings: () => setLayout((l) => revealPanel(l, "object-settings", { x: 96, y: 96, w: 360, h: 560 })),
revealObjectSettings: (group) =>
isTauriRuntime()
? void openObjectSettingsWindowNative(group)
: setLayout((l) => revealPanel(l, "object-settings", { x: 96, y: 96, w: 360, h: 560 })),
});
useObjectSettingsShortcut(shortcutOverrides, engineRef, openSettingsOfObject);
@@ -678,6 +684,9 @@ export default function App() {
contextMenuState: { setMenu },
});
// [195b] Natives Fenster „Objekteinstellungen": Spiegel hin, Ops/Host-Handler zurück (no-op ausserhalb von Tauri).
useObjectSettingsWindowHost(baseHost);
// ── Stabile Handler + memoisierte Kinder ([121]) ─────────────────────────
// Handler für memoisierte Kinder als EIN Bündel mit stabiler Identität (`useEventBundle`): ein
// App-Render (z. B. nach einer Op) ändert deren Props dann nicht, sie rendern nicht mit.
+2
View File
@@ -8,6 +8,7 @@ import { SettingsWindowApp } from "./native/SettingsWindowApp";
import { DrawingLevelsWindowApp } from "./native/DrawingLevelsWindowApp";
import { LayerSettingsWindowApp } from "./native/LayerSettingsWindowApp";
import { ContextImportWindowApp } from "./native/ContextImportWindowApp";
import { ObjectSettingsWindowApp } from "./native/ObjectSettingsWindowApp";
import { ErrorBoundary } from "./ui/ErrorBoundary";
import { initCore } from "./core";
import { getLanguage, setLanguage } from "./i18n";
@@ -80,6 +81,7 @@ function RootByWindowKind() {
if (windowKind === "drawing-levels") return <DrawingLevelsWindowApp />;
if (windowKind === "layer-settings") return <LayerSettingsWindowApp />;
if (windowKind === "context-import") return <ContextImportWindowApp />;
if (windowKind === "object-settings") return <ObjectSettingsWindowApp />;
return <App />;
}
+114
View File
@@ -0,0 +1,114 @@
// [195b] Eigenständiger Root des nativen Fensters „Objekteinstellungen" (`?window=object-settings`, von main.tsx
// gerendert; Hauptfenster-Seite: `objectSettingsWindow.ts`, Protokoll: `objectSettingsSync.ts`).
//
// Keine zweite Implementierung der Abschnitte: das Fenster rendert `ObjectSettingsPanel` wie das schwebende Panel.
// Der Store dieses Dokuments ist ein Spiegel des Hauptfensters (Projekt + Kern-Dokument, Auswahl, aktive Ebene);
// seine Projekt-Änderungen gehen als Ops ans Hauptfenster (`changeSink.ts`), Host-Handler ebenso. Cmd+Z/
// Cmd+Shift+Z wirken auf den Verlauf des Hauptfensters; Esc schliesst das Fenster.
import { useEffect, useMemo, useState } from "react";
import { t } from "../i18n";
import { PanelHostProvider } from "../panels/host";
import type { PanelHost } from "../panels/types";
import { ObjectSettingsPanel } from "../panels/objectSettings/ObjectSettingsPanel";
import { setSettingsArea } from "../panels/objectSettings/areaState";
import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState";
import { setState } from "../state/appStore";
import { setChangeSink } from "../state/changeSink";
import {
OBJECT_SETTINGS_PREFIX as PREFIX,
applyObjectSettingsSync,
mirrorIntoStore,
remoteHost,
type ObjectSettingsSnapshot,
type ObjectSettingsSync,
type ObjectSettingsUi,
} from "./objectSettingsSync";
/** Befehl ans Hauptfenster (s. Protokoll in `objectSettingsSync.ts`). */
function send(name: string, args: unknown[] = []): void {
void import("@tauri-apps/api/event").then(({ emitTo }) =>
emitTo("main", `${PREFIX}-command`, { name, args }).catch((err) => console.error("[object-settings] Befehl nicht gesendet", name, err)),
);
}
const isTextEntry = (el: Element | null): boolean =>
el instanceof HTMLElement && (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT" || el.isContentEditable);
export function ObjectSettingsWindowApp() {
const [ui, setUi] = useState<ObjectSettingsUi | null>(null);
useEffect(() => {
// Änderungen nicht lokal anwenden, sondern ans Hauptfenster (das hält Verlauf und Wahrheit).
setChangeSink((ops, key) => send("change", [ops, key ?? null]));
setState({ notify: (message: string, kind?: "info" | "warning" | "error") => send("notify", [message, kind ?? "info"]) });
let disposed = false;
let snap: ObjectSettingsSnapshot | null = null;
let focusSeq = 0;
const unlisten: Array<() => void> = [];
void (async () => {
const { listen, emitTo } = await import("@tauri-apps/api/event");
if (disposed) return;
const off = await listen<ObjectSettingsSync>(`${PREFIX}-sync`, (e) => {
const next = applyObjectSettingsSync(snap, e.payload);
if (!next) return;
mirrorIntoStore(snap, next);
snap = next;
const f = next.ui.focus;
if (f && f.seq !== focusSeq) {
focusSeq = f.seq;
setSettingsArea("object");
if (f.group) expandAndFocusInfoGroup(f.group);
}
setUi(next.ui);
});
if (disposed) return off();
unlisten.push(off);
await emitTo("main", `${PREFIX}-window-ready`).catch(() => {});
})();
const onKey = (e: KeyboardEvent) => {
if (isTextEntry(document.activeElement)) return;
const mod = e.metaKey || e.ctrlKey;
if (mod && (e.key === "z" || e.key === "Z")) {
e.preventDefault();
send(e.shiftKey ? "redo" : "undo");
} else if (mod && (e.key === "y" || e.key === "Y")) {
e.preventDefault();
send("redo");
} else if (e.key === "Escape") {
void import("@tauri-apps/api/window").then(({ getCurrentWindow }) => getCurrentWindow().close());
}
};
window.addEventListener("keydown", onKey);
return () => {
disposed = true;
window.removeEventListener("keydown", onKey);
unlisten.forEach((u) => u());
setChangeSink(null);
};
}, []);
const hostData = ui?.host;
const handlers = ui?.handlers;
const host = useMemo(
() => (hostData && handlers ? (remoteHost({ host: hostData, handlers }, (name, args) => send("host", [name, args])) as unknown as PanelHost) : null),
[hostData, handlers],
);
return (
<div className="objset-window">
<header className="imp-head" data-tauri-drag-region style={{ paddingLeft: 88 }}>
<span className="imp-head-title">{t("nav.objectSettings")}</span>
</header>
{host ? (
<PanelHostProvider value={host}>
<ObjectSettingsPanel />
</PanelHostProvider>
) : (
<div className="objset-empty">{t("resources.loading")}</div>
)}
</div>
);
}
+132
View File
@@ -0,0 +1,132 @@
// [195b] Sync-Brücke des nativen Fensters „Objekteinstellungen": Spiegelung (Projekt + Auswahl + Host-Werte)
// hin, Ops zurück. Hauptfenster und Nebenfenster teilen sich im Test denselben Store; die Rollen wechseln über
// den Abfluss (`setChangeSink`).
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { getState, setState } from "../state/appStore";
import { setChangeSink } from "../state/changeSink";
import { selectionInfoFor } from "../state/useSelectionInfo";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { patchItem } from "../core/opsBuild";
import type { CoreOp } from "../core/ops";
import { EMPTY_SELECTION } from "../state/selection";
import {
applyObjectSettingsSync,
applyForwardedChange,
hostSnapshot,
mirrorIntoStore,
objectSettingsSync,
remoteHost,
type ObjectSettingsSnapshot,
} from "./objectSettingsSync";
const st = () => getState();
/** Stand, wie ihn das Hauptfenster sendet. */
function snapshot(focus: ObjectSettingsSnapshot["ui"]["focus"] = null): ObjectSettingsSnapshot {
const s = st();
return {
project: s.project,
ui: { selection: s.selection, activeLevelId: s.activeLevelId, ...hostSnapshot({ activeTool: "select", onSetWallType: () => {} }), focus },
};
}
beforeEach(() => {
st().loadProject(buildComplexSampleProject());
setState({ selection: EMPTY_SELECTION });
});
afterEach(() => setChangeSink(null));
describe("Sync-Nachrichten [195b]", () => {
it("erst der ganze Stand, dann nur Auswahl-Patch bei Auswahlwechsel", () => {
const a = snapshot();
const first = objectSettingsSync(null, a);
expect(first && "full" in first).toBe(true);
expect(objectSettingsSync(a, snapshot())).toBeNull();
const wall = st().project.walls[0].id;
setState({ selection: { ...EMPTY_SELECTION, walls: [wall] } });
const b = snapshot();
const msg = objectSettingsSync(a, b);
expect(msg).not.toBeNull();
expect(msg && "project" in msg ? msg.project : undefined).toBeUndefined();
expect(msg && "ui" in msg ? Object.keys(msg.ui!.set) : []).toEqual(["selection"]);
// Fensterseite: aus ganzem Stand + Patch entsteht derselbe Stand.
const mirrored = applyObjectSettingsSync(applyObjectSettingsSync(null, first!), JSON.parse(JSON.stringify(msg)));
expect(mirrored!.ui.selection.walls).toEqual([wall]);
});
it("Projektänderung schickt nur die geänderten Felder; Undo ebenso", () => {
const a = snapshot();
const w = st().project.walls[0];
st().applyChange((p) => patchItem(p, "walls", w.id, { height: 2.333 }));
const b = snapshot();
const msg = objectSettingsSync(a, b)!;
// Wände und davon abhängige Felder (z. B. angehängte Masse), nicht das ganze Projekt.
const fields = "project" in msg ? Object.keys(msg.project!.set) : [];
expect(fields).toContain("walls");
expect(fields.length).toBeLessThan(4);
expect("ui" in msg ? msg.ui : undefined).toBeUndefined();
st().undo();
const c = snapshot();
const back = objectSettingsSync(b, c)!;
expect("project" in back ? Object.keys(back.project!.set) : []).toContain("walls");
const mirrored = applyObjectSettingsSync(b, JSON.parse(JSON.stringify(back)))!;
expect(mirrored.project.walls.find((x) => x.id === w.id)!.height).toBe(w.height);
});
it("Fokus-Anfrage (Taste T) geht als UI-Patch", () => {
const a = snapshot();
const msg = objectSettingsSync(a, snapshot({ seq: 1, group: "wall" }))!;
expect("ui" in msg && msg.ui!.set.focus).toEqual({ seq: 1, group: "wall" });
});
});
describe("Spiegel im Nebenfenster [195b]", () => {
it("Spiegel trägt Projekt, Auswahl und Kern-Dokument (Objekt-Info rechnet darauf)", () => {
const wall = st().project.walls[0].id;
const snap = { ...snapshot(), ui: { ...snapshot().ui, selection: { ...EMPTY_SELECTION, walls: [wall] } } };
const copy = JSON.parse(JSON.stringify(snap)) as ObjectSettingsSnapshot; // über IPC: neue Identität
mirrorIntoStore(null, copy);
expect(st().project).toBe(copy.project);
expect(selectionInfoFor(st().project, st().selection)?.kind).toBe("wall");
});
it("mit Abfluss: Änderung wird nicht lokal angewendet, sondern als Ops abgegeben; Hauptfenster wendet sie mit Undo an", () => {
const w = st().project.walls[0];
const before = st().project;
const sent: Array<[readonly CoreOp[], string | undefined]> = [];
setChangeSink((ops, key) => sent.push([ops, key]));
st().applyChange((p) => patchItem(p, "walls", w.id, { height: 2.271 }), "wall-height");
st().updateWall(w.id, { height: 2.272 });
expect(st().project).toBe(before);
expect(sent.length).toBe(2);
expect(sent[0][1]).toBe("wall-height");
// Hauptfenster: ohne Abfluss, Ops kommen über JSON.
setChangeSink(null);
const depth = st().undoDepth;
for (const [ops, key] of JSON.parse(JSON.stringify(sent)) as Array<[CoreOp[], string | null]>) applyForwardedChange(ops, key);
expect(st().project.walls.find((x) => x.id === w.id)!.height).toBe(2.272);
expect(st().undoDepth).toBe(depth + 2);
st().undo();
expect(st().project.walls.find((x) => x.id === w.id)!.height).toBe(2.271);
});
});
describe("Host im Nebenfenster [195b]", () => {
it("Wert-Felder gespiegelt, Handler ans Hauptfenster weitergeleitet, fehlende Handler fehlen", () => {
const snap = hostSnapshot({ activeTool: "wall", sectionLine: null, onSetWallType: () => {}, displayMode: { mode: "all", setMode: () => {} } });
expect(snap.handlers).toEqual(["onSetWallType"]);
expect(snap.host).toEqual({ activeTool: "wall", sectionLine: null });
const calls: Array<[string, unknown[]]> = [];
const host = remoteHost(snap, (name, args) => calls.push([name, args])) as unknown as Record<string, unknown>;
expect(host.activeTool).toBe("wall");
expect(host.measurement).toBeNull();
expect(host.onSetStairType).toBeUndefined();
(host.onSetWallType as (id: string) => void)("wt-1");
expect(calls).toEqual([["onSetWallType", ["wt-1"]]]);
});
});
+148
View File
@@ -0,0 +1,148 @@
// [195b] Sync-Brücke des nativen Fensters „Objekteinstellungen" (Taste T) — reine Teile, ohne Tauri.
//
// Das Nebenfenster rendert DIESELBEN Komponenten wie das schwebende Panel (`ObjectSettingsPanel` mit Objekt-Info
// und Attributen), nur mit anderer Datenquelle: Es lädt denselben Store, hält ihn aber als Spiegel des
// Hauptfensters (Projekt-Leseansicht + eigenes Kern-Dokument, Auswahl, aktive Ebene) und stellt einen Panel-Host
// bereit, dessen Wert-Felder gespiegelt sind und dessen Handler ans Hauptfenster gehen.
//
// Hauptfenster → Nebenfenster: „object-settings-sync" mit dem ganzen Stand (`{ full }`, nach „ready") bzw. danach
// nur den Änderungen: Projekt als Feld-Differenz der obersten Ebene (`projectDelta`, Referenzvergleich — die
// Leseansicht teilt unveränderte Listen), UI-Teil als `StateDelta` (Strukturvergleich, kleine Werte).
// Nebenfenster → Hauptfenster: „object-settings-command" mit `{ name, args }`:
// - `change` [ops, coalesceKey]: Projekt-Änderung (Store-Aktionen im Nebenfenster rechnen Ops auf dem Spiegel
// und geben sie über `changeSink.ts` ab) → `applyChange` im Hauptfenster (Prüfung, Undo je Änderung);
// - `host` [name, args]: Handler des Panel-Hosts (Wand-Typ setzen, Treppe ändern …) — läuft im Hauptfenster;
// - `undo`, `redo`, `notify` [text, kind].
// Der neue Stand kommt in beiden Fällen über den nächsten Sync zurück (auch nach Undo im Hauptfenster).
import type { Project } from "../model/types";
import type { CoreOp } from "../core/ops";
import type { PanelHostValue } from "../panels/host";
import type { InfoGroupId } from "../panels/objectInfo/groups";
import { getState, setState } from "../state/appStore";
import { storeDocument } from "../state/historySlice";
import type { Selection } from "../state/selection";
import { applyProjectDelta, projectDelta, type ProjectDelta } from "./projectDelta";
import { applyStateDelta, stateDelta, type StateDelta } from "./windowBridge";
export const OBJECT_SETTINGS_WINDOW_LABEL = "object-settings";
export const OBJECT_SETTINGS_PREFIX = "object-settings";
/** UI-Teil des Spiegels (klein, Strukturvergleich). */
export interface ObjectSettingsUi {
selection: Selection;
activeLevelId: string;
/** Wert-Felder des Panel-Hosts (aktives Werkzeug, Schnittlinie …). */
host: Record<string, unknown>;
/** Namen der Handler, die der Host im Hauptfenster hat. */
handlers: string[];
/** Taste T: Bereich „Objekt" zeigen und diesen Abschnitt aufklappen (`seq` zählt die Anfragen). */
focus: { seq: number; group: InfoGroupId | null } | null;
}
export interface ObjectSettingsSnapshot {
project: Project;
ui: ObjectSettingsUi;
}
export type ObjectSettingsSync = { full: ObjectSettingsSnapshot } | { project?: ProjectDelta; ui?: StateDelta };
/** Nachricht von `prev` (zuletzt gesendet, `null` = noch nichts) nach `next`; `null` = nichts zu senden. */
export function objectSettingsSync(prev: ObjectSettingsSnapshot | null, next: ObjectSettingsSnapshot): ObjectSettingsSync | null {
if (!prev) return { full: next };
const project = prev.project === next.project ? null : projectDelta(prev.project, next.project);
const ui = stateDelta(prev.ui, next.ui);
if (ui === "full") return { full: next };
if (!project && !ui) return null;
return { ...(project ? { project } : {}), ...(ui ? { ui } : {}) };
}
/** Fensterseite: Nachricht anwenden. Eine Differenz vor dem ersten ganzen Stand wird verworfen (`null`). */
export function applyObjectSettingsSync(prev: ObjectSettingsSnapshot | null, msg: ObjectSettingsSync): ObjectSettingsSnapshot | null {
if ("full" in msg) return msg.full;
if (!prev) return null;
return {
project: msg.project ? applyProjectDelta(prev.project, msg.project) : prev.project,
ui: msg.ui ? applyStateDelta(prev.ui, msg.ui) : prev.ui,
};
}
/** Felder, die das Nebenfenster selbst stellt (nicht JSON-tauglich bzw. je Mausschritt neu). */
const LOCAL_HOST_FIELDS = new Set(["displayMode", "measurement"]);
/** Übersteht der Wert die IPC-Serialisierung (keine Zyklen)? */
function jsonSafe(v: unknown): boolean {
try {
JSON.stringify(v);
return true;
} catch {
return false;
}
}
/** Host des Hauptfensters zerlegt in gespiegelte Wert-Felder und die Namen seiner Handler. */
export function hostSnapshot(host: object): Pick<ObjectSettingsUi, "host" | "handlers"> {
const values: Record<string, unknown> = {};
const handlers: string[] = [];
for (const [k, v] of Object.entries(host)) {
if (LOCAL_HOST_FIELDS.has(k)) continue;
if (typeof v === "function") handlers.push(k);
else if (v !== undefined && jsonSafe(v)) values[k] = v;
}
return { host: values, handlers: handlers.sort() };
}
/**
* Panel-Host des Nebenfensters: Wert-Felder aus dem Spiegel, Handler leiten über `call` ans Hauptfenster weiter
* (Argumente sind reine Daten). Handler, die das Hauptfenster nicht hat, fehlen auch hier (Panels prüfen
* optionale Handler auf Vorhandensein). Kein Messwert im Nebenfenster (änderte sich je Mausschritt).
*/
export function remoteHost(
ui: Pick<ObjectSettingsUi, "host" | "handlers">,
call: (name: string, args: unknown[]) => void,
): PanelHostValue {
const handlers = new Set(ui.handlers);
const forwarders = new Map<string, (...args: unknown[]) => void>();
const displayMode = { mode: "all" as const, setMode: () => {} };
return new Proxy({} as PanelHostValue, {
get(_t, prop) {
if (typeof prop !== "string") return undefined;
if (prop === "displayMode") return displayMode;
if (prop === "measurement") return null;
if (handlers.has(prop)) {
let fn = forwarders.get(prop);
if (!fn) {
fn = (...args: unknown[]) => call(prop, args);
forwarders.set(prop, fn);
}
return fn;
}
return ui.host[prop];
},
has(_t, prop) {
return typeof prop === "string" && (handlers.has(prop) || prop in ui.host || LOCAL_HOST_FIELDS.has(prop));
},
});
}
/**
* Fensterseite: Spiegel in den Store übernehmen. Ein neues Projekt wird ins Kern-Dokument des Stores geladen
* (Abfragen wie die Objekt-Info rechnen darauf, `documentFor`); Verlauf führt nur das Hauptfenster.
*/
export function mirrorIntoStore(prev: ObjectSettingsSnapshot | null, next: ObjectSettingsSnapshot): void {
const patch: Record<string, unknown> = {};
if (!prev || prev.project !== next.project) {
const doc = storeDocument(next.project);
if (doc.current !== next.project) doc.load(next.project);
patch.project = next.project;
}
if (!prev || prev.ui.selection !== next.ui.selection) patch.selection = next.ui.selection;
if (!prev || prev.ui.activeLevelId !== next.ui.activeLevelId) patch.activeLevelId = next.ui.activeLevelId;
if (Object.keys(patch).length > 0) setState(patch as Parameters<typeof setState>[0]);
}
/** Hauptfensterseite: Änderung aus dem Nebenfenster anwenden (`null` aus JSON = kein Schlüssel). */
export function applyForwardedChange(ops: readonly CoreOp[], coalesceKey: string | null | undefined): void {
if (!Array.isArray(ops) || ops.length === 0) return;
getState().applyChange(ops, coalesceKey ?? undefined);
}
@@ -0,0 +1,40 @@
// [195b] Das native Fenster rendert dieselben Abschnitte wie das schwebende Panel, nur mit gespiegeltem Store und
// weiterleitendem Host (`remoteHost`). Ohne DOM: Server-Render des Panels im Fenster-Aufbau.
import { createElement } from "react";
import { renderToString } from "react-dom/server";
import { afterEach, describe, expect, it } from "vitest";
import { getState } from "../state/appStore";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { EMPTY_SELECTION } from "../state/selection";
import { PanelHostProvider } from "../panels/host";
import type { PanelHost } from "../panels/types";
import { ObjectSettingsPanel } from "../panels/objectSettings/ObjectSettingsPanel";
import { setChangeSink } from "../state/changeSink";
import { mirrorIntoStore, remoteHost, type ObjectSettingsSnapshot } from "./objectSettingsSync";
afterEach(() => setChangeSink(null));
describe("Fenster Objekteinstellungen rendert die Panel-Abschnitte [195b]", () => {
it("Wand gewählt: Bereiche Objekt + Darstellung, Inhalt statt „Keine Auswahl“", () => {
const project = JSON.parse(JSON.stringify(buildComplexSampleProject())) as ObjectSettingsSnapshot["project"];
const wall = project.walls[0];
const snap: ObjectSettingsSnapshot = {
project,
ui: {
selection: { ...EMPTY_SELECTION, walls: [wall.id] },
activeLevelId: wall.floorId,
host: { activeTool: "select", sectionLine: null },
handlers: ["onSetWallType"],
focus: null,
},
};
mirrorIntoStore(null, snap);
setChangeSink(() => {});
const host = remoteHost(snap.ui, () => {}) as unknown as PanelHost;
const html = renderToString(createElement(PanelHostProvider, { value: host }, createElement(ObjectSettingsPanel)));
expect(getState().project).toBe(project);
expect(html).toContain('data-area="object"');
expect(html).toContain('data-area="appearance"');
expect(html).not.toContain("objset-empty");
});
});
+161
View File
@@ -0,0 +1,161 @@
// [195b] Fenster „Objekteinstellungen" (Taste T) als EIGENES natives Tauri-Fenster wie Einstellungen/Ressourcen —
// Hauptfenster-Seite der Brücke. Protokoll und reine Teile: `objectSettingsSync.ts`; Fensterseite:
// `ObjectSettingsWindowApp.tsx`. Im Browser/Electron bleibt das schwebende Panel (`state/objectSettings.ts`).
//
// Der Spiegel wird nur gesendet, solange das Fenster offen ist (es meldet „ready"; zu = `getByLabel` leer), kurz
// gebündelt, und ohne React-Abo im Hauptfenster: der Hook hört direkt am Store, eine Op rendert die App nicht neu.
import { useEffect, useRef } from "react";
import { getState, subscribe } from "../state/appStore";
import { t } from "../i18n";
import type { NotifyKind } from "../state/notifySlice";
import type { InfoGroupId } from "../panels/objectInfo/groups";
import type { CoreOp } from "../core/ops";
import { isTauriRuntime } from "./projectFile";
import { BORDERLESS_WINDOW_CHROME } from "./windowChrome";
import {
OBJECT_SETTINGS_PREFIX as PREFIX,
OBJECT_SETTINGS_WINDOW_LABEL as LABEL,
applyForwardedChange,
hostSnapshot,
objectSettingsSync,
type ObjectSettingsSnapshot,
} from "./objectSettingsSync";
let focus: ObjectSettingsSnapshot["ui"]["focus"] = null;
const focusListeners = new Set<() => void>();
/**
* Öffnet das Fenster (bzw. holt es nach vorne) und bittet es, den Bereich „Objekt" zu zeigen und `group`
* aufzuklappen (Taste T, `state/objectSettings.ts`).
*/
export async function openObjectSettingsWindowNative(group: InfoGroupId | null): Promise<void> {
focus = { seq: (focus?.seq ?? 0) + 1, group };
for (const l of [...focusListeners]) l();
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
const existing = await WebviewWindow.getByLabel(LABEL);
if (existing) {
await existing.setFocus();
return;
}
new WebviewWindow(LABEL, {
url: "index.html?window=object-settings",
title: `${t("nav.objectSettings")} — dossier`,
width: 380,
height: 620,
minWidth: 300,
minHeight: 320,
...BORDERLESS_WINDOW_CHROME,
});
}
/** Bündelung der Sync-Nachrichten (ms): Tippen/Ziehen schickt nicht jeden Zwischenstand einzeln. */
const SYNC_DELAY_MS = 30;
/**
* Hält das Fenster (falls offen) synchron zu Projekt, Auswahl, aktiver Ebene und den Wert-Feldern von `host`
* (Panel-Host der App) und führt seine Befehle aus: Ops per `applyChange`, Host-Handler auf `host`. No-op
* ausserhalb von Tauri.
*/
export function useObjectSettingsWindowHost(host: object): void {
const hostRef = useRef(host);
hostRef.current = host;
const scheduleRef = useRef<() => void>(() => {});
useEffect(() => {
if (!isTauriRuntime()) return;
let disposed = false;
let open = false;
let sent: ObjectSettingsSnapshot | null = null;
let timer: ReturnType<typeof setTimeout> | null = null;
const unlisten: Array<() => void> = [];
const current = (): ObjectSettingsSnapshot => {
const s = getState();
return { project: s.project, ui: { selection: s.selection, activeLevelId: s.activeLevelId, ...hostSnapshot(hostRef.current), focus } };
};
const flush = async () => {
timer = null;
if (disposed || !open) return;
const { WebviewWindow } = await import("@tauri-apps/api/webviewWindow");
if (!(await WebviewWindow.getByLabel(LABEL))) {
// Fenster zu: beim nächsten Öffnen meldet es „ready" und bekommt den ganzen Stand.
open = false;
sent = null;
return;
}
const next = current();
const msg = objectSettingsSync(sent, next);
if (!msg) return;
sent = next;
const { emitTo } = await import("@tauri-apps/api/event");
await emitTo(LABEL, `${PREFIX}-sync`, msg).catch(() => {
sent = null;
});
};
const schedule = () => {
if (!open || timer !== null) return;
timer = setTimeout(() => void flush(), SYNC_DELAY_MS);
};
scheduleRef.current = schedule;
// Store-Änderungen: nur Projekt, Auswahl, aktive Ebene zählen (der Rest ändert sich oft und interessiert nicht).
let last = getState();
unlisten.push(
subscribe(() => {
const s = getState();
if (s.project !== last.project || s.selection !== last.selection || s.activeLevelId !== last.activeLevelId) schedule();
last = s;
}),
);
focusListeners.add(schedule);
unlisten.push(() => focusListeners.delete(schedule));
void (async () => {
const { listen } = await import("@tauri-apps/api/event");
if (disposed) return;
const offReady = await listen(`${PREFIX}-window-ready`, () => {
open = true;
sent = null;
void flush();
});
const offCommand = await listen<{ name: string; args?: unknown[] }>(`${PREFIX}-command`, (e) => {
const args = e.payload.args ?? [];
switch (e.payload.name) {
case "change":
applyForwardedChange(args[0] as CoreOp[], args[1] as string | null);
break;
case "host": {
const fn = (hostRef.current as Record<string, unknown>)[args[0] as string];
if (typeof fn === "function") (fn as (...a: unknown[]) => void)(...((args[1] as unknown[]) ?? []));
break;
}
case "undo":
getState().undo();
break;
case "redo":
getState().redo();
break;
case "notify":
getState().notify(String(args[0] ?? ""), (args[1] as NotifyKind | undefined) ?? "info");
break;
}
});
if (disposed) {
offReady();
offCommand();
return;
}
unlisten.push(offReady, offCommand);
})();
return () => {
disposed = true;
if (timer !== null) clearTimeout(timer);
unlisten.forEach((u) => u());
scheduleRef.current = () => {};
};
}, []);
// Host-Werte (aktives Werkzeug, Schnittlinie …) ändern sich mit dem Host.
useEffect(() => scheduleRef.current(), [host]);
}
+16 -12
View File
@@ -614,18 +614,22 @@ export function AttributesPanel() {
fillEditable,
hatchUi,
onHatchSourceChange,
<Dropdown
value={hatchPatternIsNone ? "" : sel.effectiveHatchId ?? ""}
disabled={!fillEditable}
onChange={(v) => host.onSetSelectionFill(v || null)}
options={[
{ value: "", label: t("attr.hatch.none") },
// Die Ressource „Ohne" (Muster none) wäre dasselbe wie „Keine Schraffur".
...project.hatches
.filter((h) => h.pattern !== "none")
.map((h) => ({ value: h.id, label: h.name })),
]}
/>,
<>
<Dropdown
value={hatchPatternIsNone ? "" : sel.effectiveHatchId ?? ""}
disabled={!fillEditable}
onChange={(v) => host.onSetSelectionFill(v || null)}
options={[
{ value: "", label: t("attr.hatch.none") },
// Die Ressource „Ohne" (Muster none) wäre dasselbe wie „Keine Schraffur".
...project.hatches
.filter((h) => h.pattern !== "none")
.map((h) => ({ value: h.id, label: h.name })),
]}
/>
{/* [195b] Mehrfachauswahl mit abweichender Schraffur. */}
{appearance.hatch.mixed && <span className="attr-mixed" data-mixed="hatch">{t("objsettings.mixed")}</span>}
</>,
)}
{/* Transparenz NUR der Füllung/Schraffurfläche (Umriss bleibt deckend);
+1 -1
View File
@@ -7,7 +7,7 @@ import { INFO_GROUP_TITLE, type InfoGroupId } from "./groups";
import { clearInfoGroupFocus, getInfoGroupState, subscribeInfoGroups, toggleInfoGroup } from "./infoGroupState";
export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) {
const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState);
const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState);
const open = !st.collapsed.has(id);
const head = useRef<HTMLButtonElement>(null);
useEffect(() => {
+19 -5
View File
@@ -1,7 +1,9 @@
// Abschnitt „Wand" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Referenzlinie, Aufbau, Geschoss, Unter-
// und Oberkante. Gerufen von `AttributesPanel`.
import { useMemo } from "react";
import { useStore } from "../../state/appStore";
import { selectionWallValues } from "../../state/mixedValues";
import type { WallInfo } from "../../state/selectionInfo";
import { usePanelHost } from "../host";
import { t } from "../../i18n";
@@ -22,6 +24,14 @@ export function WallSection({
host: ReturnType<typeof usePanelHost>;
}) {
const storeProject = useStore((st) => st.project);
const selection = useStore((st) => st.selection);
// [195b] Mehrfachauswahl: abweichender Typ/abweichende Dicke als „gemischt" kennzeichnen.
const multi = useMemo(
() => (selection.walls.length > 1 ? selectionWallValues(storeProject, selection) : null),
[storeProject, selection],
);
const mixedMark = (on: boolean | undefined, what: string) =>
on ? <span className="attr-mixed" data-mixed={what}>{t("objsettings.mixed")}</span> : null;
// Aufbau-Typ-Segment: einschichtig vs. mehrschichtig. Aus dem Modell
// abgeleitet (singleLayer); der Umschalter auf „mehrschichtig" wählt einen
// mehrschichtigen Wandtyp-Preset (erster mit >1 Schicht), auf „einschichtig"
@@ -134,11 +144,14 @@ export function WallSection({
{/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */}
{isSingle ? (
<DimensionField
label={t("objinfo.wall.thickness")}
value={wall.thickness}
onCommit={(v) => host.onSetWallThickness(v)}
/>
<>
<DimensionField
label={t("objinfo.wall.thickness")}
value={wall.thickness}
onCommit={(v) => host.onSetWallThickness(v)}
/>
{mixedMark(multi?.thickness.mixed, "thickness")}
</>
) : (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.wall.preset")}</span>
@@ -153,6 +166,7 @@ export function WallSection({
title={t("objinfo.wall.preset")}
width={150}
/>
{mixedMark(multi?.wallTypeId.mixed, "wallType")}
</div>
)}
@@ -20,7 +20,7 @@ export function ObjectSettingsPanel() {
const sel = useSelectionInfo();
const otherSelected = useStore((s) => s.selection.trees.length + s.selection.site.length > 0);
const isGrid = useStore((s) => (sel?.kind === "drawing2d" ? s.project.drawings2d.find((d) => d.id === sel.id)?.geom.shape === "grid" : false));
const wanted = useSyncExternalStore(subscribeSettingsArea, getSettingsArea);
const wanted = useSyncExternalStore(subscribeSettingsArea, getSettingsArea, getSettingsArea);
const areas = settingsAreas({
sel,
+1
View File
@@ -63,6 +63,7 @@ const store = createStore<RootState>((api) => ({
export const useStore = store.useStore;
export const getState = store.getState;
export const setState = store.setState;
export const subscribe = store.subscribe;
// Aktive Ebene nach Projektänderungen absichern: Undo/Redo (oder jede andere Änderung) kann die
+22
View File
@@ -0,0 +1,22 @@
// [195b] Umleitung der Projekt-Änderungen eines Nebenfensters: Im nativen Fenster „Objekteinstellungen" läuft
// derselbe Store wie im Hauptfenster, aber nur als Spiegel (Leseansicht + eigenes Kern-Dokument, nachgeführt
// über die Sync-Brücke). Ist ein Abfluss gesetzt, wenden `applyChange`, `setProject`, Befehle und Griffe
// NICHTS lokal an: sie rechnen die Ops auf dem Spiegel (der dem Stand des Hauptfensters gleicht) und geben sie
// mit `coalesceKey` hierher ab; das Hauptfenster wendet sie per `applyChange` an (Prüfung, Undo je Änderung)
// und schickt den neuen Stand zurück. Im Hauptfenster ist kein Abfluss gesetzt (eine Abfrage, sonst nichts).
import type { CoreOp } from "../core/ops";
export type ChangeSink = (ops: readonly CoreOp[], coalesceKey: string | undefined) => void;
let sink: ChangeSink | null = null;
/** Abfluss setzen (`null` = wieder lokal anwenden). */
export function setChangeSink(next: ChangeSink | null): void {
sink = next;
}
/** Aktueller Abfluss oder `null` (Hauptfenster). */
export function changeSink(): ChangeSink | null {
return sink;
}
+24 -1
View File
@@ -1,7 +1,7 @@
// [195] Mehrfach-Werte: gleiche Werte → ein Wert, abweichende → leer (gemischt).
import { describe, expect, it } from "vitest";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { commonValue, selectionAppearance, selectedCount } from "./mixedValues";
import { commonValue, selectionAppearance, selectionWallValues, selectedCount } from "./mixedValues";
import { EMPTY_SELECTION, mergeSelection } from "./selection";
describe("commonValue [195]", () => {
@@ -37,3 +37,26 @@ describe("selectionAppearance [195]", () => {
expect(selectedCount(sel)).toBe(1);
});
});
describe("Mehrfachwerte Füllung/Typ/Masse [195b]", () => {
const p = buildComplexSampleProject();
const [a, b] = p.walls;
const other = p.wallTypes.find((t) => t.id !== a.wallTypeId)!;
const same = { ...p, walls: p.walls.map((w) => (w.id === b.id ? { ...w, wallTypeId: a.wallTypeId } : w)) };
const sel = mergeSelection(EMPTY_SELECTION, { walls: [a.id, b.id] });
it("gleicher Wandtyp → ein Wert; anderer Typ → Typ gemischt", () => {
const v = selectionWallValues(same, sel);
expect(v.wallTypeId).toEqual({ value: a.wallTypeId, mixed: false });
expect(v.thickness.mixed).toBe(false);
const changed = { ...p, walls: p.walls.map((w) => (w.id === b.id ? { ...w, wallTypeId: other.id } : w)) };
expect(selectionWallValues(changed, sel).wallTypeId.mixed).toBe(true);
});
it("Schraffur: gleich → Wert, abweichend → gemischt", () => {
expect(selectionAppearance(same, sel).hatch.mixed).toBe(false);
const [h1, h2] = p.hatches.filter((x) => x.pattern !== "none");
const changed = { ...same, walls: same.walls.map((w) => (w.id === a.id ? { ...w, hatchId: h1.id } : w.id === b.id ? { ...w, hatchId: h2.id } : w)) };
expect(selectionAppearance(changed, sel).hatch.mixed).toBe(true);
});
});
+23 -1
View File
@@ -28,6 +28,8 @@ export interface SelectionAppearance {
count: number;
weightMm: Common<number>;
color: Common<string>;
/** [195b] Wirksame Schraffur (Ressourcen-id, "" = keine). */
hatch: Common<string>;
}
/** Zahl der gewählten Elemente (ohne Gruppen, Schnittlinien, Lage-Darstellung, Bäume). */
@@ -39,6 +41,7 @@ export function selectedCount(sel: Selection): number {
export function selectionAppearance(project: Project, sel: Selection): SelectionAppearance {
const weights: number[] = [];
const colors: string[] = [];
const hatches: string[] = [];
let n = 0;
for (const kind of STYLE_KINDS) {
for (const id of sel[kind]) {
@@ -47,7 +50,26 @@ export function selectionAppearance(project: Project, sel: Selection): Selection
if (!info) continue;
weights.push(info.weightMm);
colors.push(info.color);
hatches.push(info.effectiveHatchId ?? "");
}
}
return { count: selectedCount(sel), weightMm: commonValue(weights), color: commonValue(colors) };
return { count: selectedCount(sel), weightMm: commonValue(weights), color: commonValue(colors), hatch: commonValue(hatches) };
}
/** [195b] Wandtyp und Dicke über die gewählten Wände (Typ und Masse bei Mehrfachauswahl). */
export interface SelectionWallValues {
wallTypeId: Common<string>;
thickness: Common<number>;
}
export function selectionWallValues(project: Project, sel: Selection): SelectionWallValues {
const types: string[] = [];
const thick: number[] = [];
for (const id of sel.walls.slice(0, MAX_COMPARED)) {
const wall = deriveSelection(project, { walls: [id] })?.wall;
if (!wall) continue;
types.push(wall.wallTypeId);
thick.push(wall.thickness);
}
return { wallTypeId: commonValue(types), thickness: commonValue(thick) };
}
+7 -6
View File
@@ -1,9 +1,10 @@
// [195] Taste T (wie Archicad Cmd+T): das Fenster „Objekteinstellungen" öffnen (schwebendes Panel `object-settings`,
// folgt der Auswahl; Bereiche Objekt + Darstellung). Der passende Abschnitt des Bereichs Objekt wird aufgeklappt
// [195] Taste T (wie Archicad Cmd+T): das Fenster „Objekteinstellungen" öffnen (unter Tauri ein natives Nebenfenster,
// [195b] `native/objectSettingsWindow.ts`; sonst das schwebende Panel `object-settings`; folgt der Auswahl; Bereiche
// Objekt + Darstellung). Der passende Abschnitt des Bereichs Objekt wird aufgeklappt
// und fokussiert; ohne Auswahl die Voreinstellung des aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst
// nichts. Die Zuordnung Auswahl → Abschnitt ist rein (`panels/objectInfo/groups.ts::objectSettingsTarget`).
import { objectSettingsTarget } from "../panels/objectInfo/groups";
import { objectSettingsTarget, type InfoGroupId } from "../panels/objectInfo/groups";
import { setSettingsArea } from "../panels/objectSettings/areaState";
import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState";
import { getState } from "./appStore";
@@ -12,8 +13,8 @@ import { selectionInfoFor } from "./useSelectionInfo";
export interface ObjectSettingsDeps {
/** Aktives Werkzeug (React-State der App). */
activeTool: string;
/** Fenster Objekteinstellungen sichtbar machen (schwebend öffnen bzw. nach vorne holen). */
revealObjectSettings: () => void;
/** Fenster Objekteinstellungen sichtbar machen (öffnen bzw. nach vorne holen); `group` = aufzuklappender Abschnitt. */
revealObjectSettings: (group: InfoGroupId | null) => void;
}
/** Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. */
@@ -28,7 +29,7 @@ export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
if (!target) return false;
setSettingsArea("object");
if (target.group) expandAndFocusInfoGroup(target.group);
deps.revealObjectSettings();
deps.revealObjectSettings(target.group);
return true;
}
@@ -0,0 +1,28 @@
// [195b] Wandtyp bei Mehrfachauswahl: gilt für alle gewählten Wände, ein Undo-Schritt.
import { describe, expect, it } from "vitest";
import { getState, setState } from "../appStore";
import { buildComplexSampleProject } from "../../model/sampleProjectComplex";
import { EMPTY_SELECTION } from "../selection";
import { buildElementAttributesHost } from "./elementAttributesHost";
import type { FlatHostOpts } from "./types";
describe("onSetWallType [195b]", () => {
it("setzt den Typ aller gewählten Wände in einem Schritt", () => {
getState().loadProject(buildComplexSampleProject());
const [a, b] = getState().project.walls;
const target = getState().project.wallTypes.find((t) => t.id !== a.wallTypeId && t.id !== b.wallTypeId)!;
setState({ selection: { ...EMPTY_SELECTION, walls: [a.id, b.id] } });
const s = getState();
const host = buildElementAttributesHost({
applyChange: s.applyChange,
updateWall: s.updateWall,
selection: { kind: "wall", id: a.id },
} as unknown as FlatHostOpts) as { onSetWallType: (id: string) => void };
const depth = getState().undoDepth;
host.onSetWallType(target.id);
const walls = getState().project.walls;
expect(walls.find((w) => w.id === a.id)!.wallTypeId).toBe(target.id);
expect(walls.find((w) => w.id === b.id)!.wallTypeId).toBe(target.id);
expect(getState().undoDepth).toBe(depth + 1);
});
});
+7 -3
View File
@@ -3,7 +3,8 @@
// Handler wirkt nur bei passender Auswahl (`selection.kind`) und schreibt über die Projekt-Aktionen
// bzw. `applyChange`.
import { patchItem, removeRoofHole, setRoofEdge } from "../../core";
import { patchItem, patchItems, removeRoofHole, setRoofEdge } from "../../core";
import { getState } from "../appStore";
import type { FlatHostOpts, HostPart } from "./types";
export function buildElementAttributesHost(c: FlatHostOpts) {
@@ -46,8 +47,11 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
if (selection?.kind === "ceiling") updateCeiling(selection.id, { edgeAtOutline: edgeAtOutline || undefined });
},
onSetWallType: (wallTypeId) => {
if (selection?.kind === "wall")
updateWall(selection.id, { wallTypeId });
if (selection?.kind !== "wall") return;
// [195b] Mehrfachauswahl: alle gewählten Wände bekommen den Typ (ein Undo-Schritt).
const ids = getState().selection.walls;
if (ids.length > 1) applyChange((p) => patchItems(p, "walls", ids, (w) => ({ ...w, wallTypeId })));
else updateWall(selection.id, { wallTypeId });
},
onSetWallThickness: (thickness) => {
if (selection?.kind === "wall")
+21 -3
View File
@@ -9,6 +9,7 @@
// RootState (siehe appStore.ts), wir greifen punktuell auf View-Felder zu.
import { applyOps } from "../core/ops";
import { changeSink } from "./changeSink";
import type { CoreOp } from "../core/ops";
import type { ProjectMutation } from "../core";
import { withDocument } from "../core";
@@ -557,12 +558,25 @@ export function createProjectSlice(
// von den paar bekannten Hochfrequenz-Aktionen (Grip-Drag & Co.) gesetzt — alle anderen Aktionen
// rufen ohne Key auf und pushen damit IMMER diskret. Das Projekt ändert sich NUR über Ops: der Kern
// prüft (NaN, doppelte ids), wendet an und zeichnet den Undo-Schritt auf ([K4] S3).
const setProject = (next: ProjectMutation, coalesceKey?: string) =>
next.coreReq ? applyCmd(next.coreReq, coalesceKey) : set((s) => commitOps(s, next.toOps(s.project), coalesceKey));
const setProject = (next: ProjectMutation, coalesceKey?: string) => {
if (forwarded(() => (next.coreReq ? storeDocument(get().project).cmdOps(next.coreReq) : next.toOps(get().project)), coalesceKey)) return;
if (next.coreReq) applyCmd(next.coreReq, coalesceKey);
else set((s) => commitOps(s, next.toOps(s.project), coalesceKey));
};
// [195b] Nebenfenster (`changeSink.ts`): Ops auf dem Spiegel rechnen und ans Hauptfenster abgeben statt anwenden.
const forwarded = (ops: () => readonly CoreOp[], coalesceKey: string | undefined): boolean => {
const sink = changeSink();
if (!sink) return false;
const list = ops();
if (list.length > 0) sink(list, coalesceKey);
return true;
};
// Befehl ([K4] S3, `commands.rs`): der Kern rechnet ihn auf dem Dokument und wendet ihn im selben
// Aufruf an (`cmdMutation`); Prüfung, Verlauf und Meldungen wie `commitOps`.
const applyCmd = (req: object, coalesceKey?: string) => {
if (forwarded(() => storeDocument(get().project).cmdOps(req), coalesceKey)) return;
let notice: string | undefined;
set((s) => {
const doc = storeDocument(s.project);
@@ -589,7 +603,10 @@ export function createProjectSlice(
const applyChange = (
ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[]),
coalesceKey?: string,
) => set((s) => commitOps(s, typeof ops === "function" ? ops(s.project) : ops, coalesceKey));
) => {
if (forwarded(() => (typeof ops === "function" ? ops(get().project) : ops), coalesceKey)) return;
set((s) => commitOps(s, typeof ops === "function" ? ops(s.project) : ops, coalesceKey));
};
// Hinweis aus dem Kern (i18n-Schlüssel) melden — derselbe höchstens alle 2 s (Griff-Zug: je Mausschritt).
let lastNotice = { key: "", at: 0 };
@@ -607,6 +624,7 @@ export function createProjectSlice(
// Griff-Änderung ([K4] S3): der Kern rechnet sie auf dem Dokument und wendet sie im selben Aufruf an
// (`grips.rs`, ein WASM-Aufruf je Mausschritt); Prüfung, Verlauf und Meldungen wie `commitOps`.
const applyGrip = (req: GripRequest, coalesceKey?: string) => {
if (forwarded(() => storeDocument(get().project).gripOps(req).ops, coalesceKey)) return;
let notice: string | undefined;
set((s) => {
const doc = storeDocument(s.project);
+10
View File
@@ -8860,6 +8860,16 @@ body {
padding: 16px 8px;
text-align: center;
}
/* [195b] Natives Nebenfenster: Kopfzeile zum Ziehen, darunter das Panel über die volle Höhe. */
.objset-window {
display: flex;
flex-direction: column;
height: 100vh;
background: var(--panel, var(--bg));
}
.objset-window > .objset-panel {
flex: 1 1 auto;
}
.attr-mixed {
color: var(--muted);
font-size: 11px;