From 4b55f3e0b4577dc3aa0b40d1a014f1b619c10b3e Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 28 Mar 2021 16:32:05 +0530 Subject: rework ModifyRecord to support operation kinds --- src/undo.rs | 29 +++++++++++++++-------------- 1 file 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 @@ -use crate::bitmap::MapPoint; +use crate::{bitmap::MapPoint, brush::Brush}; -#[derive(Copy, Clone, Debug)] -pub struct ModifyRecord { +#[derive(Debug, Clone)] +pub enum ModifyRecord { + Paint(Vec), + Invert, + Brush { old: Brush, new: Brush }, +} + +#[derive(Debug, Copy, Clone)] +pub struct PaintRecord { pub point: MapPoint, - pub old_val: bool, - pub val: bool, + pub old: bool, + pub new: bool, } -impl ModifyRecord { - pub fn new>(point: P, old_val: bool, val: bool) -> Self { - ModifyRecord { - point: point.into(), - old_val, - val, - } +impl PaintRecord { + pub fn new(point: MapPoint, old: bool, new: bool) -> Self { + Self { point, old, new } } } @@ -22,8 +25,6 @@ pub enum OpKind { Redo, } -pub type Operation = Vec; - #[derive(Debug)] pub struct UndoStack { operations: Vec, -- cgit v1.2.3