mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-25 06:22:14 -03:00
Add mask drawing mode to canvas interactions
Introduces support for a 'drawingMask' interaction mode in CanvasInteractions. Mouse events are now delegated to the maskTool when in this mode, and the canvas is re-rendered after each relevant event.
This commit is contained in:
@@ -70,6 +70,12 @@ export class CanvasInteractions {
|
|||||||
const worldCoords = this.canvas.getMouseWorldCoordinates(e);
|
const worldCoords = this.canvas.getMouseWorldCoordinates(e);
|
||||||
const viewCoords = this.canvas.getMouseViewCoordinates(e);
|
const viewCoords = this.canvas.getMouseViewCoordinates(e);
|
||||||
|
|
||||||
|
if (this.interaction.mode === 'drawingMask') {
|
||||||
|
this.canvas.maskTool.handleMouseDown(worldCoords, viewCoords);
|
||||||
|
this.canvas.render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// --- Ostateczna, poprawna kolejność sprawdzania ---
|
// --- Ostateczna, poprawna kolejność sprawdzania ---
|
||||||
|
|
||||||
// 1. Akcje globalne z modyfikatorami (mają najwyższy priorytet)
|
// 1. Akcje globalne z modyfikatorami (mają najwyższy priorytet)
|
||||||
@@ -115,6 +121,7 @@ export class CanvasInteractions {
|
|||||||
|
|
||||||
handleMouseMove(e) {
|
handleMouseMove(e) {
|
||||||
const worldCoords = this.canvas.getMouseWorldCoordinates(e);
|
const worldCoords = this.canvas.getMouseWorldCoordinates(e);
|
||||||
|
const viewCoords = this.canvas.getMouseViewCoordinates(e);
|
||||||
this.canvas.lastMousePosition = worldCoords; // Zawsze aktualizuj ostatnią pozycję myszy
|
this.canvas.lastMousePosition = worldCoords; // Zawsze aktualizuj ostatnią pozycję myszy
|
||||||
|
|
||||||
// Sprawdź, czy rozpocząć przeciąganie
|
// Sprawdź, czy rozpocząć przeciąganie
|
||||||
@@ -131,6 +138,10 @@ export class CanvasInteractions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (this.interaction.mode) {
|
switch (this.interaction.mode) {
|
||||||
|
case 'drawingMask':
|
||||||
|
this.canvas.maskTool.handleMouseMove(worldCoords, viewCoords);
|
||||||
|
this.canvas.render();
|
||||||
|
break;
|
||||||
case 'panning':
|
case 'panning':
|
||||||
this.panViewport(e);
|
this.panViewport(e);
|
||||||
break;
|
break;
|
||||||
@@ -156,6 +167,13 @@ export class CanvasInteractions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleMouseUp(e) {
|
handleMouseUp(e) {
|
||||||
|
const viewCoords = this.canvas.getMouseViewCoordinates(e);
|
||||||
|
if (this.interaction.mode === 'drawingMask') {
|
||||||
|
this.canvas.maskTool.handleMouseUp(viewCoords);
|
||||||
|
this.canvas.render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.interaction.mode === 'resizingCanvas') {
|
if (this.interaction.mode === 'resizingCanvas') {
|
||||||
this.finalizeCanvasResize();
|
this.finalizeCanvasResize();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user