Selection Manager : fix undo/redo regression

This commit is contained in:
jdescottes 2015-08-15 17:08:09 +02:00
parent 4e1f6bee3f
commit ff98670055

View File

@ -95,12 +95,7 @@
var pixels = this.currentSelection.pixels; var pixels = this.currentSelection.pixels;
var frame = this.piskelController.getCurrentFrame(); var frame = this.piskelController.getCurrentFrame();
pixels.forEach(function (pixel) { this.pastePixels_(frame, pixels);
if (pixel.color === Constants.TRANSPARENT_COLOR || pixel.color === null) {
return;
}
frame.setPixel(pixel.col, pixel.row, pixel.color);
});
$.publish(Events.PISKEL_SAVE_STATE, { $.publish(Events.PISKEL_SAVE_STATE, {
type : pskl.service.HistoryService.REPLAY, type : pskl.service.HistoryService.REPLAY,
@ -113,9 +108,21 @@
}; };
ns.SelectionManager.prototype.replay = function (frame, replayData) { ns.SelectionManager.prototype.replay = function (frame, replayData) {
replayData.pixels.forEach(function (pixel) { if (replayData.type === SELECTION_REPLAY.PASTE) {
var color = replayData.type === SELECTION_REPLAY.PASTE ? pixel.color : Constants.TRANSPARENT_COLOR; this.pastePixels_(frame, replayData.pixels);
frame.setPixel(pixel.col, pixel.row, color); } else if (replayData.type === SELECTION_REPLAY.ERASE) {
replayData.pixels.forEach(function (pixel) {
frame.setPixel(pixel.col, pixel.row, Constants.TRANSPARENT_COLOR);
});
}
};
ns.SelectionManager.prototype.pastePixels_ = function(frame, pixels) {
pixels.forEach(function (pixel) {
if (pixel.color === Constants.TRANSPARENT_COLOR || pixel.color === null) {
return;
}
frame.setPixel(pixel.col, pixel.row, pixel.color);
}); });
}; };