@@ -287,6 +287,8 @@ struct PathToolData {
287
287
drag_start_pos : DVec2 ,
288
288
previous_mouse_position : DVec2 ,
289
289
toggle_colinear_debounce : bool ,
290
+ equidistant_colinear_debounce : bool ,
291
+ original_handle_colinear : bool ,
290
292
opposing_handle_lengths : Option < OpposingHandleLengths > ,
291
293
/// Describes information about the selected point(s), if any, across one or multiple shapes and manipulator point types (anchor or handle).
292
294
/// The available information varies depending on whether `None`, `One`, or `Multiple` points are currently selected.
@@ -471,6 +473,28 @@ impl PathToolData {
471
473
false
472
474
}
473
475
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
+
474
498
/// 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.
475
499
fn try_get_selected_handle_and_anchor ( & self , shape_editor : & ShapeState , document : & DocumentMessageHandler ) -> Option < ( DVec2 , DVec2 ) > {
476
500
let ( layer, selection) = shape_editor. selected_shape_state . iter ( ) . next ( ) ?; // Only count selections of a single layer
@@ -567,6 +591,8 @@ impl PathToolData {
567
591
shape_editor. snap ( & mut self . snap_manager , & self . snap_cache , document, input, previous_mouse)
568
592
} ;
569
593
594
+ self . update_equidistant_handle_collinearity ( equidistant, shape_editor, document, responses) ;
595
+
570
596
let handle_lengths = if equidistant { None } else { self . opposing_handle_lengths . take ( ) } ;
571
597
shape_editor. move_selected_points ( handle_lengths, document, snapped_delta, equidistant, responses, true ) ;
572
598
self . previous_mouse_position += document_to_viewport. inverse ( ) . transform_vector2 ( snapped_delta) ;
0 commit comments