mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
fix(click): the card or label on top takes the click in every layer
Review fixes for #1781: - One rule for cards: the world-overlay host hands its hit test to the pick registry, and every click handler reads the topmost interactive card or label once per click (`clickCard`, `isUnderOtherCard` in src/data/pickRegistry.js), so all handlers agree in any listener order. A layer whose own card or label is on top acts on it whatever is drawn under it; a layer under another layer's card neither acts nor treats the click as empty space (a tracked aircraft stays tracked, a selection stays selected); Context names nothing under a card. A selected news card over a vessel no longer opens the link and selects the vessel. - With one rule, the per-owner arbitration options are no longer read and are removed: `passive`, `expanded` and `declinesClick` pick owners, `rememberClickPickActions`, `isActedOnByOtherLayer`, card backgrounds and `cardKeepsClick`. The dispatcher is unchanged from main. - A drag that ends on a quake disc, label or card does nothing; opening the USGS page or clearing the selection needs a clean click. - A click on the map under another layer's card opens no Street Level ground image. - A CCTV card that is going away is still not the scene under it. - Docs and changelog describe the new rule.
This commit is contained in:
1 parent
7312280817
commit
bb3bf9858b
87 files changed
+1398
-1775
No files matched your search
@@ -221,6 +221,8 @@ function harness(
|
||||
unregisterPickOwner: (id) => owners.delete(id),
|
||||
resolvePickId: (pick) => pick?.id ?? pick?.primitive?.id,
|
||||
isOwnedByOtherLayer: (_layerId, id) => id?.startsWith('other:'),
|
||||
// The card on top at a click, as the registry answers from the host.
|
||||
clickCard: () => cardHit,
|
||||
},
|
||||
sprites: { spriteDrawOrder: () => -9 },
|
||||
render: { governorRequestRender: (reason) => renders.push(reason) },
|
||||
|
||||
@@ -482,12 +482,13 @@ export function createSelection({ state, services, parts }) {
|
||||
state.clickHandler = input.onClick((click) => {
|
||||
if (!state.enabled || services.pointer?.isPointerFree?.() === false)
|
||||
return;
|
||||
const at = click.screenPosition;
|
||||
// The topmost painted entry decides: our own card or label acts; one
|
||||
// covered by another layer's card does not.
|
||||
const hit = overlay?.hitTest?.(at?.x, at?.y);
|
||||
if (hit && sourceIds.includes(hit.sourceId)) {
|
||||
hit.entry?.activate?.();
|
||||
// The card or label painted on top takes the click, read once per
|
||||
// click so every layer agrees: ours acts whatever is drawn under it;
|
||||
// another layer's is that layer's click, so the sightings under it do
|
||||
// not act and the selection stays.
|
||||
const hit = services.picking?.clickCard?.(click) ?? null;
|
||||
if (hit) {
|
||||
if (sourceIds.includes(hit.sourceId)) hit.entry?.activate?.();
|
||||
return;
|
||||
}
|
||||
// A sighting icon's item id is its pick id, `wildlife:<stableId>`.
|
||||
@@ -509,8 +510,6 @@ export function createSelection({ state, services, parts }) {
|
||||
services.picking?.isOwnedByOtherLayer?.('wildlife-sightings', id)
|
||||
)
|
||||
return;
|
||||
// Another layer's card on top is that layer's click, not empty map.
|
||||
if (hit) return;
|
||||
clearAndRebuild();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,20 +43,17 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
},
|
||||
};
|
||||
bindWildlifeViewer(state.viewer);
|
||||
const overlayHost = {
|
||||
setEntries: (id, value) => entries.set(id, value),
|
||||
clearSource: (id) => entries.delete(id),
|
||||
setVisible() {},
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
sourceId ? (hit?.sourceId === sourceId ? hit : null) : coveringHit || hit,
|
||||
};
|
||||
const selection = createSelection({
|
||||
state,
|
||||
services: {
|
||||
overlayHost: {
|
||||
setEntries: (id, value) => entries.set(id, value),
|
||||
clearSource: (id) => entries.delete(id),
|
||||
setVisible() {},
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
sourceId
|
||||
? hit?.sourceId === sourceId
|
||||
? hit
|
||||
: null
|
||||
: coveringHit || hit,
|
||||
},
|
||||
overlayHost,
|
||||
now: () => row.observedAt + 60_000,
|
||||
project: (_scene, anchor) => {
|
||||
projections++;
|
||||
@@ -71,6 +68,12 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
}),
|
||||
eventTarget: new EventTarget(),
|
||||
...extraServices,
|
||||
// The card on top at a click, as the registry answers from the host.
|
||||
picking: {
|
||||
clickCard: (c) =>
|
||||
overlayHost.hitTest(c.screenPosition?.x, c.screenPosition?.y),
|
||||
...extraServices.picking,
|
||||
},
|
||||
},
|
||||
parts: {
|
||||
rendering: {
|
||||
@@ -187,7 +190,7 @@ test('selected photo and name cards use the selected lane, select on click and n
|
||||
}
|
||||
});
|
||||
|
||||
test('a covered sighting label yields; the top label acts over trails and other scene items', () => {
|
||||
test('a covered sighting label and icon yield; the top label acts over trails and other scene items', () => {
|
||||
const f = fixture(row, {
|
||||
// Registered owners, as the app has them: an aircraft, and the flight
|
||||
// trails every layer reads as a no-op (src/data/trailRenderer.js).
|
||||
@@ -205,15 +208,16 @@ test('a covered sighting label yields; the top label acts over trails and other
|
||||
f.click(null);
|
||||
assert.equal(f.flights.length, 1);
|
||||
assert.equal(f.state.selectedRow, row);
|
||||
// A sighting icon under another layer's card is that card's click too.
|
||||
f.click();
|
||||
assert.equal(f.flights.length, 2, 'an actual sighting remains selectable');
|
||||
assert.equal(f.flights.length, 1, 'a covered sighting does not act');
|
||||
f.cover(null);
|
||||
// The top label acts over a flight trail: never a dead click.
|
||||
f.click('gev-trail:fl-a1b2c3:head');
|
||||
assert.equal(f.flights.length, 3, 'the label acts over a flight trail');
|
||||
// And over another layer's scene item, as on main.
|
||||
assert.equal(f.flights.length, 2, 'the label acts over a flight trail');
|
||||
// And over another layer's scene item.
|
||||
f.click('other:aircraft');
|
||||
assert.equal(f.flights.length, 4, 'the top label acts');
|
||||
assert.equal(f.flights.length, 3, 'the top label acts');
|
||||
assert.equal(f.state.selectedRow, row);
|
||||
f.selection.remove();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user