diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index c3e15ea4d2..11b2f28f6f 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -3255,7 +3255,12 @@ down | auth-failed` (plus the unchanged `missing-key`/`unsupported`) with > stacking. Narrow mobile Cockpit > viewports suppress the legacy layer stack, peripheral HUD, and secondary > Context/briefing panes so the flight instruments and primary controls remain -> unobstructed. Outside Cockpit, Radio starts collapsed while off and lives +> unobstructed. There the collapsed Display and Radio launchers form one row +> centred on the Reset/Exit axis; the default theme anchors it above the +> compass block, clear of the ground speed and altitude telemetry it used to +> cover, while Cyber keeps the row at the top. `scripts/qa-cockpit-utility.mjs` +> checks the default row's centring and clearance at 390 and 360 px. Outside +> Cockpit, Radio starts collapsed while off and lives > only in its section inside Context; the detailed panel's normal accordion > control owns its disclosure and its Enable/Disable action owns power. > Radio volume in the full and Cockpit surfaces, plus Space Mission diff --git a/scripts/qa-cockpit-utility.mjs b/scripts/qa-cockpit-utility.mjs index c5a94018fa..7b1b860723 100644 --- a/scripts/qa-cockpit-utility.mjs +++ b/scripts/qa-cockpit-utility.mjs @@ -2321,6 +2321,56 @@ try { JSON.stringify(narrowViewActions), ); + // The collapsed Display/Radio row on a phone: centred on the Reset/Exit + // axis and clear of the ground speed and altitude telemetry it once covered. + for (const [width, height] of [[390, 844], [360, 740]]) { + await page.setViewport({ width, height, deviceScaleFactor: 1 }); + const phoneRow = await page.evaluate(async () => { + const manager = window.__godsEyeView.styleManager; + manager._setCockpitDisclosure('display', false); + manager._setCockpitDisclosure('radio', false); + await new Promise(requestAnimationFrame); + manager.cockpitView.syncSignalLayout(); + await new Promise(requestAnimationFrame); + const rect = (element) => element?.getBoundingClientRect().toJSON() || null; + const launchers = [...document.querySelectorAll( + '#cockpit-utility-controls .cockpit-utility-control', + )].map(rect); + return { + launchers, + speed: rect(document.querySelector('#cockpit-hud .cockpit-speed')), + altitude: rect(document.querySelector('#cockpit-hud .cockpit-altitude')), + switcher: rect(document.getElementById('view-switcher')), + viewport: { width: innerWidth, height: innerHeight }, + // Cyber parks its row at the top; this check is the default theme's. + theme: document.documentElement.dataset.uiTheme || 'default', + }; + }); + const overlaps = (a, b) => Boolean(a && b) + && a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom; + const rowLeft = Math.min(...phoneRow.launchers.map((launcher) => launcher.left)); + const rowRight = Math.max(...phoneRow.launchers.map((launcher) => launcher.right)); + const switcherCentre = phoneRow.switcher + ? (phoneRow.switcher.left + phoneRow.switcher.right) / 2 + : NaN; + check( + `${width}px Cockpit Display/Radio row is centred and clear of the speed and altitude readouts`, + phoneRow.launchers.length === 2 + && phoneRow.launchers.every((launcher) => launcher.width > 0) + && phoneRow.theme !== 'cyber' + && phoneRow.speed?.width > 0 + && phoneRow.altitude?.width > 0 + && phoneRow.launchers.every((launcher) => ( + !overlaps(launcher, phoneRow.speed) && !overlaps(launcher, phoneRow.altitude) + )) + && Math.abs((rowLeft + rowRight) / 2 - switcherCentre) <= 2 + && rowLeft >= 0 + && rowRight <= phoneRow.viewport.width, + JSON.stringify(phoneRow), + ); + } + await page.setViewport({ width: 390, height: 844, deviceScaleFactor: 1 }); + const resetResult = await page.evaluate(() => { // Both the UI and compatibility facade delegate to this navigation owner. const manager = window.__godsEyeView.styleManager._locationNavigation; diff --git a/src/cockpitMarkup.test.mjs b/src/cockpitMarkup.test.mjs index 64d03914bd..3ce5918cb2 100644 --- a/src/cockpitMarkup.test.mjs +++ b/src/cockpitMarkup.test.mjs @@ -1137,10 +1137,16 @@ test('mobile Cockpit prioritizes flight instruments and collision-safe controls' assert.match(mobileCockpit[1], /body\.cockpit-mode #intel-hud/); assert.match(mobileCockpit[1], /body\.cockpit-mode \.cockpit-context-window/); assert.match(mobileCockpit[1], /body\.cockpit-mode \.cockpit-signal-window/); + // The collapsed Display/Radio row is centred on the Reset/Exit axis and + // anchored above the compass block, not at a fixed offset that covered the + // ground speed and altitude readouts; the compass reads the same anchor. assert.match( mobileCockpit[1], - /body\.cockpit-mode \.cockpit-utility-controls[\s\S]*?bottom:\s*152px;/, + /body\.cockpit-mode \.cockpit-utility-controls \{[\s\S]*?bottom:\s*calc\(var\(--cockpit-compass-bottom\) \+ 182px\);[\s\S]*?left:\s*12px;[\s\S]*?justify-content:\s*center;/, ); + assert.doesNotMatch(mobileCockpit[1], /bottom:\s*152px;/); + assert.match(css, /\.cockpit-compass \{[\s\S]*?bottom:\s*var\(--cockpit-compass-bottom\);/); + assert.match(css, /--cockpit-compass-bottom:\s*clamp\(44px, 7vh, 72px\);/); assert.match( mobileCockpit[1], /body\.cockpit-mode \.cockpit-utility-control\.is-expanded[\s\S]*?top:\s*96px;/, diff --git a/src/ui/styles/cockpit.css b/src/ui/styles/cockpit.css index befbfbbff4..ae9e8025b0 100644 --- a/src/ui/styles/cockpit.css +++ b/src/ui/styles/cockpit.css @@ -48,6 +48,9 @@ --cockpit-side-panel-width: min(340px, 28vw); /* HUD bottom offset + tallest scaled telemetry block + 20px clear border. */ --cockpit-bottom-rail-safe: calc(clamp(84px, 11vh, 118px) + 100px); + /* The compass block's bottom edge; the phone Display/Radio row sits above + the telemetry it carries. */ + --cockpit-compass-bottom: clamp(44px, 7vh, 72px); position: fixed; inset: 0; z-index: 145; @@ -645,7 +648,7 @@ html:not([lang='en']) .cockpit-roll-token.is-separator { .cockpit-compass { position: absolute; left: 50%; - bottom: clamp(44px, 7vh, 72px); + bottom: var(--cockpit-compass-bottom); width: min(760px, 72vw); transform: translateX(-50%) rotateX(7deg) translateZ(18px); transform-style: preserve-3d; @@ -2076,15 +2079,25 @@ body.cockpit-mode #intel-hud .hud-right-edge { body.cockpit-mode #right-context-rail { display: none !important; } + /* A centred row above the compass block: its ground speed and altitude + telemetry tops out ~171px above the block's bottom edge on phones, so + the row clears it by ~10px and stays on the same axis as RESET/EXIT. + The row spans the width to centre its launchers; only they take input. */ body.cockpit-mode .cockpit-utility-controls { top: auto; right: 12px; - bottom: 152px; - max-width: calc(100vw - 24px); + bottom: calc(var(--cockpit-compass-bottom) + 182px); + left: 12px; + justify-content: center; + max-width: none; + pointer-events: none; } body.cockpit-mode .cockpit-utility-controls { flex-direction: row; } + body.cockpit-mode .cockpit-utility-control { + pointer-events: auto; + } body.cockpit-mode .cockpit-utility-launcher { width: min(150px, calc((100vw - 31px) / 2)); min-height: 42px; diff --git a/src/ui/styles/cyber.css b/src/ui/styles/cyber.css index 4957cd7697..d7c0c174ea 100644 --- a/src/ui/styles/cyber.css +++ b/src/ui/styles/cyber.css @@ -2892,10 +2892,14 @@ max-height: min(48vh, 440px); } + /* Centred like the default theme's phone row; the desktop panel width + would otherwise pin it left of the Reset/Exit axis. */ :root[data-ui-theme='cyber'] body.cockpit-mode .cockpit-utility-controls { top: 92px !important; right: 12px; bottom: auto; + left: 12px; + width: auto; } :root[data-ui-theme='cyber']