mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Merge origin/main into space-missions-fixes
Main's single click rule (the card or label on top takes the click, read once per click through clickCard and isUnderOtherCard in src/data/pickRegistry.js) covers a click on a Space Missions label: a mission marker label is an interactive world-overlay entry, so the host's hit test names it as the card on top for every other layer. The per-layer label guards in CCTV, Drone Airspace, FIRMS, Ghost Maps, News, Perimeters, Shipwrecks, Vessels, Wildlife Sightings, ALPR, Local ADS-B and the cockpit orbital focus are dropped for main's versions. The mission-label tests are kept on main's API: fakeInputUnderLabel now also names the label as the card on top, and each test shows a click on the label never acts on the card, camera, vessel, fire, reader, aircraft or report under it, and leaves the selection as it is. A launches test checks that a mission label is interactive and is the card on top for every other layer. Docs, changelog and the dispatcher's `overlay` note describe the merged behaviour. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
commit
0e5c5e624c
146 files changed
+9734
-1157
No files matched your search
@@ -277,15 +277,18 @@ export function createShipwrecksLayer({
|
||||
if (!clicks) return;
|
||||
_clickHandler = clicks.onClick((click) => {
|
||||
if (pointer && !pointer.isPointerFree()) return;
|
||||
const at = click.screenPosition;
|
||||
// A click a label painted over the cards took is not on a card.
|
||||
const cardHit = click.overlay
|
||||
? null
|
||||
: overlayHost.hitTest?.(at?.x, at?.y, {
|
||||
sourceId: SHIPWRECKS_OVERLAY_SOURCE_ID,
|
||||
});
|
||||
if (cardHit && cardHit.entryId === _selectedCardId) {
|
||||
if (_selectedLink) openExternal(_selectedLink);
|
||||
// The card or label painted on top takes the click, read once per
|
||||
// click so every layer agrees: ours opens its source whatever is drawn
|
||||
// under it; another layer's is that layer's click, so the markers
|
||||
// under it do not act and the selection stays.
|
||||
const cardHit = picking.clickCard?.(click) ?? null;
|
||||
if (cardHit) {
|
||||
if (
|
||||
cardHit.sourceId === SHIPWRECKS_OVERLAY_SOURCE_ID &&
|
||||
cardHit.entryId === _selectedCardId &&
|
||||
_selectedLink
|
||||
)
|
||||
openExternal(_selectedLink);
|
||||
return;
|
||||
}
|
||||
// A marker's item id is its pick id, `shipwreck:<id>`. Read from what is
|
||||
|
||||
@@ -37,7 +37,7 @@ function deferred() {
|
||||
return { promise, resolve };
|
||||
}
|
||||
|
||||
function harness({ snapshots, now = () => 1 } = {}) {
|
||||
function harness({ snapshots, now = () => 1, cardHit = () => null } = {}) {
|
||||
const cards = [];
|
||||
const handlers = [];
|
||||
const opened = [];
|
||||
@@ -48,6 +48,8 @@ function harness({ snapshots, now = () => 1 } = {}) {
|
||||
const { draw } = bindFakeDraw(viewer);
|
||||
const queue = [...(snapshots || [])];
|
||||
const requests = [];
|
||||
// The card on top at a click, as the host answers the pick registry.
|
||||
picking.setClickCardHitTest((x, y) => cardHit(x, y));
|
||||
const layer = createShipwrecksLayer({
|
||||
source: {
|
||||
getSnapshot({ signal }) {
|
||||
@@ -60,7 +62,7 @@ function harness({ snapshots, now = () => 1 } = {}) {
|
||||
overlayHost: {
|
||||
setEntries: (_source, entries) => cards.push(entries),
|
||||
setVisible() {},
|
||||
hitTest: () => null,
|
||||
hitTest: cardHit,
|
||||
},
|
||||
// The globe's clicks: one listener per click handler installed.
|
||||
input: () => ({
|
||||
@@ -395,21 +397,23 @@ test('the page deadline subtracts the newest available source age from the limit
|
||||
assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults');
|
||||
});
|
||||
|
||||
test("a click a label painted over the open card takes never opens the card's link, and closes the card", async (t) => {
|
||||
test("a click on a mission label over the open card never opens the card's link, and keeps the card open", async (t) => {
|
||||
let picked = null;
|
||||
const viewer = { scene: { canvas: {}, pick: () => picked } };
|
||||
bindFakeDraw(viewer);
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
let cardUnder = null;
|
||||
const fake = fakeInputUnderLabel(viewer, {
|
||||
beneath: () =>
|
||||
cardUnder ? { sourceId: 'shipwrecks', entryId: cardUnder } : null,
|
||||
});
|
||||
t.after(() => fake.destroy());
|
||||
const cards = [];
|
||||
const opened = [];
|
||||
let cardUnder = null;
|
||||
const layer = createShipwrecksLayer({
|
||||
source: { getSnapshot: () => Promise.resolve(snapshot([wreck('a')])) },
|
||||
overlayHost: {
|
||||
setEntries: (_source, entries) => cards.push(entries),
|
||||
setVisible() {},
|
||||
hitTest: () => (cardUnder ? { entryId: cardUnder } : null),
|
||||
},
|
||||
input: () => fake.input,
|
||||
picking,
|
||||
@@ -426,19 +430,63 @@ test("a click a label painted over the open card takes never opens the card's li
|
||||
const [card] = cards.at(-1);
|
||||
assert.equal(card.id, 'shipwreck-card:a');
|
||||
|
||||
// The open card lies under the label: the click opens nothing.
|
||||
// The open card lies under the label: the click opens nothing, and the
|
||||
// label on top is its own click, so the card stays open.
|
||||
picked = null;
|
||||
cardUnder = card.id;
|
||||
fake.label.over = true;
|
||||
fake.click();
|
||||
assert.deepEqual(opened, [], 'the link beneath the label is not opened');
|
||||
assert.deepEqual(cards.at(-1), [], 'the card is closed');
|
||||
assert.equal(cards.at(-1)[0]?.id, card.id, 'the card stays open');
|
||||
|
||||
// Off the label, a click on the open card opens its link.
|
||||
fake.label.over = false;
|
||||
picked = { primitive: {}, id: { set: 'shipwrecks:', id: 'shipwreck:a' } };
|
||||
fake.click();
|
||||
picked = null;
|
||||
fake.click();
|
||||
assert.equal(opened.length, 1);
|
||||
});
|
||||
|
||||
test('a covered selected card and covered markers yield; bare markers select', async () => {
|
||||
let painted = [];
|
||||
const h = harness({
|
||||
snapshots: [
|
||||
snapshot([
|
||||
wreck('a', { url: 'https://example.com/a' }),
|
||||
wreck('b', { url: 'https://example.com/b' }),
|
||||
]),
|
||||
],
|
||||
cardHit: (_x, _y, { sourceId } = {}) =>
|
||||
painted.find((hit) => !sourceId || hit.sourceId === sourceId) ?? null,
|
||||
});
|
||||
try {
|
||||
h.layer.enable();
|
||||
await h.layer.update();
|
||||
const click = () => h.handlers[0].click({ screenPosition: { x: 1, y: 1 } });
|
||||
h.pick('a');
|
||||
click();
|
||||
const first = h.lastCard()[0];
|
||||
painted = [
|
||||
{ sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' },
|
||||
{ sourceId: 'shipwrecks', entryId: first.id },
|
||||
];
|
||||
h.pick(null);
|
||||
click();
|
||||
assert.deepEqual(h.opened, []);
|
||||
assert.equal(h.lastCard()[0].id, first.id);
|
||||
// A marker under another layer's card is that card's click too.
|
||||
h.pick('b');
|
||||
click();
|
||||
assert.equal(h.lastCard()[0].id, first.id, 'a covered marker yields');
|
||||
painted = [];
|
||||
click();
|
||||
assert.equal(h.lastCard()[0].id, 'shipwreck-card:b');
|
||||
painted = [{ sourceId: 'shipwrecks', entryId: 'shipwreck-card:b' }];
|
||||
h.pick(null);
|
||||
click();
|
||||
assert.deepEqual(h.opened, ['https://example.com/b']);
|
||||
painted = [];
|
||||
click();
|
||||
assert.deepEqual(h.lastCard(), [], 'bare map still clears the selection');
|
||||
} finally {
|
||||
h.layer.destroy();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user