mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 01:28:12 +08:00
Implement Undo and Redo (#354)
* Implement undo and redo * Create more save points and hook up menu entry * Fix operation ordering * Remove debug statement * Fix folder changed order * Don't store overlays in the history chain * Keep selection
This commit is contained in:
committed by
Keavon Chambers
parent
47fbb8d0fa
commit
0ccb181e2c
@@ -272,6 +272,24 @@ impl Document {
|
||||
self.set_transform_relative_to_scope(layer, None, transform)
|
||||
}
|
||||
|
||||
fn remove_overlays(&mut self, path: &mut Vec<LayerId>) {
|
||||
if self.layer(path).unwrap().overlay {
|
||||
self.delete(path).unwrap()
|
||||
}
|
||||
let ids = self.folder(path).map(|folder| folder.layer_ids.clone()).unwrap_or_default();
|
||||
for id in ids {
|
||||
path.push(id);
|
||||
self.remove_overlays(path);
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clone_without_overlays(&self) -> Self {
|
||||
let mut document = self.clone();
|
||||
document.remove_overlays(&mut vec![]);
|
||||
document
|
||||
}
|
||||
|
||||
/// Mutate the document by applying the `operation` to it. If the operation necessitates a
|
||||
/// reaction from the frontend, responses may be returned.
|
||||
pub fn handle_operation(&mut self, operation: &Operation) -> Result<Option<Vec<DocumentResponse>>, DocumentError> {
|
||||
|
||||
Reference in New Issue
Block a user