diff options
-rw-r--r-- | src/undo.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/undo.rs b/src/undo.rs index ae96a66..1044c63 100644 --- a/src/undo.rs +++ b/src/undo.rs | |||
@@ -1,19 +1,22 @@ | |||
1 | use crate::bitmap::MapPoint; | 1 | use crate::{bitmap::MapPoint, brush::Brush}; |
2 | 2 | ||
3 | #[derive(Copy, Clone, Debug)] | 3 | #[derive(Debug, Clone)] |
4 | pub struct ModifyRecord { | 4 | pub enum ModifyRecord { |
5 | Paint(Vec<PaintRecord>), | ||
6 | Invert, | ||
7 | Brush { old: Brush, new: Brush }, | ||
8 | } | ||
9 | |||
10 | #[derive(Debug, Copy, Clone)] | ||
11 | pub struct PaintRecord { | ||
5 | pub point: MapPoint, | 12 | pub point: MapPoint, |
6 | pub old_val: bool, | 13 | pub old: bool, |
7 | pub val: bool, | 14 | pub new: bool, |
8 | } | 15 | } |
9 | 16 | ||
10 | impl ModifyRecord { | 17 | impl PaintRecord { |
11 | pub fn new<P: Into<MapPoint>>(point: P, old_val: bool, val: bool) -> Self { | 18 | pub fn new(point: MapPoint, old: bool, new: bool) -> Self { |
12 | ModifyRecord { | 19 | Self { point, old, new } |
13 | point: point.into(), | ||
14 | old_val, | ||
15 | val, | ||
16 | } | ||
17 | } | 20 | } |
18 | } | 21 | } |
19 | 22 | ||
@@ -22,8 +25,6 @@ pub enum OpKind { | |||
22 | Redo, | 25 | Redo, |
23 | } | 26 | } |
24 | 27 | ||
25 | pub type Operation = Vec<ModifyRecord>; | ||
26 | |||
27 | #[derive(Debug)] | 28 | #[derive(Debug)] |
28 | pub struct UndoStack<T> { | 29 | pub struct UndoStack<T> { |
29 | operations: Vec<T>, | 30 | operations: Vec<T>, |