@@ -411,12 +411,6 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
411411 Escape ,
412412 RightClick
413413 ) ,
414- PathToolFsmState :: MoldingSegment => actions ! ( PathToolMessageDiscriminant ;
415- PointerMove ,
416- DragStop ,
417- RightClick ,
418- Escape ,
419- ) ,
420414 }
421415 }
422416}
@@ -468,7 +462,6 @@ enum PathToolFsmState {
468462 selection_shape : SelectionShapeType ,
469463 } ,
470464 SlidingPoint ,
471- MoldingSegment ,
472465}
473466
474467#[ derive( Default ) ]
@@ -739,7 +732,7 @@ impl PathToolData {
739732 self . molding_info = Some ( ( pos1, pos2) )
740733 }
741734 }
742- PathToolFsmState :: MoldingSegment
735+ PathToolFsmState :: Dragging ( self . dragging_state )
743736 }
744737 }
745738 // If no other layers are selected and this is a single-click, then also select the layer (exception)
@@ -1573,7 +1566,6 @@ impl Fsm for PathToolFsmState {
15731566 }
15741567 }
15751568 Self :: SlidingPoint => { }
1576- Self :: MoldingSegment => { }
15771569 }
15781570
15791571 responses. add ( PathToolMessage :: SelectedPointUpdated ) ;
@@ -1678,20 +1670,33 @@ impl Fsm for PathToolFsmState {
16781670 break_colinear_molding,
16791671 } ,
16801672 ) => {
1673+ let selected_only_handles = !shape_editor. selected_points ( ) . any ( |point| matches ! ( point, ManipulatorPointId :: Anchor ( _) ) ) ;
16811674 tool_data. stored_selection = None ;
1682- let mut selected_only_handles = true ;
16831675
1684- let selected_points = shape_editor. selected_points ( ) ;
1676+ if !tool_data. saved_points_before_handle_drag . is_empty ( ) && ( tool_data. drag_start_pos . distance ( input. mouse . position ) > DRAG_THRESHOLD ) && ( selected_only_handles) {
1677+ tool_data. handle_drag_toggle = true ;
1678+ }
16851679
1686- for point in selected_points {
1687- if matches ! ( point, ManipulatorPointId :: Anchor ( _) ) {
1688- selected_only_handles = false ;
1689- break ;
1690- }
1680+ if tool_data. drag_start_pos . distance ( input. mouse . position ) > DRAG_THRESHOLD {
1681+ tool_data. molding_segment = true ;
16911682 }
16921683
1693- if !tool_data. saved_points_before_handle_drag . is_empty ( ) && ( tool_data. drag_start_pos . distance ( input. mouse . position ) > DRAG_THRESHOLD ) && ( selected_only_handles) {
1694- tool_data. handle_drag_toggle = true ;
1684+ let break_molding = input. keyboard . get ( break_colinear_molding as usize ) ;
1685+
1686+ // Logic for molding segment
1687+ if let Some ( segment) = & mut tool_data. segment {
1688+ if let Some ( molding_segment_handles) = tool_data. molding_info {
1689+ tool_data. temporary_adjacent_handles_while_molding = segment. mold_handle_positions (
1690+ document,
1691+ responses,
1692+ molding_segment_handles,
1693+ input. mouse . position ,
1694+ break_molding,
1695+ tool_data. temporary_adjacent_handles_while_molding ,
1696+ ) ;
1697+ }
1698+
1699+ return PathToolFsmState :: Dragging ( tool_data. dragging_state ) ;
16951700 }
16961701
16971702 let anchor_and_handle_toggled = input. keyboard . get ( move_anchor_with_handles as usize ) ;
@@ -1769,29 +1774,6 @@ impl Fsm for PathToolFsmState {
17691774 tool_data. slide_point ( input. mouse . position , responses, & document. network_interface , shape_editor) ;
17701775 PathToolFsmState :: SlidingPoint
17711776 }
1772- ( PathToolFsmState :: MoldingSegment , PathToolMessage :: PointerMove { break_colinear_molding, .. } ) => {
1773- if tool_data. drag_start_pos . distance ( input. mouse . position ) > DRAG_THRESHOLD {
1774- tool_data. molding_segment = true ;
1775- }
1776-
1777- let break_colinear_molding = input. keyboard . get ( break_colinear_molding as usize ) ;
1778-
1779- // Logic for molding segment
1780- if let Some ( segment) = & mut tool_data. segment {
1781- if let Some ( molding_segment_handles) = tool_data. molding_info {
1782- tool_data. temporary_adjacent_handles_while_molding = segment. mold_handle_positions (
1783- document,
1784- responses,
1785- molding_segment_handles,
1786- input. mouse . position ,
1787- break_colinear_molding,
1788- tool_data. temporary_adjacent_handles_while_molding ,
1789- ) ;
1790- }
1791- }
1792-
1793- PathToolFsmState :: MoldingSegment
1794- }
17951777 ( PathToolFsmState :: Ready , PathToolMessage :: PointerMove { delete_segment, .. } ) => {
17961778 tool_data. delete_segment_pressed = input. keyboard . get ( delete_segment as usize ) ;
17971779 tool_data. saved_points_before_anchor_convert_smooth_sharp . clear ( ) ;
@@ -1917,6 +1899,9 @@ impl Fsm for PathToolFsmState {
19171899 tool_data. saved_points_before_handle_drag . clear ( ) ;
19181900 tool_data. handle_drag_toggle = false ;
19191901 }
1902+ tool_data. molding_info = None ;
1903+ tool_data. molding_segment = false ;
1904+ tool_data. temporary_adjacent_handles_while_molding = None ;
19201905 tool_data. angle_locked = false ;
19211906 responses. add ( DocumentMessage :: AbortTransaction ) ;
19221907 tool_data. snap_manager . cleanup ( responses) ;
@@ -1934,17 +1919,6 @@ impl Fsm for PathToolFsmState {
19341919
19351920 PathToolFsmState :: Ready
19361921 }
1937- ( PathToolFsmState :: MoldingSegment , PathToolMessage :: Escape | PathToolMessage :: RightClick ) => {
1938- // Undo the molding and go back to the state before
1939- tool_data. molding_info = None ;
1940- tool_data. molding_segment = false ;
1941- tool_data. temporary_adjacent_handles_while_molding = None ;
1942-
1943- responses. add ( DocumentMessage :: AbortTransaction ) ;
1944- tool_data. snap_manager . cleanup ( responses) ;
1945-
1946- PathToolFsmState :: Ready
1947- }
19481922 // Mouse up
19491923 ( PathToolFsmState :: Drawing { selection_shape } , PathToolMessage :: DragStop { extend_selection, shrink_selection } ) => {
19501924 let extend_selection = input. keyboard . get ( extend_selection as usize ) ;
@@ -2672,48 +2646,49 @@ fn update_dynamic_hints(
26722646 dragging_hint_data. 0 . push ( HintGroup ( hold_group) ) ;
26732647 }
26742648
2675- dragging_hint_data
2676- }
2677- PathToolFsmState :: Drawing { .. } => HintData ( vec ! [
2678- HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Rmb , "" ) , HintInfo :: keys( [ Key :: Escape ] , "Cancel" ) . prepend_slash( ) ] ) ,
2679- HintGroup ( vec![
2680- HintInfo :: mouse( MouseMotion :: LmbDrag , "Select Area" ) ,
2681- HintInfo :: keys( [ Key :: Shift ] , "Extend" ) . prepend_plus( ) ,
2682- HintInfo :: keys( [ Key :: Alt ] , "Subtract" ) . prepend_plus( ) ,
2683- ] ) ,
2684- ] ) ,
2685- PathToolFsmState :: MoldingSegment => {
2686- let mut has_colinear_anchors = false ;
2649+ if tool_data. molding_segment {
2650+ let mut has_colinear_anchors = false ;
26872651
2688- if let Some ( segment) = & tool_data. segment {
2689- let handle1 = HandleId :: primary ( segment. segment ( ) ) ;
2690- let handle2 = HandleId :: end ( segment. segment ( ) ) ;
2652+ if let Some ( segment) = & tool_data. segment {
2653+ let handle1 = HandleId :: primary ( segment. segment ( ) ) ;
2654+ let handle2 = HandleId :: end ( segment. segment ( ) ) ;
26912655
2692- if let Some ( vector_data) = document. network_interface . compute_modified_vector ( segment. layer ( ) ) {
2693- let other_handle1 = vector_data. other_colinear_handle ( handle1) ;
2694- let other_handle2 = vector_data. other_colinear_handle ( handle2) ;
2695- if other_handle1. is_some ( ) || other_handle2. is_some ( ) {
2696- has_colinear_anchors = true ;
2697- }
2656+ if let Some ( vector_data) = document. network_interface . compute_modified_vector ( segment. layer ( ) ) {
2657+ let other_handle1 = vector_data. other_colinear_handle ( handle1) ;
2658+ let other_handle2 = vector_data. other_colinear_handle ( handle2) ;
2659+ if other_handle1. is_some ( ) || other_handle2. is_some ( ) {
2660+ has_colinear_anchors = true ;
2661+ }
2662+ } ;
2663+ }
2664+
2665+ let handles_stored = if let Some ( other_handles) = tool_data. temporary_adjacent_handles_while_molding {
2666+ other_handles[ 0 ] . is_some ( ) || other_handles[ 1 ] . is_some ( )
2667+ } else {
2668+ false
26982669 } ;
2699- }
27002670
2701- let handles_stored = if let Some ( other_handles) = tool_data. temporary_adjacent_handles_while_molding {
2702- other_handles[ 0 ] . is_some ( ) || other_handles[ 1 ] . is_some ( )
2703- } else {
2704- false
2705- } ;
2671+ let molding_disable_possible = has_colinear_anchors || handles_stored;
27062672
2707- let molding_disable_possible = has_colinear_anchors || handles_stored ;
2673+ let mut molding_hints = vec ! [ HintGroup ( vec! [ HintInfo :: mouse ( MouseMotion :: Rmb , "" ) , HintInfo :: keys ( [ Key :: Escape ] , "Cancel" ) . prepend_slash ( ) ] ) ] ;
27082674
2709- let mut molding_hints = vec ! [ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Rmb , "" ) , HintInfo :: keys( [ Key :: Escape ] , "Cancel" ) . prepend_slash( ) ] ) ] ;
2675+ if molding_disable_possible {
2676+ molding_hints. push ( HintGroup ( vec ! [ HintInfo :: keys( [ Key :: Alt ] , "Break Colinear Handles" ) ] ) ) ;
2677+ }
27102678
2711- if molding_disable_possible {
2712- molding_hints. push ( HintGroup ( vec ! [ HintInfo :: keys( [ Key :: Alt ] , "Break Colinear Handles" ) ] ) ) ;
2679+ HintData ( molding_hints)
2680+ } else {
2681+ dragging_hint_data
27132682 }
2714-
2715- HintData ( molding_hints)
27162683 }
2684+ PathToolFsmState :: Drawing { .. } => HintData ( vec ! [
2685+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Rmb , "" ) , HintInfo :: keys( [ Key :: Escape ] , "Cancel" ) . prepend_slash( ) ] ) ,
2686+ HintGroup ( vec![
2687+ HintInfo :: mouse( MouseMotion :: LmbDrag , "Select Area" ) ,
2688+ HintInfo :: keys( [ Key :: Shift ] , "Extend" ) . prepend_plus( ) ,
2689+ HintInfo :: keys( [ Key :: Alt ] , "Subtract" ) . prepend_plus( ) ,
2690+ ] ) ,
2691+ ] ) ,
27172692 PathToolFsmState :: SlidingPoint => HintData ( vec ! [ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Rmb , "" ) , HintInfo :: keys( [ Key :: Escape ] , "Cancel" ) . prepend_slash( ) ] ) ] ) ,
27182693 } ;
27192694 responses. add ( FrontendMessage :: UpdateInputHints { hint_data } ) ;
0 commit comments