Add saveState calls after layer modifications

Added calls to saveState() after scaling, rotating, and removing layers to ensure changes are properly recorded in the undo/redo history. Also refactored the matting button UI for better layout and ensured saveState is called after matting results are applied.
This commit is contained in:
Dariusz L
2025-06-24 17:30:32 +02:00
parent 3922572315
commit 64550609b8
2 changed files with 76 additions and 63 deletions

View File

@@ -1111,6 +1111,7 @@ export class Canvas {
layer.height *= scale;
});
this.render();
this.saveState();
}
rotateLayer(angle) {
@@ -1118,6 +1119,7 @@ export class Canvas {
layer.rotation += angle;
});
this.render();
this.saveState();
}
updateCanvasSize(width, height, saveHistory = true) {

View File

@@ -487,9 +487,11 @@ async function createCanvasWidget(node, widget, app) {
textContent: "Remove Layer",
onclick: () => {
if (canvas.selectedLayers.length > 0) {
canvas.saveState();
canvas.layers = canvas.layers.filter(l => !canvas.selectedLayers.includes(l));
canvas.updateSelection([]);
canvas.render();
canvas.saveState();
}
}
}),
@@ -548,10 +550,17 @@ async function createCanvasWidget(node, widget, app) {
disabled: true,
onclick: () => canvas.redo()
}),
$el("div", {
style: {
display: "flex",
alignItems: "center",
gap: "8px"
}
}, [
$el("button.painter-button.requires-selection.matting-button", {
textContent: "Matting",
onclick: async () => {
const statusIndicator = MattingStatusIndicator.getInstance(controlPanel.querySelector('.controls'));
onclick: async (e) => {
const statusIndicator = MattingStatusIndicator.getInstance(e.target.parentElement);
try {
if (canvas.selectedLayers.length !== 1) {
@@ -593,6 +602,7 @@ async function createCanvasWidget(node, widget, app) {
canvas.layers.push(newLayer);
canvas.updateSelection([newLayer]);
canvas.render();
canvas.saveState();
await canvas.saveToServer(widget.value);
app.graph.runStep();
@@ -611,7 +621,8 @@ async function createCanvasWidget(node, widget, app) {
statusIndicator.setStatus('error');
}
}
}),
})
]),
$el("button.painter-button", {
textContent: "Clear Cache",
style: {