@teachinglab/omd 0.7.25 → 0.7.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas/core/omdCanvas.js +5 -0
- package/canvas/ui/cursor.js +9 -0
- package/canvas/ui/toolbar.js +33 -1
- package/package.json +1 -1
package/canvas/core/omdCanvas.js
CHANGED
|
@@ -202,6 +202,11 @@ export class omdCanvas {
|
|
|
202
202
|
this.focusFrameManager = new FocusFrameManager(this);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
// Keep the custom cursor above toolbar/buttons and all other SVG UI.
|
|
206
|
+
if (this.cursor && this.svg) {
|
|
207
|
+
this.cursor.attachTo(this.svg);
|
|
208
|
+
}
|
|
209
|
+
|
|
205
210
|
// Apply any selection styles defined in config to the ResizeHandleManager
|
|
206
211
|
// (PointerTool registers the manager on canvas.resizeHandleManager during its constructor)
|
|
207
212
|
if (this.resizeHandleManager && this.config.selection) {
|
package/canvas/ui/cursor.js
CHANGED
|
@@ -461,4 +461,13 @@ export class Cursor {
|
|
|
461
461
|
this.element.parentNode.removeChild(this.element);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Reattach the cursor element to a specific parent so it can sit above other SVG UI.
|
|
467
|
+
* @param {SVGElement} parent
|
|
468
|
+
*/
|
|
469
|
+
attachTo(parent) {
|
|
470
|
+
if (!parent || !this.element) return;
|
|
471
|
+
parent.appendChild(this.element);
|
|
472
|
+
}
|
|
464
473
|
}
|
package/canvas/ui/toolbar.js
CHANGED
|
@@ -45,12 +45,26 @@ export class Toolbar {
|
|
|
45
45
|
|
|
46
46
|
// Create a jsvgGroup for the toolbar
|
|
47
47
|
this.toolbarGroup = new jsvgGroup();
|
|
48
|
+
this.toolbarGroup.svgObject.style.cursor = 'none';
|
|
48
49
|
|
|
49
50
|
// Stop pointer events from bubbling to canvas to prevent drawing while interacting with toolbar
|
|
50
51
|
const stopPropagation = (e) => e.stopPropagation();
|
|
51
52
|
this.toolbarGroup.svgObject.addEventListener('pointerdown', stopPropagation);
|
|
52
|
-
this.toolbarGroup.svgObject.addEventListener('pointermove', stopPropagation);
|
|
53
53
|
this.toolbarGroup.svgObject.addEventListener('pointerup', stopPropagation);
|
|
54
|
+
|
|
55
|
+
// Keep the custom cursor alive while hovering toolbar controls.
|
|
56
|
+
this.toolbarGroup.svgObject.addEventListener('pointermove', (e) => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
this._syncCanvasCursor(e);
|
|
59
|
+
});
|
|
60
|
+
this.toolbarGroup.svgObject.addEventListener('pointerenter', (e) => {
|
|
61
|
+
this._syncCanvasCursor(e, true);
|
|
62
|
+
});
|
|
63
|
+
this.toolbarGroup.svgObject.addEventListener('pointerleave', () => {
|
|
64
|
+
if (this.canvas.cursor) {
|
|
65
|
+
this.canvas.cursor.hide();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
54
68
|
|
|
55
69
|
// Create background rectangle
|
|
56
70
|
this.background = new jsvgRect();
|
|
@@ -311,4 +325,22 @@ export class Toolbar {
|
|
|
311
325
|
}
|
|
312
326
|
this.buttons.clear();
|
|
313
327
|
}
|
|
328
|
+
|
|
329
|
+
_syncCanvasCursor(event, forceShow = false) {
|
|
330
|
+
if (!this.canvas?.cursor || !this.canvas?.clientToSVG) return;
|
|
331
|
+
|
|
332
|
+
const canvasCoords = this.canvas.clientToSVG(event.clientX, event.clientY);
|
|
333
|
+
this.canvas.cursor.setPosition(canvasCoords.x, canvasCoords.y);
|
|
334
|
+
|
|
335
|
+
if (forceShow) {
|
|
336
|
+
this.canvas.cursor.show();
|
|
337
|
+
const activeTool = this.canvas.toolManager?.getActiveTool?.();
|
|
338
|
+
if (activeTool?.getCursor) {
|
|
339
|
+
this.canvas.cursor.setShape(activeTool.getCursor());
|
|
340
|
+
}
|
|
341
|
+
if (activeTool?.config) {
|
|
342
|
+
this.canvas.cursor.updateFromToolConfig(activeTool.config);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
314
346
|
}
|