Fix Path tool behavior with Shift-dragging an already selected point, where it wrongly got deselected (#2395)

* Send path tool FSM to Dragging state on MouseDown if clicking selected point

* Cleanup

* Store selected point state before new selection is made and setup deselect logic

* update previously saved point data on every point selection

* Decide whether to deselect or select on extended_select if node not already selected,  when DragStop state is reached instead of inside the  mouse_down function.

* Fix broken merge and remove leftover debug statements

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Utsav Singh
2025-04-17 02:57:56 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent bd1c0ff287
commit 7cb16a8bec
2 changed files with 63 additions and 9 deletions
@@ -388,6 +388,37 @@ impl ShapeState {
None
}
pub fn get_point_selection_state(&mut self, network_interface: &NodeNetworkInterface, mouse_position: DVec2, select_threshold: f64) -> Option<(bool, Option<SelectedPointsInfo>)> {
if self.selected_shape_state.is_empty() {
return None;
}
if let Some((layer, manipulator_point_id)) = self.find_nearest_point_indices(network_interface, mouse_position, select_threshold) {
let vector_data = network_interface.compute_modified_vector(layer)?;
let point_position = manipulator_point_id.get_position(&vector_data)?;
let selected_shape_state = self.selected_shape_state.get(&layer)?;
let already_selected = selected_shape_state.is_selected(manipulator_point_id);
// Offset to snap the selected point to the cursor
let offset = mouse_position - network_interface.document_metadata().transform_to_viewport(layer).transform_point2(point_position);
// Gather current selection information
let points = self
.selected_shape_state
.iter()
.flat_map(|(layer, state)| state.selected_points.iter().map(|&point_id| ManipulatorPointInfo { layer: *layer, point_id }))
.collect();
let selection_info = SelectedPointsInfo { points, offset, vector_data };
// Return the current selection state and info
return Some((already_selected, Some(selection_info)));
}
None
}
pub fn select_anchor_point_by_id(&mut self, layer: LayerNodeIdentifier, id: PointId, extend_selection: bool) {
if !extend_selection {
self.deselect_all_points();