Skip to content

Commit 773ce48

Browse files
Send path tool FSM to Dragging state on MouseDown if clicking selected point
1 parent c4cf477 commit 773ce48

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

editor/src/messages/tool/tool_messages/path_tool.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::messages::portfolio::document::utility_types::network_interface::Node
1010
use crate::messages::preferences::SelectionMode;
1111
use crate::messages::tool::common_functionality::auto_panning::AutoPanning;
1212
use crate::messages::tool::common_functionality::shape_editor::{
13-
ClosestSegment, ManipulatorAngle, OpposingHandleLengths, SelectedPointsInfo, SelectionChange, SelectionShape, SelectionShapeType, ShapeState,
13+
ClosestSegment, ManipulatorAngle, ManipulatorPointInfo, OpposingHandleLengths, SelectedPointsInfo, SelectionChange, SelectionShape, SelectionShapeType, ShapeState,
1414
};
1515
use crate::messages::tool::common_functionality::snapping::{SnapCache, SnapCandidatePoint, SnapConstraint, SnapData, SnapManager};
1616

@@ -479,7 +479,37 @@ impl PathToolData {
479479
self.drag_start_pos = input.mouse.position;
480480

481481
let old_selection = shape_editor.selected_points().cloned().collect::<Vec<_>>();
482+
// Check if clicking on an already selected point
483+
if let Some((layer, nearest_point)) = shape_editor.find_nearest_point_indices(&document.network_interface, input.mouse.position, SELECTION_THRESHOLD) {
484+
let clicked_selected = shape_editor.selected_points().any(|&point| nearest_point == point);
482485

486+
// If clicking on an already selected point, don't change selection
487+
// Instead, start dragging immediately
488+
if clicked_selected {
489+
responses.add(DocumentMessage::StartTransaction);
490+
491+
// Get the vector data for the current layer
492+
let vector_data = document.network_interface.compute_modified_vector(layer).unwrap();
493+
494+
// Create a SelectedPointsInfo with all currently selected points
495+
let points = shape_editor
496+
.selected_shape_state
497+
.iter()
498+
.flat_map(|(layer, state)| state.selected().map(|point_id| ManipulatorPointInfo { layer: *layer, point_id }))
499+
.collect();
500+
501+
// Offset is distance between point and cursor ( in this case it is zero )
502+
let offset = DVec2 { x: 0.0, y: 0.0 };
503+
504+
let selected_points = SelectedPointsInfo { points, offset, vector_data };
505+
506+
// Start dragging without changing selection
507+
self.start_dragging_point(selected_points, input, document, shape_editor);
508+
responses.add(OverlaysMessage::Draw);
509+
510+
return PathToolFsmState::Dragging(self.dragging_state);
511+
}
512+
}
483513
// Select the first point within the threshold (in pixels)
484514
if let Some(selected_points) = shape_editor.change_point_selection(&document.network_interface, input.mouse.position, SELECTION_THRESHOLD, extend_selection) {
485515
responses.add(DocumentMessage::StartTransaction);

0 commit comments

Comments
 (0)