mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +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
@@ -11,6 +11,7 @@ pub enum DocumentMessage {
|
||||
SelectLayers(Vec<Vec<LayerId>>),
|
||||
DeleteLayer(Vec<LayerId>),
|
||||
DeleteSelectedLayers,
|
||||
DuplicateSelectedLayers,
|
||||
AddFolder(Vec<LayerId>),
|
||||
RenameLayer(Vec<LayerId>, String),
|
||||
ToggleLayerVisibility(Vec<LayerId>),
|
||||
@@ -160,6 +161,11 @@ impl MessageHandler<DocumentMessage, ()> for DocumentMessageHandler {
|
||||
responses.push_back(DocumentOperation::DeleteLayer { path }.into())
|
||||
}
|
||||
}
|
||||
DuplicateSelectedLayers => {
|
||||
for path in self.active_document().layer_data.iter().filter_map(|(path, data)| data.selected.then(|| path.clone())) {
|
||||
responses.push_back(DocumentOperation::DuplicateLayer { path }.into())
|
||||
}
|
||||
}
|
||||
SelectLayers(paths) => {
|
||||
self.clear_selection();
|
||||
for path in paths {
|
||||
@@ -208,7 +214,7 @@ impl MessageHandler<DocumentMessage, ()> for DocumentMessageHandler {
|
||||
}
|
||||
fn actions(&self) -> ActionList {
|
||||
if self.active_document().layer_data.values().any(|data| data.selected) {
|
||||
actions!(DocumentMessageDiscriminant; Undo, DeleteSelectedLayers, RenderDocument, ExportDocument, NewDocument, NextDocument, PrevDocument)
|
||||
actions!(DocumentMessageDiscriminant; Undo, DeleteSelectedLayers, DuplicateSelectedLayers, RenderDocument, ExportDocument, NewDocument, NextDocument, PrevDocument)
|
||||
} else {
|
||||
actions!(DocumentMessageDiscriminant; Undo, RenderDocument, ExportDocument, NewDocument, NextDocument, PrevDocument)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user