implement simple stroke undo based on actions history

This commit is contained in:
2017-04-16 01:57:54 +02:00
parent 357f37e3d0
commit 28fe61704f
10 changed files with 95 additions and 9 deletions

24
engine/action.h Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
class Action
{
public:
virtual void run() = 0;
virtual void undo() = 0;
};
class ActionManager
{
public:
static ActionManager I;
std::stack<std::unique_ptr<Action>> m_actions;
static void add(Action* action)
{
I.m_actions.emplace(action);
}
static void undo()
{
I.m_actions.top()->undo();
I.m_actions.pop();
}
};