implement simple stroke undo based on actions history
This commit is contained in:
24
engine/action.h
Normal file
24
engine/action.h
Normal 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();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user