Fix sprite position after undoing/redoing a move/copy timeline range operation

This commit is contained in:
David Capello 2019-04-01 20:35:50 -03:00
parent f3bb1ecdf1
commit c0b4224f32
4 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -38,7 +39,7 @@ void CmdTransaction::setNewDocRange(const DocRange& range)
#endif
}
void CmdTransaction::commit()
void CmdTransaction::updateSpritePositionAfter()
{
m_spritePositionAfter = calcSpritePosition();

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -25,7 +26,7 @@ namespace app {
bool changeSavedState, int* savedCounter);
void setNewDocRange(const DocRange& range);
void commit();
void updateSpritePositionAfter();
SpritePosition spritePositionBeforeExecute() const { return m_spritePositionBefore; }
SpritePosition spritePositionAfterExecute() const { return m_spritePositionAfter; }

View File

@ -87,7 +87,7 @@ void Transaction::commit()
ASSERT(m_cmds);
TX_TRACE("TX: Commit <%s>\n", m_cmds->label().c_str());
m_cmds->commit();
m_cmds->updateSpritePositionAfter();
m_undo->add(m_cmds);
m_cmds = nullptr;

View File

@ -13,6 +13,7 @@
#include "app/app.h"
#include "app/app_menus.h"
#include "app/cmd_transaction.h"
#include "app/color_utils.h"
#include "app/commands/command.h"
#include "app/commands/commands.h"
@ -3725,6 +3726,12 @@ void Timeline::dropRange(DropOp op)
!m_sprite->frameTags().empty()) {
invalidateRect(getFrameHeadersBounds().offset(origin()));
}
// Update the sprite position after the command was executed
// TODO improve this workaround
Cmd* cmd = m_document->undoHistory()->lastExecutedCmd();
if (auto cmdTx = dynamic_cast<CmdTransaction*>(cmd))
cmdTx->updateSpritePositionAfter();
}
catch (const std::exception& ex) {
Console::showException(ex);