mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge origin/main into fix/hal-722-radio-next-no-autoplay
main moved the Radio markup into Vue views and rebuilt the UI tests on
stores. Resolved:
- src/ui/templates/context.html: deleted in main; the new privacy note now
lives in src/ui/views/panels/RadioPanel.vue.
- src/ui/radioControls.test.mjs: main's store fixture; the Next/Previous
autoplay test drives store.act('cycleRadio').
- src/voice/gevRealtime.test.mjs: main's createTestVoiceUi; the stop and
select handoff cases stay one table-driven test.
- src/data/radioNextState.test.mjs reads the published gev-radio view.
- src/i18n/locales/ar.json: the new note translated for the Arabic locale.
This commit is contained in:
commit
a2be947aba
679 files changed
+45369
-19625
No files matched your search
+158
-307
@@ -1,9 +1,13 @@
|
||||
import { t, msg } from '../i18n/index.js';
|
||||
import {
|
||||
showRadioEnableBusy,
|
||||
showRadioTuner,
|
||||
showRadioVolume,
|
||||
} from './radioPresentation.js';
|
||||
import {
|
||||
radioTunerSlot,
|
||||
radioTunerCommitSlot,
|
||||
radioTunerPointerPosition,
|
||||
buildRadioTunerTicks,
|
||||
} from './radioTunerModel.js';
|
||||
|
||||
/** Bind Radio input using a RadioControls receiver and supplied actions. */
|
||||
@@ -19,56 +23,9 @@ export function bindRadioControls() {
|
||||
const displayOpen = kind === 'display' && Boolean(expanded);
|
||||
const radioOpen = kind === 'radio' && Boolean(expanded);
|
||||
if (displayOpen || radioOpen) this.actions.setSignalCollapsed(true);
|
||||
if (this._cockpitDisplayPanel)
|
||||
this._cockpitDisplayPanel.hidden = !displayOpen;
|
||||
if (this._cockpitRadioPanel) this._cockpitRadioPanel.hidden = !radioOpen;
|
||||
this._cockpitDisplayToggleBtn
|
||||
?.closest('.cockpit-utility-control')
|
||||
?.classList.toggle('is-expanded', displayOpen);
|
||||
this._cockpitRadioToggleBtn
|
||||
?.closest('.cockpit-utility-control')
|
||||
?.classList.toggle('is-expanded', radioOpen);
|
||||
this._cockpitDisplayToggleBtn?.setAttribute(
|
||||
'aria-expanded',
|
||||
String(displayOpen),
|
||||
);
|
||||
this._cockpitRadioToggleBtn?.setAttribute(
|
||||
'aria-expanded',
|
||||
String(radioOpen),
|
||||
);
|
||||
this._cockpitDisclosure = { display: displayOpen, radio: radioOpen };
|
||||
this.store?.publishUtility({ ...this._cockpitDisclosure });
|
||||
if (displayOpen) this.actions.revealStyleParameters();
|
||||
if (this._cockpitDisplayToggleBtn) {
|
||||
this._cockpitDisplayToggleBtn.textContent = displayOpen ? '▶' : '◀';
|
||||
this._cockpitDisplayToggleBtn.setAttribute(
|
||||
'aria-label',
|
||||
t(
|
||||
displayOpen
|
||||
? msg('Collapse Cockpit display options')
|
||||
: msg('Expand Cockpit display options'),
|
||||
),
|
||||
);
|
||||
this._cockpitDisplayToggleBtn.title = t(
|
||||
displayOpen
|
||||
? msg('Collapse Cockpit display options')
|
||||
: msg('Expand Cockpit display options'),
|
||||
);
|
||||
}
|
||||
if (this._cockpitRadioToggleBtn) {
|
||||
this._cockpitRadioToggleBtn.textContent = radioOpen ? '▶' : '◀';
|
||||
this._cockpitRadioToggleBtn.setAttribute(
|
||||
'aria-label',
|
||||
t(
|
||||
radioOpen
|
||||
? msg('Collapse Cockpit Radio controls')
|
||||
: msg('Expand Cockpit Radio controls'),
|
||||
),
|
||||
);
|
||||
this._cockpitRadioToggleBtn.title = t(
|
||||
radioOpen
|
||||
? msg('Collapse Cockpit Radio controls')
|
||||
: msg('Expand Cockpit Radio controls'),
|
||||
);
|
||||
}
|
||||
if (!expanded && returnFocus) {
|
||||
(kind === 'display'
|
||||
? this._cockpitDisplayToggleBtn
|
||||
@@ -86,39 +43,16 @@ export function bindRadioControls() {
|
||||
this.actions.layoutCockpit();
|
||||
};
|
||||
this._setCockpitDisclosure = setCockpitDisclosure;
|
||||
const syncTunerTape = (coordinate) => {
|
||||
const scale = this._radioTuner?.querySelector('.radio-tuner-scale');
|
||||
const dial = this._radioTuner?.querySelector('.radio-tuner-dial');
|
||||
if (!scale || !dial) return null;
|
||||
const model = buildRadioTunerTicks(
|
||||
coordinate,
|
||||
this._radioTunerStations.length,
|
||||
dial.getBoundingClientRect().width,
|
||||
);
|
||||
while (scale.children.length < model.ticks.length) {
|
||||
const tick = document.createElement('span');
|
||||
tick.className = 'radio-tuner-tick';
|
||||
scale.append(tick);
|
||||
}
|
||||
while (scale.children.length > model.ticks.length)
|
||||
scale.lastElementChild?.remove();
|
||||
model.ticks.forEach((entry, index) => {
|
||||
const tick = scale.children[index];
|
||||
tick.style.left = `${entry.xPx}px`;
|
||||
tick.textContent = entry.label;
|
||||
tick.dataset.stationIndex = String(entry.stationIndex);
|
||||
tick.classList.toggle('is-current', entry.current);
|
||||
});
|
||||
scale.style.setProperty('--radio-tuner-tick-pitch', `${model.pitchPx}px`);
|
||||
return model;
|
||||
};
|
||||
/** @param {'display'|'radio'} kind @returns {boolean} Whether it is open. */
|
||||
this._cockpitDisclosureOpen = (kind) =>
|
||||
Boolean(this._cockpitDisclosure?.[kind]);
|
||||
const tunerPreview = ({
|
||||
coordinate = this._radioTunerCoordinate,
|
||||
syncStatic = true,
|
||||
rotate = true,
|
||||
} = {}) => {
|
||||
const slot = radioTunerSlot(
|
||||
this._radioTunerSlider?.value,
|
||||
this._radioTunerView.slot,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
const station = slot.locked
|
||||
@@ -136,35 +70,26 @@ export function bindRadioControls() {
|
||||
? 0.5
|
||||
: resolvedCoordinate / Math.max(1, this._radioTunerStations.length - 1);
|
||||
this._radioTunerCoordinate = resolvedCoordinate;
|
||||
this._radioTuner?.style.setProperty('--radio-tuner-ratio', String(ratio));
|
||||
this._radioTuner?.classList.toggle(
|
||||
'is-static',
|
||||
syncStatic ? false : Boolean(this._radioState?.tuningStatic),
|
||||
);
|
||||
syncTunerTape(resolvedCoordinate);
|
||||
if (this._radioTunerValue) {
|
||||
this._radioTunerValue.textContent = station
|
||||
showRadioTuner.call(this, {
|
||||
ratio,
|
||||
static: syncStatic ? false : Boolean(this._radioState?.tuningStatic),
|
||||
coordinate: resolvedCoordinate,
|
||||
count: this._radioTunerStations.length,
|
||||
value: station
|
||||
? t('CH {index} / {total}', {
|
||||
index: String(slot.stationIndex + 1).padStart(2, '0'),
|
||||
total: String(this._radioTunerStations.length).padStart(2, '0'),
|
||||
})
|
||||
: t('NO STATIONS');
|
||||
}
|
||||
if (this._radioTunerStation)
|
||||
this._radioTunerStation.textContent =
|
||||
station?.name || t('NO STATION AVAILABLE');
|
||||
if (this._radioTunerSlider) {
|
||||
this._radioTunerSlider.setAttribute(
|
||||
'aria-valuetext',
|
||||
station
|
||||
? t('{name}, station {index} of {total}', {
|
||||
name: station.name,
|
||||
index: slot.stationIndex + 1,
|
||||
total: this._radioTunerStations.length,
|
||||
})
|
||||
: t('No station available'),
|
||||
);
|
||||
}
|
||||
: t('NO STATIONS'),
|
||||
station: station?.name || t('NO STATION AVAILABLE'),
|
||||
valuetext: station
|
||||
? t('{name}, station {index} of {total}', {
|
||||
name: station.name,
|
||||
index: slot.stationIndex + 1,
|
||||
total: this._radioTunerStations.length,
|
||||
})
|
||||
: t('No station available'),
|
||||
});
|
||||
if (syncStatic)
|
||||
this.radio.previewTuningStation(station?.id || null, { rotate });
|
||||
return station;
|
||||
@@ -175,20 +100,12 @@ export function bindRadioControls() {
|
||||
this._radioTunerBandSignature = this._radioTunerStations
|
||||
.map((station) => station.id)
|
||||
.join('|');
|
||||
if (this._radioTunerSlider) {
|
||||
this._radioTunerSlider.min = '0';
|
||||
this._radioTunerSlider.max = String(
|
||||
Math.max(0, this._radioTunerStations.length - 1),
|
||||
);
|
||||
this._radioTunerSlider.step = '1';
|
||||
}
|
||||
showRadioTuner.call(this, {
|
||||
max: Math.max(0, this._radioTunerStations.length - 1),
|
||||
});
|
||||
};
|
||||
const refreshTunerBand = ({ force = false } = {}) => {
|
||||
if (
|
||||
this._radioTunerDragging ||
|
||||
this._radioTuner?.hidden ||
|
||||
this._radioTunerSlider?.disabled
|
||||
)
|
||||
if (this._radioTunerDragging || !this._radioTunerView.available)
|
||||
return false;
|
||||
const selectedId = this._radioState?.selected?.id || null;
|
||||
const pool = this.radio.getTunerStations(750);
|
||||
@@ -211,14 +128,16 @@ export function bindRadioControls() {
|
||||
selectedPoolIndex >= 0 ? selectedPoolIndex : 0,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
this._radioTunerSlider.value = String(slot.slot);
|
||||
showRadioTuner.call(this, { slot: slot.slot });
|
||||
this._radioTunerCoordinate = slot.stationIndex >= 0 ? slot.stationIndex : 0;
|
||||
tunerPreview({ coordinate: this._radioTunerCoordinate, syncStatic: false });
|
||||
return true;
|
||||
};
|
||||
this._refreshRadioTunerBand = refreshTunerBand;
|
||||
this._refreshRadioTunerText = () =>
|
||||
tunerPreview({ coordinate: this._radioTunerCoordinate, syncStatic: false });
|
||||
const beginTuner = () => {
|
||||
if (this._radioTunerDragging || this._radioTunerSlider?.disabled)
|
||||
if (this._radioTunerDragging || !this._radioTunerView.available)
|
||||
return false;
|
||||
refreshTunerBand();
|
||||
if (!this._radioTunerStations.length || !this.radio.beginTuning())
|
||||
@@ -227,7 +146,7 @@ export function bindRadioControls() {
|
||||
// Only an explicit globe pointer/wheel gesture releases camera pinning.
|
||||
this._radioTunerBandPinnedForNavigation = true;
|
||||
this._radioTunerDragging = true;
|
||||
this._radioTuner?.classList.add('is-dragging');
|
||||
showRadioTuner.call(this, { dragging: true });
|
||||
const selectedIndex = this._radioTunerStations.findIndex(
|
||||
(station) => station.id === this._radioState?.selected?.id,
|
||||
);
|
||||
@@ -235,7 +154,7 @@ export function bindRadioControls() {
|
||||
selectedIndex >= 0 ? selectedIndex : 0,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
this._radioTunerSlider.value = String(slot.slot);
|
||||
showRadioTuner.call(this, { slot: slot.slot });
|
||||
this._radioTunerCoordinate = slot.stationIndex >= 0 ? slot.stationIndex : 0;
|
||||
this._radioTunerDragStartSlot = slot.slot;
|
||||
this._radioTunerDragSnapshot = {
|
||||
@@ -258,31 +177,28 @@ export function bindRadioControls() {
|
||||
this._radioTunerPool = [...dragSnapshot.stations];
|
||||
this._radioTunerBandSignature = dragSnapshot.bandSignature;
|
||||
this._radioTunerSelectedId = dragSnapshot.selectedId;
|
||||
if (this._radioTunerSlider) {
|
||||
const startSlot = radioTunerSlot(
|
||||
dragSnapshot.slot,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
this._radioTunerSlider.max = String(startSlot.max);
|
||||
this._radioTunerSlider.value = String(startSlot.slot);
|
||||
}
|
||||
const startSlot = radioTunerSlot(
|
||||
dragSnapshot.slot,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
showRadioTuner.call(this, { max: startSlot.max, slot: startSlot.slot });
|
||||
this._radioTunerCoordinate = Number.isFinite(dragSnapshot.coordinate)
|
||||
? dragSnapshot.coordinate
|
||||
: dragSnapshot.slot;
|
||||
} else if (!commit && this._radioTunerSlider) {
|
||||
this._radioTunerSlider.value = String(this._radioTunerDragStartSlot);
|
||||
} else if (!commit) {
|
||||
showRadioTuner.call(this, { slot: this._radioTunerDragStartSlot });
|
||||
this._radioTunerCoordinate = this._radioTunerDragStartSlot;
|
||||
}
|
||||
let station = tunerPreview({
|
||||
coordinate: this._radioTunerCoordinate,
|
||||
rotate: commit,
|
||||
});
|
||||
if (commit && !station && this._radioTunerSlider) {
|
||||
if (commit && !station) {
|
||||
const snapped = radioTunerCommitSlot(
|
||||
this._radioTunerSlider.value,
|
||||
this._radioTunerView.slot,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
this._radioTunerSlider.value = String(snapped.slot);
|
||||
showRadioTuner.call(this, { slot: snapped.slot });
|
||||
this._radioTunerCoordinate = snapped.stationIndex;
|
||||
station = tunerPreview({ coordinate: this._radioTunerCoordinate });
|
||||
}
|
||||
@@ -305,21 +221,18 @@ export function bindRadioControls() {
|
||||
this._radioTunerKeyboardKey = null;
|
||||
if (commit && (!result || result.ok)) refreshTunerBand();
|
||||
this._radioTunerDragSnapshot = null;
|
||||
// Flush the snapped position while transitions are still disabled so
|
||||
// removing the drag class cannot interpolate from the released gap.
|
||||
void this._radioTunerNeedle?.offsetLeft;
|
||||
this._radioTuner?.classList.remove('is-dragging');
|
||||
// The tuner lays out the snapped position while transitions are still
|
||||
// disabled before it drops the drag class, so the needle cannot
|
||||
// interpolate from the released gap.
|
||||
showRadioTuner.call(this, { dragging: false });
|
||||
if (result && !result.ok) {
|
||||
this._radioTunerBandPinnedForNavigation = false;
|
||||
if (result.reason === 'station-unavailable') {
|
||||
if (this._radioTunerValue)
|
||||
this._radioTunerValue.textContent = t('OFF AIR');
|
||||
if (this._radioTunerStation)
|
||||
this._radioTunerStation.textContent = t('STATION UNAVAILABLE');
|
||||
this._radioTunerSlider?.setAttribute(
|
||||
'aria-valuetext',
|
||||
t('Station unavailable after directory refresh'),
|
||||
);
|
||||
showRadioTuner.call(this, {
|
||||
value: t('OFF AIR'),
|
||||
station: t('STATION UNAVAILABLE'),
|
||||
valuetext: t('Station unavailable after directory refresh'),
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -341,13 +254,30 @@ export function bindRadioControls() {
|
||||
return;
|
||||
}
|
||||
};
|
||||
// Both Enable buttons render from the Radio store; before its first render
|
||||
// there is nothing shown to mark, so the button is marked directly.
|
||||
const setTriggerBusy = (trigger, busy) => {
|
||||
const where =
|
||||
trigger === this._radioEnableBtn
|
||||
? 'panel'
|
||||
: trigger === this._cockpitRadioEnableBtn
|
||||
? 'cockpit'
|
||||
: null;
|
||||
if (where && showRadioEnableBusy.call(this, busy, where)) return;
|
||||
trigger.setAttribute('aria-disabled', String(busy));
|
||||
trigger.setAttribute('aria-busy', String(busy));
|
||||
};
|
||||
// The store patches aria-busy on the next render, so a second press before
|
||||
// it lands is turned away by this set.
|
||||
const busyTriggers = new Set();
|
||||
const toggleRadio = async (trigger) => {
|
||||
if (!this.actions.isRegistered()) return;
|
||||
if (busyTriggers.has(trigger)) return;
|
||||
if (trigger.getAttribute('aria-busy') === 'true') return;
|
||||
const enabling = !this.actions.isEnabled();
|
||||
const revealAfterEnable = enabling && trigger === this._radioEnableBtn;
|
||||
trigger.setAttribute('aria-disabled', 'true');
|
||||
trigger.setAttribute('aria-busy', 'true');
|
||||
busyTriggers.add(trigger);
|
||||
setTriggerBusy(trigger, true);
|
||||
try {
|
||||
const toggled = await this.actions.runUserAction(
|
||||
(notificationToken) =>
|
||||
@@ -379,29 +309,14 @@ export function bindRadioControls() {
|
||||
if (revealAfterEnable)
|
||||
await this._revealRadioControlsAfterExplicitEnable(trigger);
|
||||
} finally {
|
||||
busyTriggers.delete(trigger);
|
||||
if (!this.destroyed) {
|
||||
trigger.setAttribute('aria-disabled', 'false');
|
||||
trigger.setAttribute('aria-busy', 'false');
|
||||
setTriggerBusy(trigger, false);
|
||||
if (revealAfterEnable && trigger.isConnected)
|
||||
trigger.focus({ preventScroll: true });
|
||||
}
|
||||
}
|
||||
};
|
||||
this.listen(
|
||||
this._radioEnableBtn,
|
||||
'click',
|
||||
() => void toggleRadio(this._radioEnableBtn),
|
||||
);
|
||||
this.listen(
|
||||
this._cockpitRadioEnableBtn,
|
||||
'click',
|
||||
() => void toggleRadio(this._cockpitRadioEnableBtn),
|
||||
);
|
||||
this.listen(this._cockpitRadioToggleBtn, 'click', () => {
|
||||
const open =
|
||||
this._cockpitRadioToggleBtn.getAttribute('aria-expanded') === 'true';
|
||||
setCockpitDisclosure('radio', !open);
|
||||
});
|
||||
this.listen(
|
||||
document,
|
||||
'pointerdown',
|
||||
@@ -424,10 +339,8 @@ export function bindRadioControls() {
|
||||
'keydown',
|
||||
(event) => {
|
||||
if (event.key !== 'Escape') return;
|
||||
const displayOpen =
|
||||
this._cockpitDisplayToggleBtn?.getAttribute('aria-expanded') === 'true';
|
||||
const radioOpen =
|
||||
this._cockpitRadioToggleBtn?.getAttribute('aria-expanded') === 'true';
|
||||
const displayOpen = this._cockpitDisclosureOpen('display');
|
||||
const radioOpen = this._cockpitDisclosureOpen('radio');
|
||||
if (!displayOpen && !radioOpen) return;
|
||||
const nestedPanel = event.target?.closest?.(
|
||||
'.panel-collapsible:not(.collapsed), #param-slider-panel:not(.collapsed)',
|
||||
@@ -474,64 +387,6 @@ export function bindRadioControls() {
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(this._radioFilter, 'change', () => {
|
||||
const presentation = this.radio.getUIState();
|
||||
if (!presentation.presentationActive) {
|
||||
this._radioFilter.value = presentation.filter;
|
||||
return;
|
||||
}
|
||||
if (this._radioTunerDragging) finishTuner(false);
|
||||
if (
|
||||
!this.actions.setParams(
|
||||
{
|
||||
filter: this._radioFilter.value,
|
||||
},
|
||||
{ origin: 'user' },
|
||||
)
|
||||
) {
|
||||
this._radioFilter.value = this.radio.getUIState().filter;
|
||||
return;
|
||||
}
|
||||
this._radioTunerBandPinnedForNavigation = false;
|
||||
this._radioTunerPool = [];
|
||||
refreshTunerBand({ force: true });
|
||||
});
|
||||
this.listen(this._radioPrevBtn, 'click', () => cycleRadio(-1));
|
||||
this.listen(this._radioNextBtn, 'click', () => cycleRadio(1));
|
||||
this.listen(
|
||||
this._radioPlayBtn,
|
||||
'click',
|
||||
() => void this.radio.togglePlayback({ origin: 'user' }),
|
||||
);
|
||||
this.listen(this._radioStopBtn, 'click', () =>
|
||||
this.radio.stopPlayback({ origin: 'user' }),
|
||||
);
|
||||
this.listen(this._radioVolume, 'input', () => {
|
||||
const value = Number(this._radioVolume.value);
|
||||
if (this._radioVolumeValue)
|
||||
this._radioVolumeValue.textContent = `${value}%`;
|
||||
this.actions.setParams({ volume: value / 100 }, { origin: 'user' });
|
||||
});
|
||||
// Cockpit owns the Cesium camera even though it intentionally clears
|
||||
// viewer.trackedEntity. Station changes must never start the map-view
|
||||
// rotation/fallback flights that would compete with its preUpdate pose.
|
||||
this.listen(this._cockpitRadioPrevBtn, 'click', () =>
|
||||
cycleRadio(-1, { rotate: false }),
|
||||
);
|
||||
this.listen(this._cockpitRadioNextBtn, 'click', () =>
|
||||
cycleRadio(1, { rotate: false }),
|
||||
);
|
||||
this.listen(
|
||||
this._cockpitRadioPlayBtn,
|
||||
'click',
|
||||
() => void this.radio.togglePlayback({ origin: 'user' }),
|
||||
);
|
||||
this.listen(this._cockpitRadioVolume, 'input', () => {
|
||||
const value = Number(this._cockpitRadioVolume.value);
|
||||
if (this._cockpitRadioVolumeValue)
|
||||
this._cockpitRadioVolumeValue.textContent = `${value}%`;
|
||||
this.actions.setParams({ volume: value / 100 }, { origin: 'user' });
|
||||
});
|
||||
const updateTunerFromPointer = (event) => {
|
||||
const rect = this._radioTunerSlider?.getBoundingClientRect();
|
||||
if (!rect || !this._radioTunerStations.length) return false;
|
||||
@@ -547,14 +402,71 @@ export function bindRadioControls() {
|
||||
this._radioTunerDragDirection = -1;
|
||||
this._radioTunerLastSlot = position.stationIndex;
|
||||
this._radioTunerCoordinate = position.coordinate;
|
||||
this._radioTunerSlider.value = String(position.stationIndex);
|
||||
showRadioTuner.call(this, { slot: position.stationIndex });
|
||||
tunerPreview({ coordinate: position.coordinate });
|
||||
return true;
|
||||
};
|
||||
const releaseNavigationBand = () => {
|
||||
this._radioTunerBandPinnedForNavigation = false;
|
||||
};
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
this.canvas,
|
||||
'pointerdown',
|
||||
(event) => {
|
||||
releaseNavigationBand,
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this.canvas,
|
||||
'wheel',
|
||||
releaseNavigationBand,
|
||||
tunerListenerOptions,
|
||||
);
|
||||
// The directory order is catalog/filter authority, not camera authority.
|
||||
// Globe motion therefore never rebuilds or re-ranks the frequency band.
|
||||
this._radioSelectedHandler = () =>
|
||||
this.actions.setPanelCollapsed('radio-panel', false);
|
||||
this.listen(document, 'gev:radio-selected', this._radioSelectedHandler);
|
||||
// The Radio panel's and Cockpit's controls, and the tuner slider's events,
|
||||
// call these through the store.
|
||||
// Cockpit owns the Cesium camera even though it intentionally clears
|
||||
// viewer.trackedEntity, so its station steps pass `rotate: false`: they
|
||||
// must never start the map-view rotation/fallback flights that would
|
||||
// compete with its preUpdate pose.
|
||||
this._storeToken = this.store?.connect?.({
|
||||
/** @param {'panel'|'cockpit'} where Which Enable button was pressed. */
|
||||
toggleRadio: (where) =>
|
||||
void toggleRadio(
|
||||
where === 'cockpit'
|
||||
? this._cockpitRadioEnableBtn
|
||||
: this._radioEnableBtn,
|
||||
),
|
||||
toggleCockpitRadio: () =>
|
||||
setCockpitDisclosure('radio', !this._cockpitDisclosureOpen('radio')),
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @returns {string} The station tag the filter shows afterwards.
|
||||
*/
|
||||
setRadioFilter: (filter) => {
|
||||
if (!this.radio.getUIState().presentationActive)
|
||||
return this.radio.getUIState().filter;
|
||||
if (this._radioTunerDragging) finishTuner(false);
|
||||
if (!this.actions.setParams({ filter }, { origin: 'user' }))
|
||||
return this.radio.getUIState().filter;
|
||||
this._radioTunerBandPinnedForNavigation = false;
|
||||
this._radioTunerPool = [];
|
||||
refreshTunerBand({ force: true });
|
||||
return filter;
|
||||
},
|
||||
cycleRadio,
|
||||
toggleRadioPlayback: () =>
|
||||
void this.radio.togglePlayback({ origin: 'user' }),
|
||||
stopRadio: () => this.radio.stopPlayback({ origin: 'user' }),
|
||||
setRadioVolume: (percent) => {
|
||||
const value = Number(percent);
|
||||
showRadioVolume.call(this, value);
|
||||
this.actions.setParams({ volume: value / 100 }, { origin: 'user' });
|
||||
},
|
||||
tunerPointerDown: (event) => {
|
||||
if (!beginTuner()) return;
|
||||
this._radioTunerPointerId = event.pointerId;
|
||||
this._radioTunerSlider.focus({ preventScroll: true });
|
||||
@@ -566,12 +478,7 @@ export function bindRadioControls() {
|
||||
updateTunerFromPointer(event);
|
||||
event.preventDefault();
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'pointermove',
|
||||
(event) => {
|
||||
tunerPointerMove: (event) => {
|
||||
if (
|
||||
!this._radioTunerDragging ||
|
||||
this._radioTunerPointerId !== event.pointerId
|
||||
@@ -580,17 +487,17 @@ export function bindRadioControls() {
|
||||
updateTunerFromPointer(event);
|
||||
event.preventDefault();
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'input',
|
||||
() => {
|
||||
tunerInput: () => {
|
||||
if (this._radioTunerPointerId !== null || this._radioTunerKeyboardKey)
|
||||
return;
|
||||
if (!this._radioTunerDragging && !beginTuner()) return;
|
||||
// A drag the input starts begins from the selected station's slot.
|
||||
if (this._radioTunerDragging)
|
||||
showRadioTuner.call(this, {
|
||||
slot: Number(this._radioTunerSlider.value),
|
||||
});
|
||||
else if (!beginTuner()) return;
|
||||
const inputSlot = radioTunerSlot(
|
||||
this._radioTunerSlider.value,
|
||||
this._radioTunerView.slot,
|
||||
this._radioTunerStations.length,
|
||||
);
|
||||
if (inputSlot.slot > this._radioTunerLastSlot)
|
||||
@@ -601,21 +508,11 @@ export function bindRadioControls() {
|
||||
this._radioTunerCoordinate = inputSlot.stationIndex;
|
||||
tunerPreview({ coordinate: this._radioTunerCoordinate });
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'change',
|
||||
() => {
|
||||
tunerChange: () => {
|
||||
if (this._radioTunerPointerId === null && !this._radioTunerKeyboardKey)
|
||||
finishTuner(true);
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'pointerup',
|
||||
(event) => {
|
||||
tunerPointerUp: (event) => {
|
||||
if (this._radioTunerPointerId !== event.pointerId) return;
|
||||
updateTunerFromPointer(event);
|
||||
finishTuner(true);
|
||||
@@ -626,12 +523,7 @@ export function bindRadioControls() {
|
||||
}
|
||||
event.preventDefault();
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'pointercancel',
|
||||
(event) => {
|
||||
tunerPointerCancel: (event) => {
|
||||
if (
|
||||
this._radioTunerPointerId !== null &&
|
||||
this._radioTunerPointerId !== event.pointerId
|
||||
@@ -644,24 +536,14 @@ export function bindRadioControls() {
|
||||
}
|
||||
finishTuner(false);
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'lostpointercapture',
|
||||
(event) => {
|
||||
tunerLostPointerCapture: (event) => {
|
||||
if (
|
||||
this._radioTunerDragging &&
|
||||
this._radioTunerPointerId === event.pointerId
|
||||
)
|
||||
finishTuner(false);
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'keydown',
|
||||
(event) => {
|
||||
tunerKeyDown: (event) => {
|
||||
if (event.key === 'Escape' && this._radioTunerDragging) {
|
||||
event.preventDefault();
|
||||
finishTuner(false);
|
||||
@@ -683,7 +565,7 @@ export function bindRadioControls() {
|
||||
this._radioTunerKeyboardKey = event.key;
|
||||
const max = Math.max(0, this._radioTunerStations.length - 1);
|
||||
const current = radioTunerSlot(
|
||||
this._radioTunerSlider.value,
|
||||
this._radioTunerView.slot,
|
||||
this._radioTunerStations.length,
|
||||
).slot;
|
||||
const page = Math.max(1, Math.round(max / 10));
|
||||
@@ -704,15 +586,10 @@ export function bindRadioControls() {
|
||||
this._radioTunerDragDirection = -1;
|
||||
this._radioTunerLastSlot = slot.slot;
|
||||
this._radioTunerCoordinate = slot.stationIndex;
|
||||
this._radioTunerSlider.value = String(slot.slot);
|
||||
showRadioTuner.call(this, { slot: slot.slot });
|
||||
tunerPreview({ coordinate: this._radioTunerCoordinate });
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'keyup',
|
||||
(event) => {
|
||||
tunerKeyUp: (event) => {
|
||||
if (
|
||||
!this._radioTunerKeyboardKey ||
|
||||
event.key !== this._radioTunerKeyboardKey
|
||||
@@ -721,32 +598,6 @@ export function bindRadioControls() {
|
||||
event.preventDefault();
|
||||
finishTuner(true);
|
||||
},
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this._radioTunerSlider,
|
||||
'blur',
|
||||
() => finishTuner(true),
|
||||
tunerListenerOptions,
|
||||
);
|
||||
const releaseNavigationBand = () => {
|
||||
this._radioTunerBandPinnedForNavigation = false;
|
||||
};
|
||||
this.listen(
|
||||
this.canvas,
|
||||
'pointerdown',
|
||||
releaseNavigationBand,
|
||||
tunerListenerOptions,
|
||||
);
|
||||
this.listen(
|
||||
this.canvas,
|
||||
'wheel',
|
||||
releaseNavigationBand,
|
||||
tunerListenerOptions,
|
||||
);
|
||||
// The directory order is catalog/filter authority, not camera authority.
|
||||
// Globe motion therefore never rebuilds or re-ranks the frequency band.
|
||||
this._radioSelectedHandler = () =>
|
||||
this.actions.setPanelCollapsed('radio-panel', false);
|
||||
this.listen(document, 'gev:radio-selected', this._radioSelectedHandler);
|
||||
tunerBlur: () => finishTuner(true),
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user