mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The screen annotation renderer keeps each mark's SVG parts as attribute records and presents the board to a store after every rendered frame; a view teleports it to the page and hands back the callout text and mark groups the renderer measures. The tracked-entity fade is measured once the frame is in the document, removed marks fade out before they leave, and the styles it injected move to annotations.css.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The screen-space annotation board as its view renders it. The screen
|
|
* annotation renderer (src/annotations/screenAnnotationRenderer.js) presents
|
|
* every mark's SVG parts after each rendered frame; the view hands back the
|
|
* elements the renderer measures and reports when a draw-on stroke finishes.
|
|
*/
|
|
export const useScreenAnnotationsStore = defineStore(
|
|
'gev-screen-annotations',
|
|
() => {
|
|
/**
|
|
* `{owner, viewBox, markers, marks}`, or null while no renderer exists.
|
|
* Each mark is `{key, className, opacity, display, drawn, children}`;
|
|
* `owner` is passed back with each element and report.
|
|
*/
|
|
const board = shallowRef(null);
|
|
|
|
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
|
function publish(next) {
|
|
board.value = next && markRaw(next);
|
|
}
|
|
|
|
/**
|
|
* The controls whose `attach(owner, key, kind, element)` and
|
|
* `drawn(owner, key)` the view calls.
|
|
*/
|
|
const controls = shallowRef(null);
|
|
|
|
/** @param {?object} next The controls, or null to disconnect. */
|
|
function connect(next) {
|
|
controls.value = next && markRaw(next);
|
|
}
|
|
|
|
return { board, publish, controls, connect };
|
|
},
|
|
);
|