1// Aseprite
2// Copyright (C) 2001-2016 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifndef APP_UI_EDITOR_STATES_HISTORY_H_INCLUDED
8#define APP_UI_EDITOR_STATES_HISTORY_H_INCLUDED
9#pragma once
10
11#include "app/ui/editor/editor_state.h"
12
13#include <vector>
14
15namespace app {
16
17 // Stack of states in the editor. The top state is the current state
18 // of the editor.
19 class EditorStatesHistory {
20 public:
21 EditorStatesHistory();
22 ~EditorStatesHistory();
23
24 bool empty() const { return m_states.empty(); }
25
26 // Gets the current state.
27 EditorStatePtr top();
28
29 // Adds a new state in the history.
30 void push(const EditorStatePtr& state);
31
32 // Removes a state from the history (you should keep a reference of
33 // the state with top() if you want to keep it in memory).
34 void pop();
35
36 // Deletes all the history.
37 void clear();
38
39 private:
40 // Stack of states (the back of the vector is the top of the stack).
41 std::vector<EditorStatePtr> m_states;
42 };
43
44} // namespace app
45
46#endif
47