Merge main (e4708a81, #1745) into the renderer branch

Main brings the reviewed one-time-control and timeline-mark changes. They
keep this branch's renderer work: earthquakes draw through the draw port and
register their strong quakes as marks; the weather clock keeps `follows` beside
`world`; the weather layer measures ages and delays from the timeline time;
the Visual panel keeps its sky and weather groups under Effects. Tests that
moved time through the weather clock now move it on the world clock.
This commit is contained in:
Sameh Khamis committed 2026-11-14 22:08:39 -08:00
commit 0ecbfbecd0
123 files changed
+5917 -1471

No files matched your search

+18 -4
View File
@@ -9,10 +9,12 @@ import { useCockpitStore } from '../../stores/cockpit.js';
import { useDisplayStore } from '../../stores/display.js';
import UiButton from '../../kit/UiButton.vue';
// The Cockpit's Display and Radio launchers and their popovers. RadioControls
// presents which popover is open and the compact Radio controls; until it
// does, both are closed and the controls show their initial state. The
// controls call RadioControls through the store. The Display popover's slots
// The Cockpit's Display and Radio launchers and their popovers, and the
// desktop look's rail, whose icons stay at the edge and open one panel at a
// time as the main page's rails do. RadioControls presents which popover is
// open and the compact Radio controls; until it does, both are closed and the
// controls show their initial state. The controls call RadioControls through
// the store. The Display popover's slots
// are static: the Display panel teleports its real controls into them while
// the Cockpit display portal publishes them.
const store = useRadioStore();
@@ -52,6 +54,7 @@ const radioLabel = computed(() =>
<div class="cockpit-utility-launcher" data-cockpit-launcher="display">
<span>{{ t('DISPLAY') }}</span>
<span class="cockpit-utility-divider" aria-hidden="true"></span>
<button v-if="open.display" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'display', { returnFocus: true })">−</button>
<button id="cockpit-display-toggle-btn" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel">{{ open.display ? '▶' : '◀' }}</button>
</div>
<div id="cockpit-display-panel" class="cockpit-utility-popover ui-scroll" v-class-toggle="{ 'uses-shared-display-controls': !!cockpitPortal }" role="group" :aria-label="t('Cockpit display options')" :hidden="!open.display">
@@ -65,6 +68,7 @@ const radioLabel = computed(() =>
<div class="cockpit-utility-launcher" data-cockpit-launcher="radio">
<span>{{ t('RADIO') }}</span>
<span class="cockpit-utility-divider" aria-hidden="true"></span>
<button v-if="open.radio" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'radio', { returnFocus: true })">−</button>
<button id="cockpit-radio-toggle-btn" @click="act('toggleCockpitRadio')" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel">{{ open.radio ? '▶' : '◀' }}</button>
</div>
<div id="cockpit-radio-panel" class="cockpit-utility-popover cockpit-radio-compact" role="group" :aria-label="t('Cockpit compact Radio controls')" :hidden="!open.radio">
@@ -82,5 +86,15 @@ const radioLabel = computed(() =>
</label>
</div>
</div>
<div class="cockpit-utility-rail" :class="{ 'is-open': open.display || open.radio }">
<span class="cockpit-utility-rail__labels" aria-hidden="true">
<span>{{ t('DISPLAY') }}</span>
<span>{{ t('RADIO') }}</span>
</span>
<span class="cockpit-utility-rail__icons">
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="display" :class="{ 'is-on': open.display }" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel" @click="act('toggleCockpitUtility', 'display')"><span class="material-symbols-outlined" aria-hidden="true">tune</span></button>
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="radio" :class="{ 'is-on': open.radio }" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel" @click="act('toggleCockpitUtility', 'radio')"><span class="material-symbols-outlined" aria-hidden="true">radio</span></button>
</span>
</div>
</aside>
</template>
+31 -10
View File
@@ -5,12 +5,14 @@ import { t } from '../../../i18n/index.js';
import { vPanelState } from '../../rail/panelState.js';
import { vClassToggle } from '../../rail/classToggle.js';
import PanelCollapseButton from '../../rail/PanelCollapseButton.vue';
import UiPanelEdge from '../../kit/UiPanelEdge.vue';
import UiSegmented from '../../kit/UiSegmented.vue';
import UiSlider from '../../kit/UiSlider.js';
import { useDisplayStore } from '../../stores/display.js';
import UiButton from '../../kit/UiButton.vue';
import UiSelect from '../../kit/UiSelect.js';
import { StyleParameterRows } from '../../styleParameters.js';
import VisualPresets from './VisualPresets.vue';
// The Display panel. VisualSettings presents the HUD, Sonar, Scope,
// Celestial, detection, bloom and sharpen and AircraftDisplay the 3D group,
@@ -21,6 +23,12 @@ const { view, models3d, parameters, cockpitPortal, weather, sky } = storeToRefs(
// A control's change goes to its owner (DisplayBindings).
const act = (name, ...args) => display.act(name, ...args);
const pct = (value) => `${value}%`;
// The words of the on/off pill each card header draws (visual-panel.css), as
// CSS strings.
const pillWords = computed(() => ({
'--pp-pill-on': JSON.stringify(t('ON')),
'--pp-pill-off': JSON.stringify(t('OFF')),
}));
const hud = computed(() => view.value?.hud ?? null);
const sonar = computed(() => view.value?.sonar ?? null);
const sonarOn = computed(() => sonar.value?.enabled ?? true);
@@ -29,6 +37,7 @@ const detectButton = computed(() => detection.value?.button ?? null);
const allocation = computed(() => detection.value?.allocation ?? 'ELASTIC');
const scopeOn = computed(() => view.value?.scope.enabled ?? true);
const scopeFeather = computed(() => view.value?.scope.featherPct ?? 100);
const scopeOpacity = computed(() => view.value?.scope.opacityPct ?? 100);
const celestial = computed(() => view.value?.celestial ?? null);
const celestialTitle = computed(() =>
celestial.value && !celestial.value.supported
@@ -64,15 +73,18 @@ const allocationOptions = computed(() => [
<!-- Post-processing toggles (top-right) -->
<div id="pp-toggles" v-panel-state="'pp-toggles'" class="panel-collapsible collapsed ui-scroll" data-panel-id="pp-toggles">
<div class="compact pp-header-row">
<span class="pp-header-label">{{ t('DISPLAY') }}</span>
<span class="pp-header-label">{{ t('VISUAL', { context: 'panel' }) }}</span>
<span class="panel-divider" aria-hidden="true"></span>
<PanelCollapseButton class="pp-collapse-btn" target="pp-toggles" :name="t('DISPLAY')" sideways start-collapsed />
<UiPanelEdge />
<PanelCollapseButton class="pp-collapse-btn" target="pp-toggles" :name="t('VISUAL', { context: 'panel' })" sideways start-collapsed />
</div>
<div class="pp-panel-body ui-scroll" data-rail-scroller>
<div class="pp-panel-body ui-scroll" data-rail-scroller :style="pillWords">
<VisualPresets />
<!-- Cockpit shows these four groups in its Display popover: each teleports to the slot the Cockpit display portal publishes. While disabled a Teleport stays in place; its 'body' target only keeps server rendering from dropping it. -->
<p class="pp-section-heading">{{ t('Overlay') }}</p>
<Teleport :to="cockpitPortal?.hud ?? 'body'" :disabled="!cockpitPortal?.hud">
<div class="pp-toggle-group">
<button class="pp-toggle-btn" :class="{ active: hud?.visible }" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
<button class="pp-toggle-btn" :class="{ active: hud?.visible }" :aria-pressed="String(Boolean(hud?.visible))" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
<span class="pp-icon">&#x25CE;</span>
<span class="pp-label" translate="no">HUD</span>
</button>
@@ -181,7 +193,17 @@ const allocationOptions = computed(() => [
<UiSlider class="pp-slider" id="scope-feather-slider" @update:model-value="act('setScopeFeather', $event)" min="0" max="200" :model-value="scopeFeather" :disabled="!scopeOn" :aria-label="t('Scope edge feather')" :title="t('Scope edge feather as a percentage of the keyhole radius')" />
<span class="pp-slider-value" id="scope-feather-value">{{ pct(scopeFeather) }}</span>
</div>
<div class="pp-slider-row visible" id="scope-opacity-row">
<span class="pp-slider-mini-label">{{ t('Opacity') }}</span>
<UiSlider class="pp-slider" id="scope-opacity-slider" @update:model-value="act('setScopeOpacity', $event)" min="50" max="100" :model-value="scopeOpacity" :disabled="!scopeOn" :aria-label="t('Scope opacity')" :title="t('How dark the scope shades the view outside the keyhole')" />
<span class="pp-slider-value" id="scope-opacity-value">{{ pct(scopeOpacity) }}</span>
</div>
</div>
<button class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
<span class="pp-icon">&#x25A1;</span>
<span class="pp-label">{{ t('Clean UI') }}</span>
</button>
<p class="pp-section-heading">{{ t('Effects') }}</p>
<div class="pp-toggle-group">
<UiButton class="pp-toggle-btn" :pressed="celestial?.active ?? false" pressed-class="active" id="celestial-toggle" @click="act('toggleCelestial')" :title="celestialTitle" :disabled="celestial ? !celestial.supported : undefined" :aria-disabled="celestial ? String(!celestial.supported) : undefined">
<span class="pp-icon material-symbols-outlined" aria-hidden="true">flare</span>
@@ -217,12 +239,8 @@ const allocationOptions = computed(() => [
<span class="pp-slider-value">{{ pct(weather.values[row.key] ?? 0) }}</span>
</div>
</div>
<button class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
<span class="pp-icon">&#x25A1;</span>
<span class="pp-label">{{ t('Clean UI') }}</span>
</button>
<div class="pp-toggle-group">
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" :aria-pressed="String(Boolean(view?.bloom.active))" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
<span class="pp-icon">&#x2728;</span>
<span class="pp-label">{{ t('Bloom') }}</span>
</button>
@@ -232,7 +250,7 @@ const allocationOptions = computed(() => [
</div>
</div>
<div class="pp-toggle-group">
<button class="pp-toggle-btn" :class="{ active: view?.sharpen.active }" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
<button class="pp-toggle-btn" :class="{ active: view?.sharpen.active }" :aria-pressed="String(Boolean(view?.sharpen.active))" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
<span class="pp-icon">&#x1F50D;</span>
<span class="pp-label">{{ t('Sharpen') }}</span>
</button>
@@ -241,6 +259,9 @@ const allocationOptions = computed(() => [
<span class="pp-slider-value" id="sharpen-intensity-value">{{ pct(view?.sharpen.intensity ?? 49) }}</span>
</div>
</div>
<button type="button" class="pp-reset-btn" :title="t('Reset Visual to its defaults: Normal look, HUD, scope, labels and effects')" @click="act('resetVisual')">
<span class="material-symbols-outlined" aria-hidden="true">restart_alt</span>{{ t('Reset to default') }}
</button>
</div>
</div>
</template>
+1 -1
View File
@@ -77,7 +77,7 @@ test('an application\'s row actions sit before fly to, labelled, and act on thei
const note = row('a1').querySelector('.draw-mark-note');
assert.equal(note.getAttribute('role'), 'status');
assert.equal(note.textContent, '');
assert.equal(row('a2').querySelector('.draw-mark-note'), null, 'a row without actions has no note');
assert.equal(row('a2').querySelector('.draw-mark-note') === null, true, 'a row without actions has no note');
const line = { ...LINE, path: [[0, 0], [1, 0]] };
store.publishDraw({ active: true, shape: 'area', color: 'primary', hint: '', marks: presentDrawMarks([line], drawMarkActions([tag]), new Map([['a1', { busy: true, text: '' }]])) });
await nextTick();
+261
View File
@@ -0,0 +1,261 @@
<script>
import { ref as moduleRef } from 'vue';
/** Voice and other callers ask for this event to show every row again. */
export const LAYER_FINDER_CLEAR_EVENT = 'gev:layer-finder-clear';
// The header buttons and the bar under the header are two instances that
// share one finder.
const finder = {
query: moduleRef(''),
show: moduleRef('all'),
searching: moduleRef(false),
filtering: moduleRef(false),
// A group's stable key (LayerRows' `data-group`), not its translated name,
// so a language change keeps the choice.
category: moduleRef(''),
categories: moduleRef([]),
shown: moduleRef(0),
};
</script>
<script setup>
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
import { msg, t } from '../../../i18n/index.js';
// Search and filter for the Data Layers list. The rows are rendered elsewhere
// (LayerRows), so this works on the list as it stands: it marks rows that
// don't match as filtered out, hides a group heading when none of its rows
// are left, and keeps doing so as rows update.
const props = defineProps({
/** 'buttons' for the header, 'bar' for the row under it. */
part: { type: String, default: 'buttons' },
});
const { query, show, searching, filtering, category, categories, shown } =
finder;
const SHOWS = [
{ id: 'all', label: msg('All layers') },
{ id: 'on', label: msg('On') },
{ id: 'off', label: msg('Off') },
];
const narrowed = computed(
() =>
Boolean(query.value.trim()) || show.value !== 'all' || Boolean(category.value),
);
const categoryLabel = computed(
() => categories.value.find((c) => c.key === category.value)?.label || '',
);
function apply() {
const list = document.getElementById('data-toggles');
if (!list) return;
const q = query.value.trim().toLocaleLowerCase();
let heading = null;
let headingHasRows = false;
let count = 0;
let group = '';
const groups = [];
const close = () =>
heading?.classList.toggle('is-filtered', !headingHasRows);
for (const el of list.children) {
if (el.classList.contains('data-layer-group-heading')) {
close();
heading = el;
headingHasRows = false;
group = el.dataset.group || el.textContent.trim();
groups.push({ key: group, label: el.textContent.trim() });
continue;
}
if (!el.classList.contains('data-toggle-row')) continue;
// The name on screen, in the UI language, and the English name too.
const name = [el.querySelector('.data-name')?.textContent, el.dataset.layerName]
.filter(Boolean)
.join(' ')
.toLocaleLowerCase();
// On means the layer is enabled, whatever its feed is doing.
const on = Boolean(
el.querySelector('.data-toggle-btn')?.classList.contains('active'),
);
const match =
(!q || name.includes(q)) &&
(show.value === 'all' || (show.value === 'on') === on) &&
(!category.value || group === category.value);
el.classList.toggle('is-filtered', !match);
if (match) {
headingHasRows = true;
count++;
}
}
close();
list.classList.toggle('is-filtering', narrowed.value);
const same =
groups.length === categories.value.length &&
groups.every(
(g, i) =>
g.key === categories.value[i].key && g.label === categories.value[i].label,
);
if (!same) categories.value = groups;
// A group that went away takes its filter with it.
if (category.value && !groups.some((g) => g.key === category.value))
category.value = '';
shown.value = count;
}
function clearAll() {
query.value = '';
show.value = 'all';
category.value = '';
searching.value = false;
filtering.value = false;
apply();
}
let observer = null;
let frame = 0;
if (props.part === 'bar') {
onMounted(() => {
const list = document.getElementById('data-toggles');
if (!list) return;
// Rows repaint many times a second; filter once per frame at most.
observer = new MutationObserver(() => {
if (frame) return;
frame = requestAnimationFrame(() => {
frame = 0;
apply();
});
});
observer.observe(list, {
childList: true,
subtree: true,
characterData: true,
attributes: true,
attributeFilter: ['class', 'data-feed-state'],
});
apply();
document.addEventListener(LAYER_FINDER_CLEAR_EVENT, clearAll);
});
onBeforeUnmount(() => {
observer?.disconnect();
cancelAnimationFrame(frame);
document.removeEventListener(LAYER_FINDER_CLEAR_EVENT, clearAll);
});
watch([query, show, category], apply);
}
const searchBtn = () => document.getElementById('layer-finder-search-btn');
async function toggleSearch() {
searching.value = !searching.value;
if (!searching.value) query.value = '';
await nextTick();
if (searching.value) document.getElementById('layer-finder-input')?.focus();
}
// Escape in the field closes the search and stays there: it must not also
// fold the panel or leave the cockpit.
async function closeSearch() {
searching.value = false;
query.value = '';
await nextTick();
searchBtn()?.focus();
}
// The filter is a disclosure of two groups of toggle buttons. Opening it moves
// focus to the chosen option; Escape, or a press outside, closes it and gives
// focus back to its button.
const filterEl = ref(null);
const menuEl = ref(null);
const triggerEl = ref(null);
const options = () => [...(menuEl.value?.querySelectorAll('button') || [])];
async function toggleFilter() {
filtering.value = !filtering.value;
if (!filtering.value) return;
await nextTick();
const menu = menuEl.value;
if (!menu) return;
// Keep the menu inside the panel, which clips what leaves it.
const panel = menu.closest('.ui-panel, [data-panel-id]');
const room = panel
? panel.getBoundingClientRect().bottom - menu.getBoundingClientRect().top - 8
: 0;
menu.style.maxHeight = room > 80 ? `${Math.floor(room)}px` : '';
(menu.querySelector('[aria-pressed="true"]') || options()[0])?.focus();
}
function closeFilter({ refocus = false } = {}) {
filtering.value = false;
if (refocus) triggerEl.value?.focus();
}
function onMenuKey(event) {
if (event.key === 'Escape') {
event.preventDefault();
event.stopPropagation();
closeFilter({ refocus: true });
return;
}
const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
const edge = { Home: 0, End: -1 }[event.key];
if (step === undefined && edge === undefined) return;
event.preventDefault();
const all = options();
const at = all.indexOf(document.activeElement);
const next =
step !== undefined
? all[(at + step + all.length) % all.length]
: all.at(edge);
next?.focus();
}
function onOutside(e) {
if (filtering.value && filterEl.value && !filterEl.value.contains(e.target))
closeFilter();
}
function pickCategory(key) {
category.value = category.value === key ? '' : key;
}
if (props.part === 'buttons') {
onMounted(() => document.addEventListener('pointerdown', onOutside, true));
onBeforeUnmount(() =>
document.removeEventListener('pointerdown', onOutside, true),
);
}
</script>
<template>
<template v-if="part === 'buttons'">
<button id="layer-finder-search-btn" type="button" class="layer-finder__btn" :class="{ active: searching || query }" :aria-pressed="String(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
<span class="material-symbols-outlined" aria-hidden="true">search</span>
</button>
<span ref="filterEl" class="layer-finder__filter">
<button ref="triggerEl" type="button" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
<span class="material-symbols-outlined" aria-hidden="true">filter_list</span>
</button>
<span v-if="filtering" id="layer-finder-menu" ref="menuEl" class="layer-finder__menu" role="group" :aria-label="t('Filter layers')" @keydown="onMenuKey">
<span role="group" :aria-label="t('Status')">
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Status') }}</span>
<button v-for="s in SHOWS" :key="s.id" type="button" :aria-pressed="String(show === s.id)" :class="{ active: show === s.id }" @click="show = s.id">
<span class="material-symbols-outlined" aria-hidden="true">{{ show === s.id ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ t(s.label) }}
</button>
</span>
<span v-if="categories.length" role="group" :aria-label="t('Category')">
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Category') }}</span>
<button v-for="c in categories" :key="c.key" type="button" :aria-pressed="String(category === c.key)" :class="{ active: category === c.key }" @click="pickCategory(c.key)">
<span class="material-symbols-outlined" aria-hidden="true">{{ category === c.key ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ c.label }}
</button>
</span>
</span>
</span>
</template>
<div v-else-if="searching || narrowed" class="layer-finder__bar">
<label v-if="searching" class="layer-finder__field">
<span class="material-symbols-outlined" aria-hidden="true">search</span>
<input id="layer-finder-input" v-model="query" type="search" :placeholder="t('Search layers…')" :aria-label="t('Search layers')" @keydown.esc.stop.prevent="closeSearch" />
</label>
<button v-if="show !== 'all'" type="button" class="layer-finder__chip" @click="show = 'all'">
{{ show === 'on' ? t('On') : t('Off') }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
</button>
<button v-if="category" type="button" class="layer-finder__chip" @click="category = ''">
{{ categoryLabel }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
</button>
<p v-if="narrowed && shown === 0" class="layer-finder__empty" role="status">{{ t('No layers match') }}</p>
</div>
</template>
+124
View File
@@ -0,0 +1,124 @@
<script setup>
import { onBeforeUnmount, onMounted, ref } from 'vue';
import { t } from '../../../i18n/index.js';
// A slim index beside the Data Layers list: one tick per group (Movement,
// Cameras, Infrastructure…). Hovering a tick names its group, clicking it
// scrolls the list there, and the tick for the group in view is lit. It reads
// the list's group headings, which LayerRows renders, so it follows whatever
// groups the layers bring.
const sections = ref([]);
const current = ref(0);
let list = null;
let observer = null;
let resize = null;
function headings() {
return list ? [...list.querySelectorAll('.data-layer-group-heading:not(.is-filtered)')] : [];
}
function readSections() {
const next = headings().map((h, i) => ({ i, label: h.textContent.trim() }));
// Live counts repaint the rows all the time; keep the ticks unless the
// groups themselves changed.
const same =
next.length === sections.value.length &&
next.every((s, i) => s.label === sections.value[i].label);
if (!same) sections.value = next;
syncCurrent();
}
// Only headings matter: a heading added, removed, renamed (a language change)
// or filtered out. Rows' counts and states change many times a second.
const isHeading = (node) =>
node?.classList?.contains('data-layer-group-heading') ||
node?.parentElement?.classList?.contains('data-layer-group-heading');
let frame = 0;
function onMutations(mutations) {
if (frame) return;
const relevant = mutations.some(
(m) =>
(m.type === 'childList' && m.target === list) || isHeading(m.target),
);
if (!relevant) return;
frame = requestAnimationFrame(() => {
frame = 0;
readSections();
});
}
function syncCurrent() {
if (!list) return;
const top = list.getBoundingClientRect().top + 8;
let index = 0;
headings().forEach((h, i) => {
if (h.getBoundingClientRect().top <= top + 4) index = i;
});
// At the very end of the list the last group is the one in view.
const scrolls = list.clientHeight > 0 && list.scrollHeight > list.clientHeight + 2;
if (scrolls && list.scrollTop + list.clientHeight >= list.scrollHeight - 2) index = sections.value.length - 1;
current.value = Math.max(0, index);
}
// The name of the tick being pointed at or focused. It is drawn on the page
// itself, just outside the panel's edge: the panel clips what leaves it, and a
// label inside would cover the rows.
const tip = ref(null);
function showTip(event, section) {
const box = event.currentTarget.getBoundingClientRect();
// Beside the tick on whichever side has room: the stack sits on the right
// in a right-to-left language.
const before = window.innerWidth - box.right < 180;
tip.value = {
label: section.label,
before,
left: `${Math.round(before ? box.left - 10 : box.right + 10)}px`,
top: `${Math.round(box.top + box.height / 2)}px`,
};
}
const hideTip = () => {
tip.value = null;
};
function jump(i) {
const h = headings()[i];
if (!h || !list) return;
list.scrollTo({ top: h.offsetTop - list.offsetTop - 4, behavior: 'smooth' });
}
onMounted(() => {
list = document.getElementById('data-toggles');
if (!list) return;
observer = new MutationObserver(onMutations);
observer.observe(list, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['class'] });
list.addEventListener('scroll', syncCurrent, { passive: true });
// The list is hidden while the panel is shut; read again when it opens.
resize = new ResizeObserver(syncCurrent);
resize.observe(list);
readSections();
});
onBeforeUnmount(() => {
observer?.disconnect();
resize?.disconnect();
cancelAnimationFrame(frame);
list?.removeEventListener('scroll', syncCurrent);
});
</script>
<template>
<nav v-if="sections.length > 1" class="layer-section-index" :aria-label="t('Layer groups')">
<button
v-for="section in sections"
:key="section.i"
type="button"
class="layer-section-index__tick"
:class="{ 'is-current': section.i === current }"
:aria-label="t('Jump to {name}', { name: section.label })"
:aria-current="section.i === current ? 'true' : undefined"
@click="jump(section.i)"
@mouseenter="showTip($event, section)"
@mouseleave="hideTip"
@focus="showTip($event, section)"
@blur="hideTip"
></button>
<Teleport to="body">
<span v-if="tip" class="layer-section-index__label"
:class="{ 'layer-section-index__label--before': tip.before }" :style="{ left: tip.left, top: tip.top }" aria-hidden="true">{{ tip.label }}</span>
</Teleport>
</nav>
</template>
+103
View File
@@ -0,0 +1,103 @@
<script setup>
import { storeToRefs } from 'pinia';
import { msg, t } from '../../../i18n/index.js';
import UiButton from '../../kit/UiButton.vue';
import { useDisplayStore } from '../../stores/display.js';
// The visual presets and map source at the top of the Visual panel. The same
// choices the command dock's tray offers, through the same Display store
// actions, so either surface stays in step with the other.
const display = useDisplayStore();
const { style, mapSource, mapSourceControls } = storeToRefs(display);
const STYLES = [
{
name: 'normal',
icon: '◯',
label: msg('Normal'),
key: '1',
title: msg('Show the globe without a visual filter.'),
},
{
name: 'retro',
icon: '▦',
label: msg('CRT'),
key: '2',
title: msg('Emulate a green phosphor CRT with scanlines and screen curvature.'),
},
{
name: 'surveillance',
icon: '🌙',
label: msg('NVG'),
key: '3',
title: msg('Simulate night-vision goggles with green intensification and a tube vignette.'),
},
{
name: 'thermal',
icon: '🌡️',
label: msg('FLIR'),
key: '4',
title: msg('Simulate FLIR-style thermal contrast. Turn up Ironbow for color.'),
},
{
name: 'anime',
icon: '✦',
label: msg('Anime'),
key: '5',
title: msg('Apply bright cel-shaded color and illustrated outlines.'),
},
{
name: 'noir',
icon: '◐',
label: msg('Noir'),
key: '6',
title: msg('Apply high-contrast monochrome film-noir grading.'),
},
];
function selectMapSource(chip) {
if (!chip.available) return;
void mapSourceControls.value?.select(chip.id).catch(() => {});
}
</script>
<template>
<section class="visual-presets" :aria-label="t('VISUAL PRESETS')">
<p class="visual-presets__heading">{{ t('Look') }}</p>
<div class="visual-presets__grid">
<UiButton
v-for="preset in STYLES"
:key="preset.name"
class="visual-presets__style"
:pressed="(style?.name ?? 'normal') === preset.name"
pressed-class="active"
:data-style="preset.name"
:title="t(preset.title)"
@click="display.act('setStyle', preset.name)"
>
<span class="visual-presets__icon" aria-hidden="true">{{ preset.icon }}</span>
<span class="visual-presets__label">{{ t(preset.label) }}</span>
<kbd class="visual-presets__key">{{ preset.key }}</kbd>
</UiButton>
</div>
<div class="visual-presets__heading visual-presets__heading--row">
<span>{{ t('MAP SOURCE') }}</span>
<span class="visual-presets__status" :class="{ warn: !!mapSource?.status.warn }">{{ mapSource ? mapSource.status.text : '3D' }}</span>
</div>
<div class="visual-presets__chips" role="group" :aria-label="t('Map source')">
<UiButton
v-for="chip in mapSource?.chips"
:key="chip.id"
class="visual-presets__chip"
:class="{ unavailable: !chip.available }"
:pressed="Boolean(chip.active)"
pressed-class="active"
:title="chip.title"
:aria-disabled="String(!chip.available)"
:aria-label="chip.ariaLabel"
@click="selectMapSource(chip)"
>{{ chip.label }}<small v-if="chip.requirement">{{ chip.requirement }}</small></UiButton
>
</div>
</section>
</template>
+197 -4
View File
@@ -19,6 +19,8 @@ function mount(t) {
// The store outlives the view; dispose it with its clock subscription.
useWorldTimeStore(pinia).$dispose();
worldClock.goLive();
// The clock keeps its rate; the next test starts at real time.
worldClock.setRate(1);
});
return () => document.getElementById('world-timeline');
}
@@ -79,16 +81,16 @@ test('the timeline hides while no layer with time to show is on', async (t) => {
const bar = mount(t);
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
await nextTick();
assert.equal(bar(), null, 'live, nothing to play');
assert.equal(bar() === null, true, 'live, nothing to play');
worldClock.seek(at);
await nextTick();
assert.equal(bar(), null, 'away from live, but nothing to play');
assert.equal(bar() === null, true, 'away from live, but nothing to play');
const remove = supportingLayer(t, at);
await nextTick();
assert.ok(bar());
remove();
await nextTick();
assert.equal(bar(), null, 'the layer went off');
assert.equal(bar() === null, true, 'the layer went off');
});
test('the track runs over the time the layers show, to now, and scrubs', async (t) => {
@@ -465,7 +467,7 @@ test('play held for a layer to load shows a spinner once the hold lasts', async
// A clock tick (a quarter second) tells of the hold; the spinner waits on.
await new Promise((resolve) => setTimeout(resolve, 250));
await nextTick();
assert.equal(bubble().querySelector('.world-timeline-spinner'), null, 'not for a quick frame');
assert.equal(bubble().querySelector('.world-timeline-spinner') === null, true, 'not for a quick frame');
// The clock tells of the hold on its next tick, and the bar shows it after.
const until = async (shown) => {
for (let waited = 0; waited < 3_000; waited += 50) {
@@ -581,3 +583,194 @@ test('a pinch measures from where the fingers are, and a lifted finger ends it',
assert.ok(Math.abs(length() - zoomedTo) < 1_000);
on(input, 'pointercancel', 100, 1);
});
test('a tick shows its label on hover, and a tap by it goes to its mark', async (t) => {
const bar = mount(t);
const now = Date.now();
const start = now - 10 * 86_400_000;
// Ticks a fifth and seven tenths along a 1000 px track.
const launch = start + (now - start) * 0.2;
const quake = start + (now - start) * 0.7;
const release = worldClock.hold('test-launches');
const unregister = worldClock.register({
id: 'test-launches',
coverage: () => ({
start,
end: now,
marks: [
start,
{ time: launch, label: 'GAUNTLET PAYLOAD', id: 'l1', kind: 'launch' },
{ time: quake, label: 'M6.4 · Fiji', kind: 'earthquake' },
],
}),
});
t.after(() => {
unregister();
release();
});
await nextTick();
const track = bar().querySelector('.world-timeline-track');
const input = bar().querySelector('input[type=range]');
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
const press = (type, clientX, pointerId = 1) =>
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
const tip = () => bar().querySelector('.world-timeline-mark-label');
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 3, 'ticks stay ticks');
assert.equal(tip()?.textContent ?? null, null);
// Hovering within 6 px of a tick shows its label, in place of the track's hint.
press('pointermove', 205);
await nextTick();
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
assert.equal(track.hasAttribute('title'), false);
press('pointermove', 698);
await nextTick();
assert.equal(tip()?.textContent, 'M6.4 · Fiji');
// Further off, or on a tick with no label, nothing shows.
press('pointermove', 690);
await nextTick();
assert.equal(tip()?.textContent ?? null, null);
assert.equal(track.hasAttribute('title'), true);
press('pointermove', 2);
await nextTick();
assert.equal(tip()?.textContent ?? null, null, 'an unlabelled mark has no label');
press('pointermove', 205);
track.dispatchEvent(new PointerEvent('pointerleave', { clientX: 1_100, pointerId: 1 }));
await nextTick();
assert.equal(tip()?.textContent ?? null, null, 'leaving the track hides it');
// A tap by a tick goes to its mark exactly; elsewhere, to the time there.
press('pointerdown', 704);
press('pointerup', 704);
await nextTick();
assert.equal(worldClock.now(), quake);
assert.match(input.getAttribute('aria-valuetext'), / · M6\.4 · Fiji$/);
press('pointerdown', 500);
press('pointerup', 500);
await nextTick();
const middle = start + (now - start) / 2;
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'went to the middle');
assert.notEqual(worldClock.now(), quake);
assert.match(input.getAttribute('aria-valuetext'), /UTC$/, 'off a mark, the time alone');
// A drag from a tick still scrubs.
press('pointerdown', 200);
press('pointermove', 300);
press('pointerup', 300);
await nextTick();
assert.ok(Math.abs(worldClock.now() - (start + (now - start) * 0.3)) < 60_000);
// The arrows go to the marks and tell their labels; focused, the label shows.
input.dispatchEvent(new Event('focus'));
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }));
await nextTick();
assert.equal(worldClock.now(), launch);
assert.match(input.getAttribute('aria-valuetext'), / · GAUNTLET PAYLOAD$/);
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
input.dispatchEvent(new Event('blur'));
await nextTick();
assert.equal(tip()?.textContent ?? null, null);
});
test('the pointer shows the nearer of two ticks within 6 px, and a zoom or a pan clears it', async (t) => {
const bar = mount(t);
const now = Date.now();
const start = now - 10 * 86_400_000;
// Two ticks 8 px apart on a 1000 px track, at 200 and 208 px.
const first = start + (now - start) * 0.2;
const second = start + (now - start) * 0.208;
const release = worldClock.hold('test-launches');
const unregister = worldClock.register({
id: 'test-launches',
coverage: () => ({
start,
end: now,
marks: [
{ time: first, label: 'FIRST', kind: 'launch' },
{ time: second, label: 'SECOND', kind: 'launch' },
],
}),
});
t.after(() => {
unregister();
release();
});
await nextTick();
const track = bar().querySelector('.world-timeline-track');
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
const pointer = (type, clientX) =>
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId: 1 }));
const tip = () => bar().querySelector('.world-timeline-mark-label');
// Where the first tick sits now, in px along the track.
const firstAt = () =>
Number.parseFloat(bar().querySelector('.world-timeline-tick').style.left) * 10;
// The handle between them, so a zoom keeps both in view.
worldClock.seek((first + second) / 2);
await nextTick();
pointer('pointermove', 203);
await nextTick();
assert.equal(tip()?.textContent, 'FIRST');
pointer('pointermove', 205);
await nextTick();
assert.equal(tip()?.textContent, 'SECOND', 'the nearer of the two');
// A wheel zoom moves the ticks from under the pointer: the label goes.
track.dispatchEvent(new WheelEvent('wheel', { deltaY: -200, cancelable: true }));
await nextTick();
assert.equal(track.classList.contains('is-zoomed'), true);
assert.equal(tip()?.textContent ?? null, null, 'a zoom clears the label');
// So does a pan, by wheel or by drag.
pointer('pointermove', firstAt());
await nextTick();
assert.equal(tip()?.textContent, 'FIRST');
track.dispatchEvent(
new WheelEvent('wheel', { deltaY: 40, shiftKey: true, cancelable: true }),
);
await nextTick();
assert.equal(tip()?.textContent ?? null, null, 'a pan clears the label');
// A tap between them goes to the nearer mark.
track.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
await nextTick();
assert.equal(track.classList.contains('is-zoomed'), false);
pointer('pointerdown', 205);
pointer('pointerup', 205);
await nextTick();
assert.equal(worldClock.now(), second, 'a tap goes to the nearer mark');
});
test('the speed shown follows the world clock, and Play runs at its rate', async (t) => {
const bar = mount(t);
const now = Date.now();
const release = worldClock.hold('test-launches');
const unregister = worldClock.register({
id: 'test-launches',
coverage: () => ({ start: now - 10 * 86_400_000, end: now - 86_400_000 }),
});
t.after(() => {
unregister();
release();
});
await nextTick();
const select = () => bar().querySelector('select.world-timeline-speed');
assert.equal(select().value, 'real');
// A host sets the rate: the selector shows it.
worldClock.setRate(86_400);
await nextTick();
assert.equal(select().value, 'day');
// A rate not offered shows as the nearest offered speed, and Play keeps it.
worldClock.setRate(5_000);
await nextTick();
assert.equal(select().value, 'hour');
bar().querySelector('.world-timeline-play').click();
assert.equal(worldClock.isPlaying(), true);
assert.equal(worldClock.getRate(), 5_000, 'Play runs at the clock\'s own rate');
worldClock.pause();
// Chosen on the selector while paused, the clock takes it at once.
select().value = 'week';
select().dispatchEvent(new Event('change'));
await nextTick();
assert.equal(worldClock.getRate(), 604_800);
assert.equal(select().value, 'week');
});
+91 -15
View File
@@ -8,11 +8,12 @@ import UiIcon from '../../kit/UiIcon.vue';
import UiSelect from '../../kit/UiSelect.js';
// The world timeline: play and pause and the speed on the left, a track
// across the stretch the layers on can show (each launch or frame a tick)
// with a handle to scrub and the time in a bubble over it, and the way back
// to live on the right, lit while live. Scrolling or pinching the track
// zooms it around the handle, dragging it moves along it, and a double-click
// shows it all again. It shows
// across the stretch the layers on can show (each mark, a launch or a strong
// earthquake, a tick, its label shown over it on hover) with a handle to
// scrub and the time in a bubble over it, and the way back to live on the
// right, lit while live. Scrolling or pinching the track zooms it around the
// handle, dragging it moves along it, a tap on or by a tick goes to its
// mark's time exactly, and a double-click shows it all again. It shows
// while a layer with a time of its own (weather, satellites, launches,
// or one a host follows) is on with time to show; with only live feeds such
// as flights on, the bar stays hidden.
@@ -53,6 +54,8 @@ const ZOOM_STEP = 1.5;
const WHEEL_ZOOM = 0.0025;
// Two presses this close are a double-click.
const DOUBLE_PRESS_MS = 500;
// A tap or a hover this near a tick, in pixels, is on its mark.
const MARK_HIT_PX = 6;
const readout = computed(() =>
Number.isFinite(time.value.timeMs)
@@ -109,8 +112,10 @@ const view = computed(() => {
});
const zoomed = computed(() => zoom.value !== null);
const viewLength = () => view.value.end - view.value.start;
// Show `length` of the span ending at `viewEnd`, held to the span.
// Show `length` of the span ending at `viewEnd`, held to the span. A zoom
// or a pan moves the ticks from under the pointer, so its label goes.
function showView(length, viewEnd) {
hovered.value = null;
const { start, end } = span.value;
if (length >= end - start) {
showWhole();
@@ -138,6 +143,7 @@ const follow = (ms) => {
};
const offView = (ms) => ms < view.value.start || ms > view.value.end;
const showWhole = () => {
hovered.value = null;
zoom.value = null;
panned = false;
};
@@ -212,6 +218,7 @@ let movedTime = false;
const onPointerDown = (event) => {
// Only the main button: a right-click is for the menu.
if (event.button > 0) return;
hovered.value = null;
const onHandle = event.target instanceof HTMLInputElement;
pointers.set(event.pointerId, { x: event.clientX, onHandle });
if (pointers.size === 1) {
@@ -241,6 +248,10 @@ const onPointerDown = (event) => {
gesture = { kind: 'press', x: event.clientX, end: view.value.end };
};
const onPointerMove = (event) => {
// A pointer hovering, none pressed, shows the label of the tick under it.
hovered.value = pointers.size
? null
: (markNear(event.clientX, event.currentTarget)?.time ?? null);
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
pointer.x = event.clientX;
@@ -266,8 +277,14 @@ const onPointerMove = (event) => {
};
const onPointerUp = (event) => {
if (!pointers.delete(event.pointerId)) return;
// A tap on or by a tick goes to its mark exactly; elsewhere, to the time
// under it.
if (gesture?.kind === 'press' && event.type === 'pointerup')
store.scrub(timeAt(event.clientX, event.currentTarget), viewLength());
store.scrub(
markNear(event.clientX, event.currentTarget)?.time ??
timeAt(event.clientX, event.currentTarget),
viewLength(),
);
// A finger lifted from a pinch ends it; the other one moves nothing.
gesture = null;
};
@@ -276,11 +293,66 @@ const place = (ms) => {
const { start, end } = view.value;
return end > start ? ((ms - start) / (end - start)) * 100 : 100;
};
// The labels of the marks at each time marked; a time may have none.
const markLabels = computed(() => {
const labels = new Map();
for (const mark of span.value?.markDetails ?? []) {
if (!labels.has(mark.time)) labels.set(mark.time, []);
if (mark.label) labels.get(mark.time).push(mark.label);
}
return labels;
});
// A tick for each time marked in view: where it sits, as a share of the
// track, and its marks' labels.
const ticks = computed(() => {
const { start, end } = view.value;
return span.value.marks
.filter((mark) => mark >= start && mark <= end)
.map((mark) => `${place(mark)}%`);
.map((mark) => ({
time: mark,
share: place(mark) / 100,
labels: markLabels.value.get(mark) ?? [],
}));
});
// The tick nearest `clientX` within MARK_HIT_PX of it, or null.
function markNear(clientX, track) {
if (!view.value) return null;
const { left, width } = track.getBoundingClientRect();
if (!(width > 0)) return null;
let near = null;
let nearest = MARK_HIT_PX;
for (const tick of ticks.value) {
const off = Math.abs(left + tick.share * width - clientX);
if (off <= nearest) {
near = tick;
nearest = off;
}
}
return near;
}
// The time of the tick the pointer hovers, and whether the handle has focus.
const hovered = shallowRef(null);
const focused = shallowRef(false);
// The labels shown over the track: the hovered tick's, or with the handle
// focused and paused on a mark (an arrow key or a tap took it there), that
// mark's. Nothing for a mark with no label.
const markTip = computed(() => {
if (!view.value) return null;
const onMark = !time.value.live && focused.value ? time.value.timeMs : null;
const over = ticks.value.find((each) => each.time === hovered.value);
const tick = over ?? ticks.value.find((each) => each.time === onMark);
return tick?.labels.length
? { share: tick.share, text: tick.labels.join('\n'), hover: Boolean(over) }
: null;
});
// The time as the handle tells it, with the labels of the mark it is on.
const valueText = computed(() => {
const labels = time.value.live
? null
: markLabels.value.get(time.value.timeMs);
return labels?.length
? `${readout.value} · ${labels.join('; ')}`
: readout.value;
});
const shown = computed(() =>
Math.min(view.value.end, Math.max(view.value.start, at.value)),
@@ -294,10 +366,11 @@ const scrub = (event) => {
}
store.scrub(Number(event.target.value), viewLength());
};
// Arrows go to the previous or next mark (a launch, a frame), or a step along
// the track as shown; Page keys take a tenth of it; Home and End go to the
// ends of all of it. Plus and minus zoom, and zero shows it all; with a
// modifier they are the browser's own zoom.
// Arrows go to the previous or next mark (a launch, a strong earthquake),
// whose label the handle then tells with the time, or a step along the track
// as shown where there is none; Page keys take a tenth
// of it; Home and End go to the ends of all of it. Plus and minus zoom, and
// zero shows it all; with a modifier they are the browser's own zoom.
const ZOOM_KEYS = ['+', '=', '-', '0'];
const onKey = (event) => {
if (ZOOM_KEYS.includes(event.key)) {
@@ -331,17 +404,18 @@ const onKey = (event) => {
><UiButton class="world-timeline-play" :label="time.playing ? t('Pause') : t('Play')" @click="store.togglePlay()"
><UiIcon :name="time.playing ? 'pause' : 'play_arrow'" :size="20" /></UiButton
><UiSelect class="gev-field gev-field--compact world-timeline-speed" :aria-label="t('Play speed')" :title="t('Play speed')" :options="speeds" :model-value="speed" @update:model-value="store.setSpeed($event)"
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp"
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="markTip?.hover ? undefined : t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp" @pointerleave="hovered = null"
><time class="world-timeline-time" :class="{ 'is-waiting': waiting }" :style="{ '--at': place(shown) / 100 }" :datetime="new Date(time.timeMs).toISOString()" aria-live="off"
><span v-if="waiting" class="world-timeline-spinner" aria-hidden="true"></span>{{ bubble }}</time
><span v-for="(left, index) in ticks" :key="index" class="world-timeline-tick" :style="{ left }" aria-hidden="true"></span
><span v-if="markTip" class="world-timeline-mark-label" :style="{ '--at': markTip.share }" aria-hidden="true">{{ markTip.text }}</span
><span v-for="tick in ticks" :key="tick.time" class="world-timeline-tick" :style="{ left: `${tick.share * 100}%` }" aria-hidden="true"></span
><span class="world-timeline-fill" :style="{ width: `${place(shown)}%` }" aria-hidden="true"></span
><input
class="world-timeline-scrub"
:class="{ 'is-off-view': handleOff }"
type="range"
:aria-label="t('World time')"
:aria-valuetext="readout"
:aria-valuetext="valueText"
:min="view.start"
:max="view.end"
step="any"
@@ -349,6 +423,8 @@ const onKey = (event) => {
@input="scrub"
aria-keyshortcuts="+ - 0"
@keydown="onKey"
@focus="focused = true"
@blur="focused = false"
/></div
><UiButton class="world-timeline-live" :label="time.live ? t('Live') : t('Back to live')" :pressed="time.live" pressed-class="is-live" :disabled="time.live" @click="store.goLive()">{{ t('Live') }}</UiButton
></div>