mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 19:28:12 +08:00
Drag to rearrange layers in the layer panel (#434)
* Add insert line * Implement dragging * Improve CSS and variable naming consistency * Resolved folder crash, added Undo/Redo support * Removed marker TODO leftover * JS cleanup * WIP preserving expanded state (via LayerData) when copy/pasting and moving layers in layer panel * Finish making folders copy/paste preserving expanded state, but not recursively yet * Add cut, copy, and paste to the Edit menu (#440) * Add cut * Hook up edit dropdown * Use copy message Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: otdavies <oliver@psyfer.io>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
otdavies
parent
b87b527566
commit
1a70667f63
@@ -490,11 +490,16 @@ impl Document {
|
||||
responses.extend(update_thumbnails_upstream(folder));
|
||||
Some(responses)
|
||||
}
|
||||
Operation::PasteLayer { path, layer, insert_index } => {
|
||||
let folder = self.folder_mut(path)?;
|
||||
let id = folder.add_layer(layer.clone(), None, *insert_index).ok_or(DocumentError::IndexOutOfBounds)?;
|
||||
let full_path = [path.clone(), vec![id]].concat();
|
||||
self.mark_as_dirty(&full_path)?;
|
||||
Operation::InsertLayer {
|
||||
destination_path,
|
||||
layer,
|
||||
insert_index,
|
||||
} => {
|
||||
let (folder_path, layer_id) = split_path(destination_path)?;
|
||||
let folder = self.folder_mut(folder_path)?;
|
||||
folder.add_layer(layer.clone(), Some(layer_id), *insert_index).ok_or(DocumentError::IndexOutOfBounds)?;
|
||||
self.mark_as_dirty(destination_path)?;
|
||||
|
||||
fn aggregate_insertions(folder: &Folder, path: &mut Vec<LayerId>, responses: &mut Vec<DocumentResponse>) {
|
||||
for (id, layer) in folder.layer_ids.iter().zip(folder.layers()) {
|
||||
path.push(*id);
|
||||
@@ -505,13 +510,14 @@ impl Document {
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
|
||||
let mut responses = Vec::new();
|
||||
if let Ok(folder) = self.folder(&full_path) {
|
||||
aggregate_insertions(folder, &mut full_path.clone(), &mut responses)
|
||||
if let Ok(folder) = self.folder(destination_path) {
|
||||
aggregate_insertions(folder, &mut destination_path.clone(), &mut responses)
|
||||
};
|
||||
|
||||
responses.extend([DocumentChanged, CreatedLayer { path: full_path }, FolderChanged { path: path.clone() }]);
|
||||
responses.extend(update_thumbnails_upstream(path));
|
||||
responses.extend([DocumentChanged, CreatedLayer { path: destination_path.clone() }, FolderChanged { path: folder_path.to_vec() }]);
|
||||
responses.extend(update_thumbnails_upstream(destination_path));
|
||||
Some(responses)
|
||||
}
|
||||
Operation::DuplicateLayer { path } => {
|
||||
|
||||
@@ -76,9 +76,9 @@ pub enum Operation {
|
||||
path: Vec<LayerId>,
|
||||
name: String,
|
||||
},
|
||||
PasteLayer {
|
||||
InsertLayer {
|
||||
layer: Layer,
|
||||
path: Vec<LayerId>,
|
||||
destination_path: Vec<LayerId>,
|
||||
insert_index: isize,
|
||||
},
|
||||
CreateFolder {
|
||||
|
||||
Reference in New Issue
Block a user