Files
DOSSIER/src/DrawingTabs.tsx
T
Claude 5530089eea [185] Navigation wie Archicad: Geschosswechsel behält Zoom, Cmd+5/6 Geschoss, Cmd+3/4 Auswahl im 3D
Grundriss: Geschosse teilen den Einpass-Schlüssel (planFitKey, PlanView fitKey), Wechsel behält
Ausschnitt und Massstab exakt. Cmd/Ctrl+5/6 Geschoss tiefer/höher im Grundriss- und 3D-Reiter.
Cmd/Ctrl+3 zeigt nur die Auswahl im 3D (Reiter „3D · Auswahl“, Kamera passt ein; ohne Auswahl alles),
Cmd/Ctrl+4 blendet die Auswahl im 3D aus. Zustand rein UI (state/view3dFilter.ts). Kern:
model3d::ElementSelection im ClassFilter (only/hideIds für Teile, Cache, Pick). Kürzel umbelegbar,
natives Menü Ansicht. PlanViewHandle.pxPerMeter liest die aktuelle viewBox.
2026-11-11 19:39:51 +00:00

91 lines
3.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Zeichnungs-Reiterleiste — Kopfzeile über der Zeichenfläche ([136]).
//
// Ein Reiter ist eine OFFENE Ansicht (UI-Zustand, state/viewTabs.ts), kein Ausschnitt: beliebig viele,
// auch mehrere aus demselben Ausschnitt oder ganz ohne Ausschnitt. Jeder Reiter merkt sich seinen
// Darstellungszustand (Geschoss/Schnitt/Ansicht, Massstab, Sichtbarkeit, Overrides, Kamera); ein Klick
// wechselt dorthin. „+" öffnet einen neuen Reiter mit der aktuellen Ansicht, „×" schliesst nur den Reiter
// (nie den letzten) — Ausschnitte werden ausschliesslich im Panel „Ausschnitte" angelegt/gelöscht. Der
// Titel ist der Name des Ausschnitts, aus dem der Reiter geöffnet wurde, sonst der Name der Zeichnungsebene.
//
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md).
import { memo } from "react";
import type { ViewSnapshot } from "./model/types";
import { useStore } from "./state/appStore";
import { tabTitle, type ViewTab, type ViewTabsState } from "./state/viewTabs";
import { isSelectionMode, useView3dFilter } from "./state/view3dFilter";
import { t } from "./i18n";
/** Handler-Bündel der Reiterleiste (Host-Handler in state/usePanelHostBase.ts). */
export interface ViewSnapshotTabsHandlers {
tabs: ViewTabsState;
onActivate: (tabId: string) => void;
onNew: () => void;
onClose: (tabId: string) => void;
/** Titel eines Reiters ohne Ausschnitt (Zeichnungskombination bzw. Zeichnungsebene). */
autoName: (levelId?: string, is3d?: boolean) => string;
}
const NO_SNAPSHOTS: ViewSnapshot[] = [];
/** Memoisiert ([121]): rendert nur, wenn sich Ausschnitte oder Reiter-Handler ändern, nicht bei jeder Op. */
export const DrawingTabs = memo(function DrawingTabs({ handlers }: { handlers: ViewSnapshotTabsHandlers }) {
const snapshots = useStore((s) => s.project.viewSnapshots) ?? NO_SNAPSHOTS;
const { tabs, onActivate, onNew, onClose, autoName } = handlers;
const liveLevelId = useStore((s) => s.activeLevelId);
const liveIs3d = useStore((s) => s.viewType === "perspektive");
// [185] „Auswahl in 3D zeigen": 3D-Reiter heissen „3D · Auswahl".
const selection3d = isSelectionMode(useView3dFilter());
// 3D-Reiter heissen „3D · Geschoss" (der aktive liest die Live-Ansicht).
const title = (tab: ViewTab) =>
tabTitle(tab, snapshots, (tb) => {
const is3d = tb.id === tabs.activeId ? liveIs3d : tb.state?.viewType === "perspektive";
if (is3d && selection3d) return t("tabs.3dSelection");
return tb.id === tabs.activeId ? autoName(liveIs3d ? liveLevelId : undefined, liveIs3d) : autoName(tb.state?.activeLevelId, tb.state?.viewType === "perspektive");
});
const closable = tabs.tabs.length > 1;
return (
<div className="drawing-tabs" role="tablist" aria-label={t("tabs.drawings")}>
{tabs.tabs.map((tab) => {
const active = tab.id === tabs.activeId;
const name = title(tab);
return (
<div key={tab.id} className={`drawing-tab${active ? " active" : ""}`} data-tab-id={tab.id}>
<button
type="button"
role="tab"
aria-selected={active}
className="drawing-tab-label"
onClick={() => onActivate(tab.id)}
title={name}
>
{name}
</button>
{closable && (
<button
type="button"
className="drawing-tab-close"
aria-label={t("tabs.close", { name })}
title={t("tabs.close", { name })}
onClick={() => onClose(tab.id)}
>
×
</button>
)}
</div>
);
})}
<button
type="button"
className="drawing-tab-add"
aria-label={t("tabs.add")}
title={t("tabs.add")}
onClick={() => onNew()}
>
+
</button>
</div>
);
});