View-Toggle: Active aus lastSetView + Stat-Box-Hoehe angeglichen
User-Feedback: 1. View-Bars sind hoeher als andere Elemente auf der Seite 2. Active-Highlight bleibt auf Top haengen — andere Views leuchten nicht 3. Glitch: Klick auf Top → Bar zeigt weiterhin Perspektive aktiv Fix 1 (Hoehe): Stat-Box Inhalts-Hoehe BAR_H*2+4 → BAR_H*2+6, der innere Trennstrich-Gap 4 → 6. Damit visual 50 → 52 = identisch mit den 2-row- Blocks (View, Preset, Massstab). Fix 2 + 3 (Active-Highlight): Backend trackt `self._last_set_view` ← gesetzt wenn handler in SET_VIEW erfolgreich war. Frontend matchView prueft zuerst `state.lastSetView === v` — kein Race-Condition zwischen ChangeProjection und Viewport-State-Lesen mehr. Fallback auf Viewport-State-Detection wenn lastSetView noch null (initial load). N/O/S/W kriegen jetzt auch Active-Highlight (vorher hartcoded false). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+22
-18
@@ -315,6 +315,7 @@ export default function OberleisteApp() {
|
||||
textSettings: { font: 'Helvetica', size: 0.20, bold: false, italic: false },
|
||||
textFonts: [],
|
||||
northAngle: 0,
|
||||
lastSetView: null,
|
||||
})
|
||||
const [appliedScale, setAppliedScale] = useState(null)
|
||||
const appliedScaleRef = useRef(null)
|
||||
@@ -373,11 +374,11 @@ export default function OberleisteApp() {
|
||||
if (appliedScale && appliedScale > 0) setMassstab(appliedScale)
|
||||
}
|
||||
|
||||
// Aktuelles View-Match. Top/Persp/Iso werden via parallel-Flag und
|
||||
// viewName unterschieden. N/O/S/W: kein zuverlaessiges View-Match
|
||||
// ueber den Viewport-Namen (wir setzen die Camera direkt) — daher
|
||||
// kein Active-State fuer Cardinals.
|
||||
// Active-Highlight aus lastSetView (vom Backend getrackt — vermeidet
|
||||
// Race-Conditions zwischen ChangeProjection und Viewport-State-Lesen).
|
||||
// Fallback wenn noch nie geklickt: Viewport-State raten.
|
||||
const matchView = (v) => {
|
||||
if (state.lastSetView) return state.lastSetView === v
|
||||
const name = (state.viewName || '').toLowerCase()
|
||||
if (v === 'Top') return name === 'top'
|
||||
if (v === 'Perspective') return state.parallel === false
|
||||
@@ -508,18 +509,21 @@ export default function OberleisteApp() {
|
||||
border: '1px solid var(--border)', borderRadius: 999,
|
||||
overflow: 'hidden', flexShrink: 0,
|
||||
}}>
|
||||
{VIEWS_ROW2.map((v, idx) => (
|
||||
<button key={v.value}
|
||||
onClick={() => setView(v.value)}
|
||||
title={`Ansicht aus ${v.value} (Norden = ${(state.northAngle || 0).toFixed(0)}°)`}
|
||||
onMouseEnter={hoverIn(false)}
|
||||
onMouseLeave={hoverOut(false)}
|
||||
style={cellStyle(false, idx === 0)}>
|
||||
<span style={{
|
||||
fontFamily: 'DM Mono, monospace', fontSize: 11, fontWeight: 600,
|
||||
}}>{v.label}</span>
|
||||
</button>
|
||||
))}
|
||||
{VIEWS_ROW2.map((v, idx) => {
|
||||
const isActive = matchView(v.value)
|
||||
return (
|
||||
<button key={v.value}
|
||||
onClick={() => setView(v.value)}
|
||||
title={`Ansicht aus ${v.value} (Norden = ${(state.northAngle || 0).toFixed(0)}°)`}
|
||||
onMouseEnter={hoverIn(isActive)}
|
||||
onMouseLeave={hoverOut(isActive)}
|
||||
style={cellStyle(isActive, idx === 0)}>
|
||||
<span style={{
|
||||
fontFamily: 'DM Mono, monospace', fontSize: 11, fontWeight: 600,
|
||||
}}>{v.label}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -702,7 +706,7 @@ export default function OberleisteApp() {
|
||||
<div style={{
|
||||
gridRow: '1 / span 2',
|
||||
display: 'flex', flexDirection: 'column',
|
||||
width: STAT_W, height: BAR_H * 2 + 4,
|
||||
width: STAT_W, height: BAR_H * 2 + 6,
|
||||
background: atScale ? 'var(--accent-dim)' : 'var(--bg-input)',
|
||||
color: atScale ? 'var(--accent-light)' : 'var(--text-primary)',
|
||||
border: '1px solid ' + (atScale ? 'var(--accent)' : 'var(--border)'),
|
||||
@@ -719,7 +723,7 @@ export default function OberleisteApp() {
|
||||
}} title={isPerspective ? 'Perspektive — kein Massstab' : 'Aktueller Live-Massstab'}>
|
||||
{isPerspective ? '—' : fmtScale(scaleVal)}
|
||||
</div>
|
||||
<div style={{ height: 4, position: 'relative' }}>
|
||||
<div style={{ height: 6, position: 'relative' }}>
|
||||
<div style={{
|
||||
position: 'absolute', left: 6, right: 6,
|
||||
top: '50%', height: 1,
|
||||
|
||||
Reference in New Issue
Block a user