Fix layers losing their names upon being grouped (#1637)

* no message

* no message

* no message

* Make layers reserve their names when grouped

* remove redundancy

* replace String::from("") with String::new()

* Fix test

* Restore unrequested line break changes

* Avoid unwraps

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Mohamed Osama
2024-03-02 23:34:25 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 128f76af7e
commit a1f2a2b256
8 changed files with 36 additions and 3 deletions
@@ -370,6 +370,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
nodes: HashMap::new(),
parent,
insert_index: -1,
alias: String::new(),
});
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![id] });
}
@@ -423,7 +424,13 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
let id = NodeId(generate_uuid());
let insert_index = -1;
responses.add(GraphOperationMessage::NewCustomLayer { id, nodes, parent, insert_index });
responses.add(GraphOperationMessage::NewCustomLayer {
id,
nodes,
parent,
insert_index,
alias: String::new(),
});
}
}
FlipSelectedLayers { flip_axis } => {
@@ -501,6 +508,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
nodes: HashMap::new(),
parent,
insert_index: calculated_insert_index.unwrap_or(-1),
alias: String::new(),
});
responses.add(PortfolioMessage::PasteIntoFolder {
clipboard: Clipboard::Internal,
@@ -81,6 +81,7 @@ pub enum GraphOperationMessage {
nodes: HashMap<NodeId, DocumentNode>,
parent: LayerNodeIdentifier,
insert_index: isize,
alias: String,
},
NewVectorLayer {
id: NodeId,
@@ -670,7 +670,13 @@ impl MessageHandler<GraphOperationMessage, GraphOperationHandlerData<'_>> for Gr
modify_inputs.insert_image_data(image_frame, layer);
}
}
GraphOperationMessage::NewCustomLayer { id, nodes, parent, insert_index } => {
GraphOperationMessage::NewCustomLayer {
id,
nodes,
parent,
insert_index,
alias,
} => {
trace!("Inserting new layer {id} as a child of {parent:?} at index {insert_index}");
let mut modify_inputs = ModifyInputsContext::new(document_network, document_metadata, node_graph, responses);
@@ -678,6 +684,10 @@ impl MessageHandler<GraphOperationMessage, GraphOperationHandlerData<'_>> for Gr
if let Some(layer) = modify_inputs.create_layer_with_insert_index(id, insert_index, parent) {
let new_ids: HashMap<_, _> = nodes.iter().map(|(&id, _)| (id, NodeId(generate_uuid()))).collect();
if let Some(node) = modify_inputs.document_network.nodes.get_mut(&id) {
node.alias = alias.clone();
}
let shift = nodes
.get(&NodeId(0))
.and_then(|node| {
@@ -21,4 +21,5 @@ pub struct CopyBufferEntry {
pub nodes: HashMap<NodeId, DocumentNode>,
pub selected: bool,
pub collapsed: bool,
pub alias: String,
}