implement action redo

This commit is contained in:
2018-05-10 22:32:34 +02:00
parent f31e22631a
commit 4f55b477da
6 changed files with 66 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ ActionManager ActionManager::I;
void ActionManager::add(Action *action)
{
I.m_redos = std::stack<std::unique_ptr<Action>>();
I.m_actions.emplace(action);
I.m_memory += action->memory();
//LOG("History: %.2f KB", I.m_memory / 1024.f);
@@ -15,6 +16,11 @@ void ActionManager::add(Action *action)
void ActionManager::undo()
{
if (I.m_actions.empty())
return;
I.m_redos.emplace(I.m_actions.top()->get_redo());
I.m_actions.top()->undo();
I.m_memory -= I.m_actions.top()->memory();
I.m_actions.pop();
@@ -22,6 +28,20 @@ void ActionManager::undo()
App::I.update_memory_usage(I.m_memory);
}
void ActionManager::redo()
{
if (I.m_redos.empty())
return;
I.m_actions.emplace(I.m_redos.top()->get_redo());
I.m_memory += I.m_actions.top()->memory();
I.m_redos.top()->undo();
I.m_redos.pop();
//LOG("History: %.2f KB", I.m_memory / 1024.f);
App::I.update_memory_usage(I.m_memory);
}
void ActionManager::clear()
{
while (!I.m_actions.empty())