Skip to content

Commit

Permalink
TransformCommand: split undo/redo keyframe resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Apr 22, 2024
1 parent 79ec18b commit 1857aae
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions core_lib/src/interface/undoredocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,40 +147,54 @@ TransformCommand::TransformCommand(KeyFrame* undoKeyFrame,
this->undoScaleX = undoScaleX;
this->undoScaleY = undoScaleY;

Layer* redoLayer = editor->layers()->currentLayer();
redoLayerId = redoLayer->id();
Layer* undoLayer = editor->layers()->findLayerById(undoLayerId);

auto selectMan = editor->select();
redoSelectionRect = selectMan->mySelectionRect();
redoAnchor = selectMan->currentTransformAnchor();
redoTranslation = selectMan->myTranslation();
redoRotationAngle = selectMan->myRotation();
redoScaleX = selectMan->myScaleX();
redoScaleY = selectMan->myScaleY();
switch(undoLayer->type())
{
case Layer::BITMAP:
{
undoBitmap = *static_cast<BitmapImage*>(undoKeyFrame);
break;
}
case Layer::VECTOR:
{
undoVector = *static_cast<VectorImage*>(undoKeyFrame);
break;
}
default:
break;
}

Layer* layer = editor->layers()->findLayerById(undoLayerId);
Layer* redoLayer = editor->layers()->currentLayer();
redoLayerId = redoLayer->id();

// TODO: this could become a bug.. should we check layer type for undo and redo layer respectively?
const int currentFrame = editor->currentFrame();
switch(layer->type())

switch(redoLayer->type())
{
case Layer::BITMAP:
{
undoBitmap = *static_cast<BitmapImage*>(undoKeyFrame);
redoBitmap = *static_cast<LayerBitmap*>(layer)->getBitmapImageAtFrame(currentFrame);
redoBitmap = *static_cast<LayerBitmap*>(redoLayer)->getBitmapImageAtFrame(currentFrame);
break;
}
case Layer::VECTOR:
{
undoVector = *static_cast<VectorImage*>(undoKeyFrame);
redoVector = *static_cast<LayerVector*>(layer)->
redoVector = *static_cast<LayerVector*>(redoLayer)->
getVectorImageAtFrame(currentFrame);
break;
}
default:
break;
}

auto selectMan = editor->select();
redoSelectionRect = selectMan->mySelectionRect();
redoAnchor = selectMan->currentTransformAnchor();
redoTranslation = selectMan->myTranslation();
redoRotationAngle = selectMan->myRotation();
redoScaleX = selectMan->myScaleX();
redoScaleY = selectMan->myScaleY();

setText(description);
}

Expand Down

0 comments on commit 1857aae

Please sign in to comment.