mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
Commit the shown CCTV camera with FOCUS, not a hidden picker option
The picker no longer keeps a hidden, disabled copy of the opening camera. That copy could be re-picked with ArrowDown on a closed list, could show twice in the iOS picker, and left Firefox without an accessible value. The list now selects the camera's own option, as before. A native list sends no change for the option it already shows, so FOCUS (or NEAREST, when that camera is the nearest) keeps the shown camera. Closing the list without a choice keeps automatic selection.
This commit is contained in:
1 parent
a6eecee157
commit
09588b98bf
13 files changed
+56
-105
No files matched your search
@@ -1,5 +1,5 @@
|
||||
- Keep the CCTV camera picked with NEAREST, from the camera list or by a scene
|
||||
when it is the camera the view just moved to. The pick did not stick:
|
||||
- Keep the CCTV camera picked with NEAREST, FOCUS or by a scene when it is
|
||||
the camera CCTV switched to after the view moved. The pick did not stick:
|
||||
NEAREST's own flight, or the next pan, switched to another camera, so the
|
||||
panel showed a camera nobody had picked. Choosing the camera the list already
|
||||
shows now counts as a pick too (gekh, #1702).
|
||||
panel showed a camera nobody had picked. To keep the camera the list
|
||||
already shows, press FOCUS (gekh, #1702).
|
||||
@@ -2003,14 +2003,15 @@ count of cameras outside the view.
|
||||
Turning CCTV on opens on the camera nearest the view. Until someone picks a
|
||||
camera, each settled move, such as a shared view's flight landing, moves it to
|
||||
the camera then nearest the view. Automatic selection ends at the first pick:
|
||||
NEAREST, PREV or NEXT, a camera chosen in the picker, a click on a camera, a
|
||||
click on empty ground that deselects, an auto-hop step, or a call to
|
||||
NEAREST, PREV or NEXT, FOCUS, a camera chosen in the picker, a click on a
|
||||
camera, a click on empty ground that deselects, an auto-hop step, or a call to
|
||||
`selectCamera`, `focusNearest`, `focusNearestToPoint` or
|
||||
`setParams({ selectedCameraId })`, which voice and scenes use. Picking the
|
||||
camera that is already active counts. While the camera is the automatic one,
|
||||
the picker shows it from a hidden first option, so choosing that camera from
|
||||
the list is a change and ends automatic selection; closing the list without a
|
||||
choice keeps it.
|
||||
camera that is already active counts. The picker shows the automatic camera
|
||||
as its own option, and a native list sends no change for the option it
|
||||
already shows, so the list cannot pick that camera: FOCUS does, and so does
|
||||
NEAREST when that camera is the nearest. Closing the list without a choice
|
||||
keeps automatic selection.
|
||||
|
||||
Traffic owns its rendered-surface observer only while enabled, removes it on disable/destroy, and rebuilds no cached heights on frames where the surface identity is unchanged. Its dots and heat-lines are two renderer draw sets, it animates on the frame port's preRender, and it follows the camera through the camera port at its own 5% threshold rather than the shared `percentageChanged` ledger. The surface identity is the globe port's `surfaceVersion()` and tile readiness its `isSettled('surface')`, so the layer no longer reaches Cesium. Heat-lines are always asked for draped: where the Cesium renderer cannot drape (no depth textures) its draw port draws them (and every other draped line) over the surface, in their colour where the surface hides them and hidden past the horizon, recolouring a line in place when only its colour changes, rather than the layer dropping them.
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ function withReopenedLayer(fn) {
|
||||
moveViewer(viewer, 51.5131, -0.1291);
|
||||
assert.equal(reopenNearestCamera(), true);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, true);
|
||||
fn(viewer);
|
||||
} finally {
|
||||
globalThis.document = originalDocument;
|
||||
@@ -121,7 +120,6 @@ for (const [name, pick] of [
|
||||
withReopenedLayer((viewer) => {
|
||||
pick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, false);
|
||||
// A later settled move (a pan, or the landing of the pick's own flight)
|
||||
// leaves the explicit choice alone.
|
||||
moveViewer(viewer, 51.5081, -0.1281);
|
||||
@@ -130,3 +128,11 @@ for (const [name, pick] of [
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test('without a pick, the next settled move still follows the view', () => {
|
||||
withReopenedLayer((viewer) => {
|
||||
moveViewer(viewer, 51.5081, -0.1281);
|
||||
assert.equal(reopenNearestCamera(), true);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'a-trafalgar');
|
||||
});
|
||||
});
|
||||
@@ -73,7 +73,7 @@ export function createNavigation({
|
||||
return false;
|
||||
const nearest = nearestCameraIdToViewer();
|
||||
if (!nearest || nearest === layerState._activeCameraId) return false;
|
||||
// Still the opening pick: its notification tells the picker so.
|
||||
// Still the opening pick: later settled moves may replace it.
|
||||
parts.selection.setActiveCamera(nearest, { opening: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -286,10 +286,6 @@ export function createPresentation({
|
||||
hoverId: layerState._hoverCardId,
|
||||
},
|
||||
activeCameraId: activeId,
|
||||
// The camera CCTV opened on, following the view until someone picks one.
|
||||
activeCameraProvisional: Boolean(
|
||||
activeId && layerState._openingCameraProvisional,
|
||||
),
|
||||
activeCameraReselection: layerState._activeCameraReselection,
|
||||
activeCamera: active ? getPublicCameraState(active, activeId) : null,
|
||||
cameraIndex: cameraIndex(),
|
||||
|
||||
@@ -73,17 +73,14 @@ export function createSelection({
|
||||
record,
|
||||
)
|
||||
) {
|
||||
// Picking the camera a settled move re-opened is still a choice: later
|
||||
// settled moves must leave it alone, and the picker learns it.
|
||||
const endsOpening = layerState._openingCameraProvisional && !opening;
|
||||
if (endsOpening) layerState._openingCameraProvisional = false;
|
||||
// Picking the camera a settled move re-opened is still a pick: later
|
||||
// settled moves must leave it alone.
|
||||
if (!opening) layerState._openingCameraProvisional = false;
|
||||
// Browser-only feeds have a separate player; a reselect retries it
|
||||
// without re-running activation or touching the projection geometry.
|
||||
if (parts.model.isBrowserOverlayCamera(record.camera)) {
|
||||
layerState._activeCameraReselection += 1;
|
||||
parts.presentation.notifyListeners();
|
||||
} else if (endsOpening) {
|
||||
parts.presentation.notifyListeners();
|
||||
}
|
||||
return CCTV_ACTIVATION_RESULT.UNCHANGED;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ test('same-camera selection notifies browser-overlay feeds so playback can retry
|
||||
assert.equal(fixture.notifications(), 1);
|
||||
});
|
||||
|
||||
test('same-camera selection ends the opening pick and tells the panel once', () => {
|
||||
test('same-camera selection ends the opening pick without notifying snapshot feeds', () => {
|
||||
const fixture = makeSelection('tripcheck-odot');
|
||||
fixture.state._openingCameraProvisional = true;
|
||||
|
||||
@@ -63,5 +63,5 @@ test('same-camera selection ends the opening pick and tells the panel once', ()
|
||||
);
|
||||
assert.equal(fixture.state._openingCameraProvisional, false);
|
||||
assert.equal(fixture.state._activeCameraReselection, 0);
|
||||
assert.equal(fixture.notifications(), 1);
|
||||
assert.equal(fixture.notifications(), 0);
|
||||
});
|
||||
@@ -105,6 +105,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
||||
} = {}) {
|
||||
layerState._viewer = viewer;
|
||||
layerState._records = Array.isArray(records) ? records : [];
|
||||
layerState._count = layerState._records.length;
|
||||
layerState._recordById = new Map(
|
||||
layerState._records
|
||||
.filter((record) => record?.camera?.id)
|
||||
|
||||
@@ -5,9 +5,7 @@ import { useCctvStore } from '../stores/cctv.js';
|
||||
|
||||
// The camera picker: the cameras in view and a closing note for those the
|
||||
// view leaves out. It renders only when CctvControls publishes a picker,
|
||||
// which re-applies the active camera, as on every layer notification. The
|
||||
// opening camera, which follows the view until someone picks one, shows in a
|
||||
// hidden first option: choosing that camera from the list is a change.
|
||||
// which re-applies the active camera, as on every layer notification.
|
||||
const { picker } = storeToRefs(useCctvStore());
|
||||
|
||||
// The selection, applied once the options are in place.
|
||||
@@ -23,13 +21,6 @@ const vPick = { mounted: pick, updated: pick };
|
||||
|
||||
<template>
|
||||
<UiSelect v-pick="picker?.selection" :disabled="picker?.disabled"
|
||||
><option
|
||||
v-if="picker?.opening"
|
||||
value=""
|
||||
hidden
|
||||
disabled
|
||||
data-cctv-opening
|
||||
>{{ picker.opening }}</option
|
||||
><option
|
||||
v-for="option in picker?.options"
|
||||
:key="option.value"
|
||||
|
||||
@@ -226,27 +226,3 @@ test('an active id without its camera record leaves the pick alone', async (t) =
|
||||
});
|
||||
assert.equal(select.value, 'b');
|
||||
});
|
||||
|
||||
test('the opening camera shows in a hidden first option', async (t) => {
|
||||
const { select, render, values } = fixture(t);
|
||||
const [a, b] = [camera('a'), camera('b')];
|
||||
const state = {
|
||||
enabled: true,
|
||||
count: 2,
|
||||
cameraIndex: [b, a],
|
||||
activeCameraId: 'b',
|
||||
activeCamera: b,
|
||||
};
|
||||
await render({ ...state, activeCameraProvisional: true });
|
||||
assert.deepEqual(values(), ['', 'b', 'a']);
|
||||
assert.equal(select.selectedIndex, 0);
|
||||
const opening = select.options[0];
|
||||
assert.equal(opening.textContent, 'Austin · Cam b');
|
||||
assert.equal(opening.hidden, true);
|
||||
assert.equal(opening.disabled, true);
|
||||
assert.equal(opening.dataset.cctvOpening, '');
|
||||
|
||||
await render(state);
|
||||
assert.deepEqual(values(), ['b', 'a'], 'a picked camera has no hidden option');
|
||||
assert.equal(select.value, 'b');
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
// src/ui/cctvPickerOpening.test.mjs — the picker can pick the opening camera.
|
||||
// The opening camera follows the view until someone picks one. A native
|
||||
// select fires no change for the option it already shows, so the picker keeps
|
||||
// that camera in a hidden first option: choosing it from the list is a change
|
||||
// and ends the opening pick, while closing the list leaves it.
|
||||
// src/ui/cctvPickerOpening.test.mjs — the picker and the opening camera.
|
||||
// The opening camera follows the view until someone picks one. The picker
|
||||
// shows it as its own option; a native select fires no change for the
|
||||
// option it already shows, so FOCUS keeps that camera, and leaving the list
|
||||
// without a choice lets it follow the view.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
@@ -122,6 +122,7 @@ async function reopenedAtCambridge(t) {
|
||||
elements: {
|
||||
_cctvPanel: document.getElementById('cctv-panel'),
|
||||
_cctvSelect: select,
|
||||
_cctvFocusBtn: document.getElementById('cctv-focus-btn'),
|
||||
},
|
||||
cctv: cctvLayer,
|
||||
actions: {
|
||||
@@ -154,52 +155,43 @@ async function reopenedAtCambridge(t) {
|
||||
return { viewer, select };
|
||||
}
|
||||
|
||||
/** The label of the opening camera's hidden option, or null. */
|
||||
function openingLabel(select) {
|
||||
return (
|
||||
select.querySelector('option[data-cctv-opening]')?.textContent ?? null
|
||||
);
|
||||
}
|
||||
|
||||
test('the opening camera shows as itself, from a hidden option', async (t) => {
|
||||
test('the opening camera shows as its own option', async (t) => {
|
||||
const { select } = await reopenedAtCambridge(t);
|
||||
assert.equal(openingLabel(select), 'London · Camera b-cambridge');
|
||||
assert.equal(select.selectedIndex, 0, 'the closed picker shows it');
|
||||
const opening = select.options[0];
|
||||
assert.equal(opening.dataset.cctvOpening, '');
|
||||
assert.equal(opening.hidden, true, 'the open list does not show it twice');
|
||||
assert.equal(opening.disabled, true);
|
||||
assert.ok(
|
||||
[...select.options].some((option) => option.value === 'b-cambridge'),
|
||||
'the camera itself stays in the list to be picked',
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
const shown = select.options[select.selectedIndex];
|
||||
assert.equal(shown.hidden, false);
|
||||
assert.equal(shown.disabled, false);
|
||||
assert.equal(
|
||||
[...select.options].filter((option) => option.value === 'b-cambridge')
|
||||
.length,
|
||||
1,
|
||||
'the list shows the camera once',
|
||||
);
|
||||
assert.ok([...select.options].every((option) => !option.hidden));
|
||||
});
|
||||
|
||||
test('choosing the shown camera from the picker keeps it after a pan', async (t) => {
|
||||
test('FOCUS on the shown camera keeps it after a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
select.value = 'b-cambridge';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
// The change handler waits for the layer switch before it picks.
|
||||
const focus = document.getElementById('cctv-focus-btn');
|
||||
assert.equal(focus.disabled, false);
|
||||
focus.click();
|
||||
// The click handler waits for the layer switch before it picks.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, false);
|
||||
assert.equal(openingLabel(select), null);
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), false);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
});
|
||||
|
||||
test('closing the picker without a choice lets the camera follow a pan', async (t) => {
|
||||
test('leaving the picker without a pick lets the camera follow a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
select.focus();
|
||||
select.blur();
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, true);
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), true);
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'a-trafalgar');
|
||||
assert.equal(openingLabel(select), 'London · Camera a-trafalgar');
|
||||
assert.equal(select.selectedIndex, 0);
|
||||
assert.equal(select.value, 'a-trafalgar');
|
||||
});
|
||||
@@ -253,23 +253,15 @@ export function _renderCctvState(state) {
|
||||
};
|
||||
}
|
||||
this._picker = picker;
|
||||
// The opening camera follows the view until someone picks one. The picker
|
||||
// shows it in a hidden first option, so choosing it from the list changes
|
||||
// the value and counts as that pick; closing the list leaves it as is.
|
||||
const opening = Boolean(
|
||||
state?.activeCameraProvisional && activeId && activeCamera,
|
||||
);
|
||||
this.store.setPicker({
|
||||
options: picker?.options || [],
|
||||
note: picker?.note || '',
|
||||
opening: opening ? pickerOption(activeCamera, activeId).label : '',
|
||||
disabled,
|
||||
// The active camera is always one of the listed records. With nothing
|
||||
// active the closed picker shows the note when nothing is in view; a
|
||||
// focused picker keeps its old options, so it only clears.
|
||||
selection: opening
|
||||
? { index: 0 }
|
||||
: activeId && activeCamera
|
||||
selection:
|
||||
activeId && activeCamera
|
||||
? { value: activeId }
|
||||
: !activeId
|
||||
? { index: !picking && cameras.length === 0 && outside ? 0 : -1 }
|
||||
|
||||
@@ -25,9 +25,8 @@ export const useCctvStore = defineStore('gev-cctv', () => {
|
||||
/** `{label, state}` for the source badge; null until first synced. */
|
||||
const sourceBadge = shallowRef(null);
|
||||
/**
|
||||
* The camera picker: `{options: [{value, label}], note, opening, disabled,
|
||||
* selection: {value}|{index}|null}`; null until first rendered. `opening`
|
||||
* labels the opening camera's hidden first option, or is empty.
|
||||
* The camera picker: `{options: [{value, label}], note, disabled,
|
||||
* selection: {value}|{index}|null}`; null until first rendered.
|
||||
*/
|
||||
const picker = shallowRef(null);
|
||||
/** The scene summary as typed so far; null until the first one. */
|
||||
|
||||
Reference in new issue
Block a user