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:
parent
128f76af7e
commit
a1f2a2b256
|
|
@ -364,6 +364,7 @@ mod test {
|
|||
nodes: HashMap::new(),
|
||||
parent: LayerNodeIdentifier::ROOT,
|
||||
insert_index: -1,
|
||||
alias: String::new(),
|
||||
});
|
||||
editor.handle_message(NodeGraphMessage::SelectedNodesSet { nodes: vec![FOLDER_ID] });
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
};
|
||||
|
||||
let node = layer.to_node();
|
||||
let previous_alias = active_document.network().nodes.get(&node).map(|node| node.alias.clone()).unwrap_or_default();
|
||||
|
||||
let Some(node) = active_document.network().nodes.get(&node).and_then(|node| node.inputs.first()).and_then(|input| input.as_node()) else {
|
||||
continue;
|
||||
};
|
||||
|
|
@ -197,6 +199,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
.collect(),
|
||||
selected: active_document.selected_nodes.selected_layers_contains(layer, active_document.metadata()),
|
||||
collapsed: false,
|
||||
alias: previous_alias,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -375,6 +378,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
nodes: entry.nodes.clone(),
|
||||
parent,
|
||||
insert_index,
|
||||
alias: entry.alias.clone(),
|
||||
});
|
||||
if entry.selected {
|
||||
responses.add(NodeGraphMessage::SelectedNodesAdd { nodes: vec![id] });
|
||||
|
|
@ -408,6 +412,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
nodes: entry.nodes,
|
||||
parent,
|
||||
insert_index: -1,
|
||||
alias: entry.alias,
|
||||
});
|
||||
if entry.selected {
|
||||
responses.add(NodeGraphMessage::SelectedNodesAdd { nodes: vec![id] });
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ fn new_brush_layer(document: &DocumentMessageHandler, responses: &mut VecDeque<M
|
|||
nodes: HashMap::from([(NodeId(0), brush_node)]),
|
||||
parent: document.new_layer_parent(),
|
||||
insert_index: -1,
|
||||
alias: String::new(),
|
||||
});
|
||||
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![id] });
|
||||
|
||||
|
|
|
|||
|
|
@ -341,7 +341,13 @@ impl SelectToolData {
|
|||
let id = NodeId(generate_uuid());
|
||||
let insert_index = -1;
|
||||
let layer = LayerNodeIdentifier::new_unchecked(id);
|
||||
responses.add(GraphOperationMessage::NewCustomLayer { id, nodes, parent, insert_index });
|
||||
responses.add(GraphOperationMessage::NewCustomLayer {
|
||||
id,
|
||||
nodes,
|
||||
parent,
|
||||
insert_index,
|
||||
alias: String::new(),
|
||||
});
|
||||
new_dragging.push(layer);
|
||||
}
|
||||
let nodes = new_dragging.iter().map(|layer| layer.to_node()).collect();
|
||||
|
|
|
|||
Loading…
Reference in New Issue