Files
gods-eye-view/src/ui/views/panels/CockpitProgress.vue
T
Denis Groshev c24352ff5e fix(cockpit): an application subject keeps its rates on a slow update interval, its ground lift eases out, and its HUD shows a speed and a progress name only when given
An application subject's camera step is now capped at its own update
interval plus 0.1 s rather than at 0.1 s, so at 500 ms its heading slew,
ground lift and anchor correction run at their configured rates; a long
stall still moves it no further than one late update. The built-in
views keep their 0.1 s cap.

When groundClamp turns false the lift the floor gave goes at the rate
it came, not at once. A HUD view with no speed has no speed readout,
and a progress line with no summary is hidden from assistive
technology instead of being an unnamed image.
2026-11-12 17:00:12 +01:00

58 lines
2.7 KiB
Vue

<script setup>
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { cockpitProgressLayout } from '../../../cockpitProgress.js';
// A provider subject's progress line (src/cockpitSubjectProviders.js): a thin
// line along the bottom of the view, its ticks, labels and marker laid out
// at the line's own width (src/cockpitProgress.js). The part before the
// marker is dimmed. Everything it shows is worded by the provider. It is an
// image named by the provider's summary; with no summary it is decoration,
// hidden from assistive technology.
const props = defineProps({
progress: { type: Object, required: true },
});
/** The width laid out at before the line is measured (px). */
const FALLBACK_WIDTH_PX = 960;
const root = ref(null);
const widthPx = ref(0);
let observer = null;
const measure = () => {
widthPx.value = root.value?.clientWidth || 0;
};
onMounted(() => {
measure();
if (typeof ResizeObserver === 'function' && root.value) {
observer = new ResizeObserver(measure);
observer.observe(root.value);
}
});
onBeforeUnmount(() => observer?.disconnect());
const width = computed(() => widthPx.value || FALLBACK_WIDTH_PX);
const layout = computed(() =>
cockpitProgressLayout(props.progress, width.value),
);
// Positions as shares of the line, so a resize between measurements keeps
// every mark in place.
const percent = (x) => `${((x / width.value) * 100).toFixed(3)}%`;
</script>
<template>
<div ref="root" class="cockpit-progress" :role="progress.summary ? 'img' : undefined" :aria-label="progress.summary || undefined" :aria-hidden="progress.summary ? undefined : 'true'">
<template v-if="layout">
<div class="cockpit-progress-line" aria-hidden="true">
<span class="cockpit-progress-travelled" :style="{ width: percent(layout.travelledX) }"></span>
</div>
<i v-for="(tick, index) in layout.ticks" :key="`t${index}`" class="cockpit-progress-tick" :class="{ labelled: tick.labelled, merged: tick.count > 1, travelled: tick.x <= layout.travelledX }" :data-tone="tick.tone" :style="{ left: percent(tick.x) }" aria-hidden="true"></i>
<span v-for="(label, index) in layout.labels" :key="`l${index}`" class="cockpit-progress-label" :data-align="label.align" :data-tone="label.tone" :style="{ left: percent(label.left), width: `${label.width}px` }" aria-hidden="true"><b>{{ label.text }}</b><small v-if="label.detail">{{ label.detail }}</small></span>
<i v-if="layout.marker" class="cockpit-progress-marker" :class="{ dwell: layout.marker.dwell }" :style="{ left: percent(layout.marker.x) }" aria-hidden="true"></i>
<span v-if="layout.tag" class="cockpit-progress-tag" aria-hidden="true">{{ layout.tag }}</span>
</template>
</div>
</template>