Add "Exclude Layers" Ctrl modifier when dragging to box select in the node graph (#3665)

* Added Ctrl modifier that filters selection to include only child nodes

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Kulcode 2026-02-03 03:49:43 +05:30 committed by GitHub
parent 910fb54c15
commit ba361cdd6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 0 deletions

View File

@ -1958,6 +1958,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
let shift = ipp.keyboard.get(Key::Shift as usize);
let alt = ipp.keyboard.get(Key::Alt as usize);
let control = ipp.keyboard.get(Key::Control 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;
@ -1983,6 +1984,33 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
}
}
}
if control {
let mut non_layer_nodes = HashSet::new();
let layer_nodes = nodes.iter().filter(|node_id| network_interface.is_layer(node_id, selection_network_path));
for &layer_id in layer_nodes {
for child_id in network_interface.upstream_flow_back_from_nodes(vec![layer_id], selection_network_path, FlowType::LayerChildrenUpstreamFlow) {
if nodes.contains(&child_id) && child_id != layer_id {
non_layer_nodes.insert(child_id);
}
}
}
// Remove non-layer nodes from selection
if alt {
nodes = previous_selection.difference(&non_layer_nodes).cloned().collect();
}
// Add non-layer nodes to selection
else if shift {
nodes = previous_selection.union(&non_layer_nodes).cloned().collect();
}
// Replace selection with non-layer nodes
else {
nodes = non_layer_nodes;
}
}
if nodes != previous_selection {
responses.add(NodeGraphMessage::SelectedNodesSet {
nodes: nodes.into_iter().collect::<Vec<_>>(),
@ -2770,6 +2798,7 @@ impl NodeGraphMessageHandler {
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
HintInfo::keys([Key::Control], "Exclude Layers").prepend_plus(),
]),
]);
if self.has_selection {