@@ -287,6 +287,8 @@ struct PathToolData {
287287 drag_start_pos : DVec2 ,
288288 previous_mouse_position : DVec2 ,
289289 toggle_colinear_debounce : bool ,
290+ equidistant_colinear_debounce : bool ,
291+ original_handle_colinear : bool ,
290292 opposing_handle_lengths : Option < OpposingHandleLengths > ,
291293 /// Describes information about the selected point(s), if any, across one or multiple shapes and manipulator point types (anchor or handle).
292294 /// The available information varies depending on whether `None`, `One`, or `Multiple` points are currently selected.
@@ -471,6 +473,28 @@ impl PathToolData {
471473 false
472474 }
473475
476+ /// Temporarily converts selected handles to colinear if they are not already colinear.
477+ fn update_equidistant_handle_collinearity ( & mut self , equidistant : bool , shape_editor : & mut ShapeState , document : & DocumentMessageHandler , responses : & mut VecDeque < Message > ) {
478+ match ( equidistant, self . equidistant_colinear_debounce ) {
479+ ( true , false ) => {
480+ let current_angle = shape_editor. selected_manipulator_angles ( & document. network_interface ) ;
481+ self . original_handle_colinear = current_angle == ManipulatorAngle :: Colinear ;
482+
483+ if !self . original_handle_colinear {
484+ shape_editor. convert_selected_manipulators_to_colinear_handles ( responses, document) ;
485+ }
486+ self . equidistant_colinear_debounce = true ;
487+ }
488+ ( false , true ) => {
489+ if !self . original_handle_colinear {
490+ shape_editor. disable_colinear_handles_state_on_selected ( & document. network_interface , responses) ;
491+ }
492+ self . equidistant_colinear_debounce = false ;
493+ }
494+ _ => { }
495+ }
496+ }
497+
474498 /// Attempts to get a single selected handle. Also retrieves the position of the anchor it is connected to. Used for the purpose of snapping the angle.
475499 fn try_get_selected_handle_and_anchor ( & self , shape_editor : & ShapeState , document : & DocumentMessageHandler ) -> Option < ( DVec2 , DVec2 ) > {
476500 let ( layer, selection) = shape_editor. selected_shape_state . iter ( ) . next ( ) ?; // Only count selections of a single layer
@@ -567,6 +591,8 @@ impl PathToolData {
567591 shape_editor. snap ( & mut self . snap_manager , & self . snap_cache , document, input, previous_mouse)
568592 } ;
569593
594+ self . update_equidistant_handle_collinearity ( equidistant, shape_editor, document, responses) ;
595+
570596 let handle_lengths = if equidistant { None } else { self . opposing_handle_lengths . take ( ) } ;
571597 shape_editor. move_selected_points ( handle_lengths, document, snapped_delta, equidistant, responses, true ) ;
572598 self . previous_mouse_position += document_to_viewport. inverse ( ) . transform_vector2 ( snapped_delta) ;
0 commit comments