Add selection subtracting to the node graph view (#3290)

Add selection subtracting for node graph
This commit is contained in:
Wade Cheng 2025-11-14 15:09:43 -05:00 committed by GitHub
parent 3871b6c4cf
commit 94414adaf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 4 deletions

View File

@ -969,7 +969,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
}
// Clicked on the graph background so we box select
if !shift_click {
if !shift_click && !alt_click {
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: Vec::new() })
}
self.box_selection_start = Some((node_graph_point, false));
@ -1925,12 +1925,13 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
.transform_point2(ipp.mouse.position);
let shift = ipp.keyboard.get(Key::Shift as usize);
let alt = ipp.keyboard.get(Key::Alt as usize);
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
log::error!("Could not get selected nodes in UpdateBoxSelection");
return;
};
let previous_selection = selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>();
let mut nodes = if shift {
let mut nodes = if shift || alt {
selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>()
} else {
HashSet::new()
@ -1943,9 +1944,13 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
};
let quad = Quad::from_box([box_selection_start, box_selection_end_graph]);
if click_targets.node_click_target.intersect_path(|| quad.to_lines(), DAffine2::IDENTITY) {
if alt {
nodes.remove(&node_id);
} else {
nodes.insert(node_id);
}
}
}
if nodes != previous_selection {
responses.add(NodeGraphMessage::SelectedNodesSet {
nodes: nodes.into_iter().collect::<Vec<_>>(),
@ -2738,7 +2743,11 @@ impl NodeGraphMessageHandler {
let mut hint_data = HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, "Add Node")]),
HintGroup(vec![HintInfo::mouse(MouseMotion::Lmb, "Select Node"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
]),
]);
if self.has_selection {
hint_data.0.extend([