Place new layers in tree based on layer selection (#526)

* place new layers based on layer selection
This commit is contained in:
Wuelle
2022-02-09 19:54:38 +01:00
committed by Keavon Chambers
parent cb9a37b638
commit cc66ab06b0
9 changed files with 18 additions and 7 deletions

View File

@@ -462,6 +462,16 @@ impl DocumentMessageHandler {
self.artboard_message_handler.artboards_graphene_document.viewport_bounding_box(&[]).ok().flatten()
}
}
/// Calculate the path that new layers should be inserted to.
/// Depends on the selected layers as well as their types (Folder/Non-Folder)
pub fn get_path_for_new_layer(&self) -> Vec<u64> {
// If the selected layers dont actually exist, a new uuid for the
// root folder will be returned
let mut path = self.graphene_document.shallowest_common_folder(self.selected_layers()).map_or(vec![], |v| v.to_vec());
path.push(generate_uuid());
path
}
}
impl PropertyHolder for DocumentMessageHandler {