Skip to content

Commit 71abd5f

Browse files
wade-chengKeavon
authored andcommitted
Add selection subtracting for node graph
1 parent 3871b6c commit 71abd5f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
969969
}
970970

971971
// Clicked on the graph background so we box select
972-
if !shift_click {
972+
if !shift_click && !alt_click {
973973
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: Vec::new() })
974974
}
975975
self.box_selection_start = Some((node_graph_point, false));
@@ -1925,12 +1925,13 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19251925
.transform_point2(ipp.mouse.position);
19261926

19271927
let shift = ipp.keyboard.get(Key::Shift as usize);
1928+
let alt = ipp.keyboard.get(Key::Alt as usize);
19281929
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
19291930
log::error!("Could not get selected nodes in UpdateBoxSelection");
19301931
return;
19311932
};
19321933
let previous_selection = selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>();
1933-
let mut nodes = if shift {
1934+
let mut nodes = if shift || alt {
19341935
selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>()
19351936
} else {
19361937
HashSet::new()
@@ -1943,7 +1944,11 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19431944
};
19441945
let quad = Quad::from_box([box_selection_start, box_selection_end_graph]);
19451946
if click_targets.node_click_target.intersect_path(|| quad.to_lines(), DAffine2::IDENTITY) {
1946-
nodes.insert(node_id);
1947+
if alt {
1948+
nodes.remove(&node_id);
1949+
} else {
1950+
nodes.insert(node_id);
1951+
}
19471952
}
19481953
}
19491954
if nodes != previous_selection {
@@ -2738,7 +2743,11 @@ impl NodeGraphMessageHandler {
27382743
let mut hint_data = HintData(vec![
27392744
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, "Add Node")]),
27402745
HintGroup(vec![HintInfo::mouse(MouseMotion::Lmb, "Select Node"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
2741-
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
2746+
HintGroup(vec![
2747+
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
2748+
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
2749+
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
2750+
]),
27422751
]);
27432752
if self.has_selection {
27442753
hint_data.0.extend([

0 commit comments

Comments
 (0)