Divide Framework
0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
UndoManager.cpp
Go to the documentation of this file.
1
2
3
#include "
Headers/UndoManager.h
"
4
5
namespace
Divide
{
6
7
UndoManager::UndoManager
(
const
U32
maxSize)
8
: _maxSize(maxSize)
9
{
10
}
11
12
bool
UndoManager::Undo
() {
13
if
(!
_undoStack
.empty()) {
14
auto
entry
=
_undoStack
.back();
15
const
bool
ret =
apply
(
entry
);
16
_undoStack
.pop_back();
17
if
(ret) {
18
entry
->swapValues();
19
_redoStack
.push_back(
entry
);
20
}
21
return
ret;
22
}
23
24
return
false
;
25
}
26
27
bool
UndoManager::Redo
() {
28
if
(!
_redoStack
.empty()) {
29
auto
entry
=
_redoStack
.back();
30
const
bool
ret =
apply
(
entry
);
31
_redoStack
.pop_back();
32
if
(ret) {
33
entry
->swapValues();
34
_undoStack
.push_back(
entry
);
35
}
36
return
ret;
37
}
38
return
false
;
39
}
40
41
bool
UndoManager::apply
(
const
std::shared_ptr<IUndoEntry>&
entry
) {
42
if
(
entry
!=
nullptr
) {
43
entry
->apply();
44
_lastActionName
=
entry
->_name;
45
return
true
;
46
}
47
return
false
;
48
}
49
50
51
const
string
&
UndoManager::lasActionName
() const noexcept {
52
return
_lastActionName
;
53
}
54
55
}
//namespace Divide
UndoManager.h
Divide::UndoManager::lasActionName
const string & lasActionName() const noexcept
Definition:
UndoManager.cpp:51
Divide::UndoManager::apply
bool apply(const std::shared_ptr< IUndoEntry > &entry)
Definition:
UndoManager.cpp:41
Divide::UndoManager::_undoStack
UndoStack _undoStack
Definition:
UndoManager.h:100
Divide::UndoManager::UndoManager
UndoManager(U32 maxSize)
Definition:
UndoManager.cpp:7
Divide::UndoManager::Undo
bool Undo()
Definition:
UndoManager.cpp:12
Divide::UndoManager::Redo
bool Redo()
Definition:
UndoManager.cpp:27
Divide::UndoManager::_lastActionName
string _lastActionName
Definition:
UndoManager.h:102
Divide::UndoManager::_redoStack
UndoStack _redoStack
Definition:
UndoManager.h:101
Divide
Handle console commands that start with a forward slash.
Definition:
AIProcessor.cpp:7
Divide::U32
uint32_t U32
Definition:
PlatformDataTypes.h:46
Divide::entry
Project const SceneEntry & entry
Definition:
DefaultScene.h:41
Source
Editor
UndoManager.cpp
Generated on Fri May 17 2024 16:59:51 for Divide Framework by
1.9.6