diff --git a/editor/src/messages/input_mapper/input_mappings.rs b/editor/src/messages/input_mapper/input_mappings.rs index b75940bf09..4aaea7068c 100644 --- a/editor/src/messages/input_mapper/input_mappings.rs +++ b/editor/src/messages/input_mapper/input_mappings.rs @@ -212,7 +212,7 @@ pub fn input_mappings() -> Mapping { entry!(KeyDown(Delete); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath), entry!(KeyDown(Backspace); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath), entry!(KeyDownNoRepeat(Tab); action_dispatch=PathToolMessage::SwapSelectedHandles), - entry!(KeyDown(MouseLeft); action_dispatch=PathToolMessage::MouseDown { direct_insert_without_sliding: Control, extend_selection: Shift, lasso_select: Control, handle_drag_from_anchor: Alt }), + entry!(KeyDown(MouseLeft); action_dispatch=PathToolMessage::MouseDown { direct_insert_without_sliding: Control, extend_selection: Shift, lasso_select: Control, handle_drag_from_anchor: Alt, drag_zero_handle: Control }), entry!(KeyDown(MouseRight); action_dispatch=PathToolMessage::RightClick), entry!(KeyDown(Escape); action_dispatch=PathToolMessage::Escape), entry!(KeyDown(KeyG); action_dispatch=PathToolMessage::GRS { key: KeyG }), diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index db61db5221..60109f4be7 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -1384,13 +1384,13 @@ impl ShapeState { let (id, anchor) = result?; let handles = vector_data.all_connected(id); - let mut positions = handles + let positions = handles .filter_map(|handle| handle.to_manipulator_point().get_position(&vector_data)) - .filter(|&handle| !anchor.abs_diff_eq(handle, 1e-5)); + .filter(|&handle| anchor.abs_diff_eq(handle, 1e-5)) + .count(); // Check by comparing the handle positions to the anchor if this manipulator group is a point - let already_sharp = positions.next().is_none(); - if already_sharp { + if positions != 0 { self.convert_manipulator_handles_to_colinear(&vector_data, id, responses, layer); } else { for handle in vector_data.all_connected(id) { diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 3954bf96f6..8a80b738a1 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -68,6 +68,7 @@ pub enum PathToolMessage { extend_selection: Key, lasso_select: Key, handle_drag_from_anchor: Key, + drag_zero_handle: Key, }, NudgeSelectedPoints { delta_x: f64, @@ -498,6 +499,7 @@ impl PathToolData { direct_insert_without_sliding: bool, lasso_select: bool, handle_drag_from_anchor: bool, + drag_zero_handle: bool, ) -> PathToolFsmState { self.double_click_handled = false; self.opposing_handle_lengths = None; @@ -560,6 +562,24 @@ impl PathToolData { } } + if let Some((Some(point), Some(vector_data))) = shape_editor + .find_nearest_point_indices(&document.network_interface, input.mouse.position, SELECTION_THRESHOLD) + .and_then(|(layer, point)| Some((point.as_anchor(), document.network_interface.compute_modified_vector(layer)))) + { + let handles = vector_data + .all_connected(point) + .filter(|handle| handle.length(&vector_data) < 1e-6) + .map(|handle| handle.to_manipulator_point()) + .collect::>(); + let endpoint = vector_data.extendable_points(false).any(|anchor| point == anchor); + + if drag_zero_handle && (handles.len() == 1 && !endpoint) { + shape_editor.deselect_all_points(); + shape_editor.select_points_by_manipulator_id(&handles); + shape_editor.convert_selected_manipulators_to_colinear_handles(responses, document); + } + } + self.start_dragging_point(selected_points, input, document, shape_editor); responses.add(OverlaysMessage::Draw); } @@ -1160,12 +1180,14 @@ impl Fsm for PathToolFsmState { extend_selection, lasso_select, handle_drag_from_anchor, + drag_zero_handle, }, ) => { let extend_selection = input.keyboard.get(extend_selection as usize); let lasso_select = input.keyboard.get(lasso_select as usize); let direct_insert_without_sliding = input.keyboard.get(direct_insert_without_sliding as usize); let handle_drag_from_anchor = input.keyboard.get(handle_drag_from_anchor as usize); + let drag_zero_handle = input.keyboard.get(drag_zero_handle as usize); tool_data.selection_mode = None; tool_data.lasso_polygon.clear(); @@ -1179,6 +1201,7 @@ impl Fsm for PathToolFsmState { direct_insert_without_sliding, lasso_select, handle_drag_from_anchor, + drag_zero_handle, ) } ( @@ -1399,6 +1422,7 @@ impl Fsm for PathToolFsmState { tool_data.saved_points_before_handle_drag.clear(); tool_data.handle_drag_toggle = false; } + tool_data.angle_locked = false; responses.add(DocumentMessage::AbortTransaction); tool_data.snap_manager.cleanup(responses); PathToolFsmState::Ready @@ -1467,6 +1491,7 @@ impl Fsm for PathToolFsmState { tool_data.alt_dragging_from_anchor = false; tool_data.alt_clicked_on_anchor = false; + tool_data.angle_locked = false; if tool_data.select_anchor_toggled { shape_editor.deselect_all_points();