Skip to content

Commit 7a9a822

Browse files
committed
remove lasso_selection_curr drag flag and extraneous comments
1 parent 0a86749 commit 7a9a822

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

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

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ pub struct NodeGraphMessageHandler {
6464
pub drag_start_chain_nodes: Vec<NodeId>,
6565
/// If dragging the background to create a box selection, this stores its starting point in node graph coordinates,
6666
/// plus a flag indicating if it has been dragged since the mousedown began.
67+
/// (We should only update hints when it has been dragged after the initial mousedown.)
6768
box_selection_start: Option<(DVec2, bool)>,
68-
/// If dragging the background to create a lasso selection, this stores its current lasso polygon in node graph coordinates,
69-
/// plus a flag indicating if it has been dragged since the mousedown began.
70-
lasso_selection_curr: Option<(Vec<DVec2>, bool)>,
69+
/// If dragging the background to create a lasso selection, this stores its current lasso polygon in node graph coordinates.
70+
/// Notice that it has been dragged since the mousedown began iff the polygon has at least two points.
71+
/// (We should only update hints when it has been dragged after the initial mousedown.)
72+
lasso_selection_curr: Option<Vec<DVec2>>,
7173
/// Restore the selection before box selection if it is aborted
7274
selection_before_pointer_down: Vec<NodeId>,
7375
/// If the grip icon is held during a drag, then shift without pushing other nodes
@@ -989,7 +991,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
989991
}
990992

991993
if control_click {
992-
self.lasso_selection_curr = Some((vec![node_graph_point], false));
994+
self.lasso_selection_curr = Some(vec![node_graph_point]);
993995
} else {
994996
self.box_selection_start = Some((node_graph_point, false));
995997
}
@@ -1128,8 +1130,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
11281130
*box_selection_dragged = true;
11291131
responses.add(NodeGraphMessage::UpdateBoxSelection);
11301132
self.update_node_graph_hints(responses);
1131-
} else if let Some((_, lasso_selection_dragged)) = &mut self.lasso_selection_curr {
1132-
*lasso_selection_dragged = true;
1133+
} else if self.lasso_selection_curr.is_some() {
11331134
responses.add(NodeGraphMessage::UpdateLassoSelection);
11341135
self.update_node_graph_hints(responses);
11351136
} else if self.reordering_import.is_some() {
@@ -1921,15 +1922,6 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19211922
}
19221923
NodeGraphMessage::UpdateBoxSelection => {
19231924
if let Some((box_selection_start, _)) = self.box_selection_start {
1924-
// The mouse button was released but we missed the pointer up event
1925-
// if ((e.buttons & 1) === 0) {
1926-
// completeBoxSelection();
1927-
// boxSelection = undefined;
1928-
// } else if ((e.buttons & 2) !== 0) {
1929-
// editor.handle.selectNodes(new BigUint64Array(previousSelection));
1930-
// boxSelection = undefined;
1931-
// }
1932-
19331925
let Some(network_metadata) = network_interface.network_metadata(selection_network_path) else {
19341926
log::error!("Could not get network metadata in UpdateBoxSelection");
19351927
return;
@@ -1986,17 +1978,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19861978
}
19871979
}
19881980
NodeGraphMessage::UpdateLassoSelection => {
1989-
if let Some((lasso_selection_curr, _)) = &mut self.lasso_selection_curr {
1990-
// WARNING WARNING WARNING: this commented-out code is copy pasted from UpdateBoxSelection above and has not been edited for lasso
1991-
// The mouse button was released but we missed the pointer up event
1992-
// if ((e.buttons & 1) === 0) {
1993-
// completeBoxSelection();
1994-
// boxSelection = undefined;
1995-
// } else if ((e.buttons & 2) !== 0) {
1996-
// editor.handle.selectNodes(new BigUint64Array(previousSelection));
1997-
// boxSelection = undefined;
1998-
// }
1999-
1981+
if let Some(lasso_selection_curr) = &mut self.lasso_selection_curr {
20001982
let Some(network_metadata) = network_interface.network_metadata(selection_network_path) else {
20011983
log::error!("Could not get network metadata in UpdateBoxSelection");
20021984
return;
@@ -2824,7 +2806,7 @@ impl NodeGraphMessageHandler {
28242806

28252807
// A box or lasso selection is in progress
28262808
let dragging_selection = self.box_selection_start.as_ref().is_some_and(|(_, box_selection_dragged)| *box_selection_dragged)
2827-
|| self.lasso_selection_curr.as_ref().is_some_and(|(_, lasso_selection_dragged)| *lasso_selection_dragged);
2809+
|| self.lasso_selection_curr.as_ref().is_some_and(|lasso_selection| lasso_selection.len() >= 2);
28282810

28292811
// Cancel the ongoing action
28302812
if wiring || dragging_nodes || dragging_selection {

0 commit comments

Comments
 (0)