mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The picker's options are data: CctvControls computes the cameras in view and the closing note for those left out, keeps a focused picker's list and prepends a camera activated under it, and publishes the options, disabled state and selection. CctvPicker renders them keyed by camera id and applies the selection once the options are in place; it updates only when the controls publish, as the old picker did on layer notifications. A picker about to be disabled no longer counts as focused. This completes the CCTV panel: everything it shows is rendered from the gev-cctv store.
89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The CCTV panel as its view renders it. CctvControls presents the buttons,
|
|
* CAL chip, meta line and calibration readout (`presentCctvPanel()`), runs
|
|
* the frame preview, source badge and typed summary, and publishes them
|
|
* here, with the camera picker's options; it keeps its listeners on the
|
|
* panel's controls.
|
|
*/
|
|
export const useCctvStore = defineStore('gev-cctv', () => {
|
|
/** The presented panel; null until the controls first render. */
|
|
const view = shallowRef(null);
|
|
|
|
/**
|
|
* The pose value being typed: `{field, label, ariaLabel, step, value,
|
|
* finish(commit, typedText)}`, or null.
|
|
*/
|
|
const calEdit = shallowRef(null);
|
|
|
|
/** The preview: requested and shown frame, loading and error state. */
|
|
const frame = shallowRef(null);
|
|
/** Whether the live video surface replaces the still frame. */
|
|
const live = shallowRef(false);
|
|
/** `{label, state}` for the source badge; null until first synced. */
|
|
const sourceBadge = shallowRef(null);
|
|
/**
|
|
* 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. */
|
|
const summary = shallowRef(null);
|
|
|
|
/** @param {object} next A fresh presentation; every publish re-renders. */
|
|
function publish(next) {
|
|
view.value = markRaw(next);
|
|
}
|
|
|
|
let editCount = 0;
|
|
|
|
/** @param {object|null} edit Each edit gets its own `id`, and input. */
|
|
function setCalEdit(edit) {
|
|
calEdit.value = edit ? markRaw({ ...edit, id: ++editCount }) : null;
|
|
}
|
|
|
|
/** @param {object} next */
|
|
function setFrame(next) {
|
|
frame.value = markRaw(next);
|
|
}
|
|
|
|
/** @param {boolean} on */
|
|
function setLive(on) {
|
|
live.value = Boolean(on);
|
|
}
|
|
|
|
/** @param {{label: string, state: string}} next */
|
|
function setSourceBadge(next) {
|
|
sourceBadge.value = markRaw(next);
|
|
}
|
|
|
|
/** @param {object} next */
|
|
function setPicker(next) {
|
|
picker.value = markRaw(next);
|
|
}
|
|
|
|
/** @param {string} text */
|
|
function setSummary(text) {
|
|
summary.value = text;
|
|
}
|
|
|
|
return {
|
|
view,
|
|
calEdit,
|
|
frame,
|
|
live,
|
|
sourceBadge,
|
|
summary,
|
|
picker,
|
|
publish,
|
|
setCalEdit,
|
|
setFrame,
|
|
setLive,
|
|
setSourceBadge,
|
|
setSummary,
|
|
setPicker,
|
|
};
|
|
});
|