Make duplicating folders also duplicate its children (#1178)

* Latest changes

* Add layer attempt

* layer tree is now correct after duplicating layers

* Latest changes

* Latest Changes

* Recursive idea

* Moving Layers to Dup Folder - not done

* latest changes

* latest progress

* Latest Changes

* Latest Changes

* Latest Changes

* Latest

* Latest

* Latest

* Duplicating Folders works

* Initial Refactoring

* Ready for QA

* Doesn't select all the children after duplicate anymore

* First pass code review with major cleanup

* Removed unused next_asssignment_id function and updated FolderLayer struct

* Removed unused logic

* First iteration of cleaning up the code

* Added Ollie's suggestions

* Code review cleanup

---------

Co-authored-by: Ollie Dolan <olliedolan10@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Christopher Mendoza
2023-05-19 00:41:16 -07:00
committed by Keavon Chambers
parent 6400953af5
commit bb1e7c44cf
7 changed files with 250 additions and 33 deletions

View File

@@ -124,11 +124,23 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
for response in document_responses {
match &response {
DocumentResponse::FolderChanged { path } => responses.add(FolderChanged { affected_folder_path: path.clone() }),
DocumentResponse::AddSelectedLayer { additional_layers } => responses.add(AddSelectedLayers {
additional_layers: additional_layers.clone(),
}),
DocumentResponse::DeletedLayer { path } => {
self.layer_metadata.remove(path);
}
DocumentResponse::LayerChanged { path } => responses.add(LayerChanged { affected_layer_path: path.clone() }),
DocumentResponse::CreatedLayer { path } => {
DocumentResponse::MoveSelectedLayersTo {
folder_path,
insert_index,
reverse_index,
} => responses.add(MoveSelectedLayersTo {
folder_path: folder_path.clone(),
insert_index: insert_index.clone(),
reverse_index: reverse_index.clone(),
}),
DocumentResponse::CreatedLayer { path, is_selected } => {
if self.layer_metadata.contains_key(path) {
warn!("CreatedLayer overrides existing layer metadata.");
}
@@ -136,9 +148,12 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
responses.add(LayerChanged { affected_layer_path: path.clone() });
self.layer_range_selection_reference = path.clone();
responses.add(AddSelectedLayers {
additional_layers: vec![path.clone()],
});
if *is_selected {
responses.add(AddSelectedLayers {
additional_layers: vec![path.clone()],
});
}
}
DocumentResponse::DocumentChanged => responses.add(RenderDocument),
DocumentResponse::DeletedSelectedManipulatorPoints => {
@@ -272,7 +287,10 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
let id = generate_uuid();
container_path.push(id);
responses.add(DocumentMessage::DeselectAllLayers);
responses.add(DocumentOperation::CreateFolder { path: container_path.clone() });
responses.add(DocumentOperation::CreateFolder {
path: container_path.clone(),
insert_index: -1,
});
responses.add(DocumentMessage::SetLayerExpansion {
layer_path: container_path,
set_expanded: true,
@@ -417,6 +435,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
responses.add(DocumentOperation::ClearBlobURL { path: layer_path.into() });
}
GroupSelectedLayers => {
// TODO: Add code that changes the insert index of the new folder based on the selected layer
let mut new_folder_path = self.document_legacy.shallowest_common_folder(self.selected_layers()).unwrap_or(&[]).to_vec();
// Required for grouping parent folders with their own children
@@ -428,7 +447,10 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
responses.add(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
responses.add(DocumentMessage::DeleteSelectedLayers);
responses.add(DocumentOperation::CreateFolder { path: new_folder_path.clone() });
responses.add(DocumentOperation::CreateFolder {
path: new_folder_path.clone(),
insert_index: -1,
});
responses.add(DocumentMessage::ToggleLayerExpansion { layer_path: new_folder_path.clone() });
responses.add(PortfolioMessage::PasteIntoFolder {
clipboard: Clipboard::Internal,

View File

@@ -395,6 +395,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
layer: Box::new(entry.layer.clone()),
destination_path,
insert_index,
duplicating: false,
});
}
};
@@ -431,6 +432,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
layer: Box::new(entry.layer.clone()),
destination_path,
insert_index: -1,
duplicating: false,
});
}

View File

@@ -368,6 +368,7 @@ impl SelectToolData {
layer: Box::new(layer),
destination_path: layer_path.clone(),
insert_index: -1,
duplicating: false,
});
responses.add(DocumentMessage::UpdateLayerMetadata {
layer_path: layer_path.clone(),
@@ -1219,8 +1220,6 @@ fn edit_layer_deepest_manipulation(intersect: &Layer, responses: &mut VecDeque<M
}
fn recursive_search(document: &DocumentMessageHandler, layer_path: &Vec<u64>, incoming_layer_path_vector: &Vec<u64>) -> bool {
// TODO: fix below, then QA
// DOUBLE CLICK BROKEN
let layer_paths = document.document_legacy.folder_children_paths(layer_path);
for path in layer_paths {
if path == *incoming_layer_path_vector {