aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-03-28 12:02:05 +0100
committerAkshay <[email protected]>2021-03-28 12:02:05 +0100
commit4b55f3e0b4577dc3aa0b40d1a014f1b619c10b3e (patch)
tree18bf39c38c85c287c67ad59e6e4829192863c12a /src
parentf9dda0f77e018142cee46e2a9ccf7b03b5ab8f21 (diff)
rework ModifyRecord to support operation kinds
Diffstat (limited to 'src')
-rw-r--r--src/undo.rs29
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 @@
1use crate::bitmap::MapPoint; 1use crate::{bitmap::MapPoint, brush::Brush};
2 2
3#[derive(Copy, Clone, Debug)] 3#[derive(Debug, Clone)]
4pub struct ModifyRecord { 4pub enum ModifyRecord {
5 Paint(Vec<PaintRecord>),
6 Invert,
7 Brush { old: Brush, new: Brush },
8}
9
10#[derive(Debug, Copy, Clone)]
11pub 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
10impl ModifyRecord { 17impl 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
25pub type Operation = Vec<ModifyRecord>;
26
27#[derive(Debug)] 28#[derive(Debug)]
28pub struct UndoStack<T> { 29pub struct UndoStack<T> {
29 operations: Vec<T>, 30 operations: Vec<T>,