diff --git a/js/_history.js b/js/_history.js index e0597fb..3adb15a 100644 --- a/js/_history.js +++ b/js/_history.js @@ -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 @@ -37,7 +53,6 @@ function HistoryStateEditCanvas () { this.layerID = currentLayer.id; this.undo = function () { - console.log("id: " + this.layerID); var stateLayer = getLayerByID(this.layerID); var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); @@ -50,7 +65,6 @@ function HistoryStateEditCanvas () { }; this.redo = function () { - console.log("id: " + this.layerID); var stateLayer = getLayerByID(this.layerID); var currentCanvas = stateLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); diff --git a/js/_layer.js b/js/_layer.js index bb77d6d..1c9a840 100644 --- a/js/_layer.js +++ b/js/_layer.js @@ -518,4 +518,5 @@ function addLayer() { // Insert it before the Add layer button layerList.insertBefore(toAppend, layerList.childNodes[0]); + new HistoryStateAddLayer(newLayer); } \ No newline at end of file