mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Add keyboard shortcut to duplicate layers (#214)
* Add keyboard shortcut to duplicate layers * Avoid heap allocation in DuplicateSelectedLayers
This commit is contained in:
committed by
Keavon Chambers
parent
310db82ab4
commit
ff232bd722
@@ -248,6 +248,13 @@ impl Document {
|
||||
let (path, _) = split_path(path.as_slice()).unwrap_or_else(|_| (&[], 0));
|
||||
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path: path.to_vec() }])
|
||||
}
|
||||
Operation::DuplicateLayer { path } => {
|
||||
let layer = self.layer(&path)?.clone();
|
||||
let (folder_path, _) = split_path(path.as_slice()).unwrap_or_else(|_| (&[], 0));
|
||||
let folder = self.folder_mut(folder_path)?;
|
||||
folder.add_layer(layer, -1).ok_or(DocumentError::IndexOutOfBounds)?;
|
||||
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path: folder_path.to_vec() }])
|
||||
}
|
||||
Operation::AddFolder { path } => {
|
||||
self.set_layer(&path, Layer::new(LayerDataTypes::Folder(Folder::default())))?;
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ pub enum Operation {
|
||||
DeleteLayer {
|
||||
path: Vec<LayerId>,
|
||||
},
|
||||
DuplicateLayer {
|
||||
path: Vec<LayerId>,
|
||||
},
|
||||
AddFolder {
|
||||
path: Vec<LayerId>,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user