aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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>,