Don't swap same frame on reverse_frames()

This commit is contained in:
David Capello 2016-07-11 09:58:43 -03:00
parent 48798b0fc5
commit 991b248940

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -353,6 +353,7 @@ void reverse_frames(Document* doc, const DocumentRange& range)
frame_t frameBegin, frameEnd;
int layerBegin, layerEnd;
bool moveFrames = false;
bool swapCels = false;
switch (range.type()) {
case DocumentRange::kCels:
@ -360,6 +361,7 @@ void reverse_frames(Document* doc, const DocumentRange& range)
frameEnd = range.frameEnd();
layerBegin = range.layerBegin();
layerEnd = range.layerEnd() + 1;
swapCels = true;
break;
case DocumentRange::kFrames:
frameBegin = range.frameBegin();
@ -371,6 +373,7 @@ void reverse_frames(Document* doc, const DocumentRange& range)
frameEnd = sprite->totalFrames()-1;
layerBegin = range.layerBegin();
layerEnd = range.layerEnd() + 1;
swapCels = true;
break;
}
@ -381,7 +384,7 @@ void reverse_frames(Document* doc, const DocumentRange& range)
api.moveFrame(sprite, frameBegin, frameRev);
}
}
else {
else if (swapCels) {
std::vector<Layer*> layers;
sprite->getLayersList(layers);
@ -390,6 +393,9 @@ void reverse_frames(Document* doc, const DocumentRange& range)
frameRev = frameEnd;
frame != (frameBegin+frameEnd)/2+1;
++frame, --frameRev) {
if (frame == frameRev)
continue;
LayerImage* layer = static_cast<LayerImage*>(layers[layerIdx]);
api.swapCel(layer, frame, frameRev);
}