Add batch preview manager and mask overlay toggle

Introduces BatchPreviewManager for reviewing and confirming multiple imported layers after auto-refresh. Adds a toggle button for mask overlay visibility in the UI and updates mask rendering logic to respect overlay visibility. Also refactors image import to return new layers and adds a utility for removing layers by ID.
This commit is contained in:
Dariusz L
2025-07-03 02:22:51 +02:00
parent 3419061b6c
commit 9f9a733731
7 changed files with 222 additions and 7 deletions

View File

@@ -765,6 +765,7 @@ export class CanvasIO {
if (result.success && result.images && result.images.length > 0) {
log.info(`Received ${result.images.length} new images, adding to canvas.`);
const newLayers = [];
for (const imageData of result.images) {
const img = new Image();
@@ -773,14 +774,15 @@ export class CanvasIO {
img.onerror = reject;
img.src = imageData;
});
await this.canvas.canvasLayers.addLayerWithImage(img, {}, 'fit');
const newLayer = await this.canvas.canvasLayers.addLayerWithImage(img, {}, 'fit');
newLayers.push(newLayer);
}
log.info("All new images imported and placed on canvas successfully.");
return true;
return newLayers;
} else if (result.success) {
log.info("No new images found since last generation.");
return true;
return [];
}
else {
throw new Error(result.error || "Failed to fetch latest images.");
@@ -788,7 +790,7 @@ export class CanvasIO {
} catch (error) {
log.error("Error importing latest images:", error);
alert(`Failed to import latest images: ${error.message}`);
return false;
return [];
}
}
}