feat(pointer): an application's own tool can take the pointer

createApplicationTools returns pointer: claim(owner) takes the pointer as
Draw does and returns its lease, or null while another tool holds it;
release(lease) gives it back; isFree() lets the application's own click
handlers yield, as the layers' do. This replaces drawShape, which this
branch added: Draw is as it was.
This commit is contained in:
Sameh Khamis committed 2026-11-09 16:56:59 -08:00
1 parent 0600d86584
commit a7f96313e9
5 files changed
+18 -231

No files matched your search

+13 -9
View File
@@ -1,7 +1,11 @@
import { SceneDirector } from '../scenes/director.js';
import { initAnnotations } from '../annotations/index.js';
import { initDrawTool } from '../annotations/drawTool.js';
import { isPointerFree } from '../data/inputOwnership.js';
import {
claimPointer,
isPointerFree,
releasePointer,
} from '../data/inputOwnership.js';
import { initGeoFileImport } from '../ui/geoFileImport.js';
import { useDisplayStore } from '../ui/stores/display.js';
import { applicationPinia } from '../ui/vueRuntime.js';
@@ -246,17 +250,17 @@ export function createApplicationTools({
signal,
}),
);
// Draw one area or line and get its geometry back, without placing a mark
// (annotations/drawTool.js `drawShape`); null without the Draw controls.
const drawShape = (options) =>
drawTool ? drawTool.drawShape(options) : Promise.resolve(null);
// An application's own click handlers yield while a tool holds the pointer,
// as the layers' do (data/inputOwnership.js).
// An application's own tool takes the pointer as Draw does, and its own
// click handlers yield while a tool holds it, as the layers' do
// (data/inputOwnership.js).
return {
sceneDirector,
annotations,
voiceCommands,
drawShape,
pointerFree: isPointerFree,
pointer: {
claim: claimPointer,
release: releasePointer,
isFree: isPointerFree,
},
};
}