diff options
author | Akshay <[email protected]> | 2021-03-28 12:02:05 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-03-28 12:02:05 +0100 |
commit | 4b55f3e0b4577dc3aa0b40d1a014f1b619c10b3e (patch) | |
tree | 18bf39c38c85c287c67ad59e6e4829192863c12a /src | |
parent | f9dda0f77e018142cee46e2a9ccf7b03b5ab8f21 (diff) |
rework ModifyRecord to support operation kinds
Diffstat (limited to 'src')
-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>, |