Fix : Loading state with delete frame/layer

The Frame and Layer selected after an undo/redo are now taken from the
next state saved in the HistoryQueue.
This commit is contained in:
jdescottes 2014-05-17 11:03:18 +02:00
parent 7cbf2b2794
commit c7c536dc80
3 changed files with 14 additions and 9 deletions

View File

@ -224,11 +224,13 @@
this.selectLayer(layer);
};
ns.PiskelController.prototype.removeCurrentLayer = function () {
ns.PiskelController.prototype.removeLayerAt = function (index) {
if (this.getLayers().length > 1) {
var layer = this.getCurrentLayer();
this.piskel.removeLayer(layer);
this.setCurrentLayerIndex(0);
var layer = this.getLayerAt(index);
if (layer) {
this.piskel.removeLayer(layer);
this.setCurrentLayerIndex(0);
}
}
};

View File

@ -123,13 +123,14 @@
};
ns.PublicPiskelController.prototype.removeCurrentLayer = function () {
this.raiseSaveStateEvent_(this.piskelController.removeCurrentLayer, []);
this.piskelController.removeCurrentLayer();
var currentLayerIndex = this.getCurrentLayerIndex();
this.raiseSaveStateEvent_(this.piskelController.removeLayerAt, [currentLayerIndex]);
this.piskelController.removeLayerAt(currentLayerIndex);
$.publish(Events.PISKEL_RESET);
};
ns.PublicPiskelController.prototype.getCurrentLayerIndex = function () {
return this.piskelController.currentLayerIndex;
return this.piskelController.getCurrentLayerIndex();
};
ns.PublicPiskelController.prototype.getCurrentFrameIndex = function () {

View File

@ -110,8 +110,10 @@
this.replayState(state);
}
var lastState = this.stateQueue[index];
this.setupState(lastState);
var lastState = this.stateQueue[index+1];
if (lastState) {
this.setupState(lastState);
}
this.currentIndex = index;
$.publish(Events.PISKEL_RESET);
if (originalSize !== this.getPiskelSize_()) {