diff options
-rw-r--r-- | src/app.rs | 7 | ||||
-rw-r--r-- | src/cache.rs | 4 |
2 files changed, 7 insertions, 4 deletions
@@ -86,7 +86,7 @@ impl<'ctx> AppState<'ctx> { | |||
86 | pub fn cache(&self) { | 86 | pub fn cache(&self) { |
87 | let mut cache = self.cache.borrow_mut(); | 87 | let mut cache = self.cache.borrow_mut(); |
88 | *cache = Some(Cache { | 88 | *cache = Some(Cache { |
89 | last_brush_size: self.brush.size().unwrap_or(0), | 89 | last_brush: self.brush, |
90 | }); | 90 | }); |
91 | } | 91 | } |
92 | 92 | ||
@@ -228,6 +228,7 @@ impl<'ctx> AppState<'ctx> { | |||
228 | } | 228 | } |
229 | } | 229 | } |
230 | ModifyRecord::Invert => self.pixmap.invert(), | 230 | ModifyRecord::Invert => self.pixmap.invert(), |
231 | // TODO: use this kind of modify record on brush change | ||
231 | ModifyRecord::Brush { old, new } => { | 232 | ModifyRecord::Brush { old, new } => { |
232 | match op_kind { | 233 | match op_kind { |
233 | OpKind::Undo => self.brush = old, | 234 | OpKind::Undo => self.brush = old, |
@@ -765,7 +766,7 @@ impl<'ctx> AppState<'ctx> { | |||
765 | self.cache | 766 | self.cache |
766 | .borrow() | 767 | .borrow() |
767 | .as_ref() | 768 | .as_ref() |
768 | .map(|c| c.last_brush_size) | 769 | .map(|c| c.last_brush.size().unwrap_or(0)) |
769 | .unwrap_or(0), | 770 | .unwrap_or(0), |
770 | true, | 771 | true, |
771 | ); | 772 | ); |
@@ -780,7 +781,7 @@ impl<'ctx> AppState<'ctx> { | |||
780 | self.cache | 781 | self.cache |
781 | .borrow() | 782 | .borrow() |
782 | .as_ref() | 783 | .as_ref() |
783 | .map(|c| c.last_brush_size) | 784 | .map(|c| c.last_brush.size().unwrap_or(0)) |
784 | .unwrap_or(0), | 785 | .unwrap_or(0), |
785 | ); | 786 | ); |
786 | } | 787 | } |
diff --git a/src/cache.rs b/src/cache.rs index 249eca9..f25d274 100644 --- a/src/cache.rs +++ b/src/cache.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | use crate::brush::Brush; | ||
2 | |||
1 | pub struct Cache { | 3 | pub struct Cache { |
2 | pub last_brush_size: u8, | 4 | pub last_brush: Brush, |
3 | } | 5 | } |