mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 07:28:12 +08:00
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:
co-authored by
Keavon Chambers
parent
910fb54c15
commit
ba361cdd6a
@@ -1958,6 +1958,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
|||||||
|
|
||||||
let shift = ipp.keyboard.get(Key::Shift as usize);
|
let shift = ipp.keyboard.get(Key::Shift as usize);
|
||||||
let alt = ipp.keyboard.get(Key::Alt 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 {
|
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
|
||||||
log::error!("Could not get selected nodes in UpdateBoxSelection");
|
log::error!("Could not get selected nodes in UpdateBoxSelection");
|
||||||
return;
|
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 {
|
if nodes != previous_selection {
|
||||||
responses.add(NodeGraphMessage::SelectedNodesSet {
|
responses.add(NodeGraphMessage::SelectedNodesSet {
|
||||||
nodes: nodes.into_iter().collect::<Vec<_>>(),
|
nodes: nodes.into_iter().collect::<Vec<_>>(),
|
||||||
@@ -2770,6 +2798,7 @@ impl NodeGraphMessageHandler {
|
|||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
|
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
|
||||||
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
|
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
|
||||||
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
|
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
|
||||||
|
HintInfo::keys([Key::Control], "Exclude Layers").prepend_plus(),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
if self.has_selection {
|
if self.has_selection {
|
||||||
|
|||||||
Reference in New Issue
Block a user