mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Implemented history state for adding layers
This commit is contained in:
parent
8201099ad5
commit
74a8ee0988
@ -27,8 +27,24 @@ function HistoryStateMoveLayer() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function HistoryStateAddLayer() {
|
//TODO: finisci
|
||||||
|
function HistoryStateAddLayer(layerData) {
|
||||||
|
this.added = layerData;
|
||||||
|
|
||||||
|
this.undo = function() {
|
||||||
|
redoStates.push(this);
|
||||||
|
// un po' brutale onestamente
|
||||||
|
this.added.selectLayer();
|
||||||
|
deleteLayer();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
this.redo = function() {
|
||||||
|
undoStates.push(this);
|
||||||
|
addLayer();
|
||||||
|
};
|
||||||
|
|
||||||
|
saveHistoryState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//prototype for undoing canvas changes
|
//prototype for undoing canvas changes
|
||||||
@ -37,7 +53,6 @@ function HistoryStateEditCanvas () {
|
|||||||
this.layerID = currentLayer.id;
|
this.layerID = currentLayer.id;
|
||||||
|
|
||||||
this.undo = function () {
|
this.undo = function () {
|
||||||
console.log("id: " + this.layerID);
|
|
||||||
|
|
||||||
var stateLayer = getLayerByID(this.layerID);
|
var stateLayer = getLayerByID(this.layerID);
|
||||||
var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]);
|
var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]);
|
||||||
@ -50,7 +65,6 @@ function HistoryStateEditCanvas () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function () {
|
this.redo = function () {
|
||||||
console.log("id: " + this.layerID);
|
|
||||||
|
|
||||||
var stateLayer = getLayerByID(this.layerID);
|
var stateLayer = getLayerByID(this.layerID);
|
||||||
var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]);
|
var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]);
|
||||||
|
@ -518,4 +518,5 @@ function addLayer() {
|
|||||||
|
|
||||||
// Insert it before the Add layer button
|
// Insert it before the Add layer button
|
||||||
layerList.insertBefore(toAppend, layerList.childNodes[0]);
|
layerList.insertBefore(toAppend, layerList.childNodes[0]);
|
||||||
|
new HistoryStateAddLayer(newLayer);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user