host.onSetWallThickness(v)}
+ />
+ {mixedMark(multi?.thickness.mixed, "thickness")}
+ >
) : (
{t("objinfo.wall.preset")}
@@ -153,6 +166,7 @@ export function WallSection({
title={t("objinfo.wall.preset")}
width={150}
/>
+ {mixedMark(multi?.wallTypeId.mixed, "wallType")}
)}
diff --git a/src/panels/objectSettings/ObjectSettingsPanel.tsx b/src/panels/objectSettings/ObjectSettingsPanel.tsx
index b004cf6e..1127809a 100644
--- a/src/panels/objectSettings/ObjectSettingsPanel.tsx
+++ b/src/panels/objectSettings/ObjectSettingsPanel.tsx
@@ -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,
diff --git a/src/state/appStore.ts b/src/state/appStore.ts
index e0f68226..1cddbf42 100644
--- a/src/state/appStore.ts
+++ b/src/state/appStore.ts
@@ -63,6 +63,7 @@ const store = createStore((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
diff --git a/src/state/changeSink.ts b/src/state/changeSink.ts
new file mode 100644
index 00000000..1ecee073
--- /dev/null
+++ b/src/state/changeSink.ts
@@ -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;
+}
diff --git a/src/state/mixedValues.test.ts b/src/state/mixedValues.test.ts
index 4e6d5ee5..53970130 100644
--- a/src/state/mixedValues.test.ts
+++ b/src/state/mixedValues.test.ts
@@ -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);
+ });
+});
diff --git a/src/state/mixedValues.ts b/src/state/mixedValues.ts
index 876dbb66..10b10ff2 100644
--- a/src/state/mixedValues.ts
+++ b/src/state/mixedValues.ts
@@ -28,6 +28,8 @@ export interface SelectionAppearance {
count: number;
weightMm: Common;
color: Common;
+ /** [195b] Wirksame Schraffur (Ressourcen-id, "" = keine). */
+ hatch: Common;
}
/** 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;
+ thickness: Common;
+}
+
+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) };
}
diff --git a/src/state/objectSettings.ts b/src/state/objectSettings.ts
index 3cddb509..1e86267c 100644
--- a/src/state/objectSettings.ts
+++ b/src/state/objectSettings.ts
@@ -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;
}
diff --git a/src/state/panelHost/elementAttributesHost.test.ts b/src/state/panelHost/elementAttributesHost.test.ts
new file mode 100644
index 00000000..63cba138
--- /dev/null
+++ b/src/state/panelHost/elementAttributesHost.test.ts
@@ -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);
+ });
+});
diff --git a/src/state/panelHost/elementAttributesHost.ts b/src/state/panelHost/elementAttributesHost.ts
index 9fa0c36a..45411fe8 100644
--- a/src/state/panelHost/elementAttributesHost.ts
+++ b/src/state/panelHost/elementAttributesHost.ts
@@ -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")
diff --git a/src/state/projectSlice.ts b/src/state/projectSlice.ts
index 3aa4ef15..2d939372 100644
--- a/src/state/projectSlice.ts
+++ b/src/state/projectSlice.ts
@@ -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);
diff --git a/src/styles.css b/src/styles.css
index 7d8671f6..a475f43a 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -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;