@@ -70,6 +70,7 @@ pub enum PathToolMessage {
7070 lasso_select : Key ,
7171 handle_drag_from_anchor : Key ,
7272 drag_restore_handle : Key ,
73+ molding_in_segment_edit : Key ,
7374 } ,
7475 NudgeSelectedPoints {
7576 delta_x : f64 ,
@@ -542,6 +543,7 @@ impl PathToolData {
542543 lasso_select : bool ,
543544 handle_drag_from_anchor : bool ,
544545 drag_zero_handle : bool ,
546+ molding_in_segment_edit : bool ,
545547 path_overlay_mode : PathOverlayMode ,
546548 segment_editing_mode : bool ,
547549 point_editing_mode : bool ,
@@ -655,7 +657,7 @@ impl PathToolData {
655657 else if let Some ( segment) = shape_editor. upper_closest_segment ( & document. network_interface , input. mouse . position , SELECTION_THRESHOLD ) {
656658 responses. add ( DocumentMessage :: StartTransaction ) ;
657659
658- if segment_editing_mode {
660+ if segment_editing_mode && !molding_in_segment_edit {
659661 let layer = segment. layer ( ) ;
660662 let segment_id = segment. segment ( ) ;
661663 let already_selected = shape_editor. selected_shape_state . get ( & layer) . map_or ( false , |state| state. is_selected_segment ( segment_id) ) ;
@@ -1333,7 +1335,7 @@ impl Fsm for PathToolFsmState {
13331335 fn transition ( self , event : ToolMessage , tool_data : & mut Self :: ToolData , tool_action_data : & mut ToolActionHandlerData , tool_options : & Self :: ToolOptions , responses : & mut VecDeque < Message > ) -> Self {
13341336 let ToolActionHandlerData { document, input, shape_editor, .. } = tool_action_data;
13351337
1336- update_dynamic_hints ( self , responses, shape_editor, document, tool_data) ;
1338+ update_dynamic_hints ( self , responses, shape_editor, document, tool_data, tool_options ) ;
13371339
13381340 let ToolMessage :: Path ( event) = event else { return self } ;
13391341 match ( self , event) {
@@ -1423,8 +1425,6 @@ impl Fsm for PathToolFsmState {
14231425 let Some ( selected_shape_state) = shape_editor. selected_shape_state . get_mut ( & layer) else {
14241426 continue ;
14251427 } ;
1426- // let selected_segments = selected_shape_state.selected_segments().collect::<Vec<_>>();
1427- // log::info!("selected segments are: {:?}", selected_segments);
14281428 if selected_shape_state. is_selected_segment ( segment_id) {
14291429 overlay_context. outline_select_bezier ( bezier, transform) ;
14301430 }
@@ -1436,7 +1436,6 @@ impl Fsm for PathToolFsmState {
14361436 tool_data. update_closest_segment ( shape_editor, input. mouse . position , document, tool_options. path_overlay_mode ) ;
14371437
14381438 if let Some ( closest_segment) = & tool_data. segment {
1439- //Do this only when the segment editing mode is turned off
14401439 if tool_options. path_editing_mode . segment_editing_mode {
14411440 let transform = document. metadata ( ) . transform_to_viewport ( closest_segment. layer ( ) ) ;
14421441 overlay_context. outline_overlay_bezier ( closest_segment. bezier ( ) , transform) ;
@@ -1477,7 +1476,7 @@ impl Fsm for PathToolFsmState {
14771476 let polygon = & tool_data. lasso_polygon ;
14781477
14791478 match ( selection_shape, selection_mode, tool_data. started_drawing_from_inside ) {
1480- // Don't draw this if it is from inside a shape and selection just began
1479+ // Don't draw box if it is from inside a shape and selection just began
14811480 ( SelectionShapeType :: Box , SelectionMode :: Enclosed , false ) => overlay_context. dashed_quad ( quad, None , fill_color, Some ( 4. ) , Some ( 4. ) , Some ( 0.5 ) ) ,
14821481 ( SelectionShapeType :: Lasso , SelectionMode :: Enclosed , _) => overlay_context. dashed_polygon ( polygon, None , fill_color, Some ( 4. ) , Some ( 4. ) , Some ( 0.5 ) ) ,
14831482 ( SelectionShapeType :: Box , _, false ) => overlay_context. quad ( quad, None , fill_color) ,
@@ -1528,12 +1527,14 @@ impl Fsm for PathToolFsmState {
15281527 lasso_select,
15291528 handle_drag_from_anchor,
15301529 drag_restore_handle,
1530+ molding_in_segment_edit,
15311531 } ,
15321532 ) => {
15331533 let extend_selection = input. keyboard . get ( extend_selection as usize ) ;
15341534 let lasso_select = input. keyboard . get ( lasso_select as usize ) ;
15351535 let handle_drag_from_anchor = input. keyboard . get ( handle_drag_from_anchor as usize ) ;
15361536 let drag_zero_handle = input. keyboard . get ( drag_restore_handle as usize ) ;
1537+ let molding_in_segment_edit = input. keyboard . get ( molding_in_segment_edit as usize ) ;
15371538
15381539 tool_data. selection_mode = None ;
15391540 tool_data. lasso_polygon . clear ( ) ;
@@ -1547,6 +1548,7 @@ impl Fsm for PathToolFsmState {
15471548 lasso_select,
15481549 handle_drag_from_anchor,
15491550 drag_zero_handle,
1551+ molding_in_segment_edit,
15501552 tool_options. path_overlay_mode ,
15511553 tool_options. path_editing_mode . segment_editing_mode ,
15521554 tool_options. path_editing_mode . point_editing_mode ,
@@ -1627,15 +1629,6 @@ impl Fsm for PathToolFsmState {
16271629 tool_data. handle_drag_toggle = true ;
16281630 }
16291631
1630- // This is responsible for selecting all the anchors if nothing is selected
1631- // Should also check that if there is some segment selection or not
1632-
1633- // if tool_data.selection_status.is_none() {
1634- // if let Some(layer) = document.click(input) {
1635- // shape_editor.select_all_anchors_in_layer(document, layer);
1636- // }
1637- // }
1638-
16391632 let anchor_and_handle_toggled = input. keyboard . get ( move_anchor_with_handles as usize ) ;
16401633 let initial_press = anchor_and_handle_toggled && !tool_data. select_anchor_toggled ;
16411634 let released_from_toggle = tool_data. select_anchor_toggled && !anchor_and_handle_toggled;
@@ -1914,7 +1907,7 @@ impl Fsm for PathToolFsmState {
19141907 } ;
19151908
19161909 if tool_data. drag_start_pos == previous_mouse {
1917- // If the click happened inside of a node then don't set selected nodes to empty array
1910+ // If click happens inside of a shape then don't set selected nodes to empty
19181911 if document. click ( & input) . is_none ( ) {
19191912 responses. add ( NodeGraphMessage :: SelectedNodesSet { nodes : vec ! [ ] } ) ;
19201913 }
@@ -2007,7 +2000,6 @@ impl Fsm for PathToolFsmState {
20072000 }
20082001 // Segment editing mode
20092002 else if let Some ( nearest_segment) = nearest_segment {
2010- //Condition this upon whether user has selected segment editing mode or not
20112003 if segment_mode {
20122004 let clicked_selected = shape_editor. selected_segments ( ) . any ( |& segment| segment == nearest_segment. segment ( ) ) ;
20132005 if !drag_occurred && extend_selection {
@@ -2409,7 +2401,14 @@ fn calculate_adjacent_anchor_tangent(
24092401 }
24102402}
24112403
2412- fn update_dynamic_hints ( state : PathToolFsmState , responses : & mut VecDeque < Message > , shape_editor : & mut ShapeState , document : & DocumentMessageHandler , tool_data : & PathToolData ) {
2404+ fn update_dynamic_hints (
2405+ state : PathToolFsmState ,
2406+ responses : & mut VecDeque < Message > ,
2407+ shape_editor : & mut ShapeState ,
2408+ document : & DocumentMessageHandler ,
2409+ tool_data : & PathToolData ,
2410+ tool_options : & PathToolOptions ,
2411+ ) {
24132412 // Condinting based on currently selected segment if it has any one g1 continuous handle
24142413
24152414 let hint_data = match state {
@@ -2443,12 +2442,27 @@ fn update_dynamic_hints(state: PathToolFsmState, responses: &mut VecDeque<Messag
24432442 drag_selected_hints. push ( HintInfo :: multi_keys ( [ [ Key :: Control ] , [ Key :: Shift ] ] , "Slide" ) . prepend_plus ( ) ) ;
24442443 }
24452444
2446- let mut hint_data = vec ! [
2447- HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Lmb , "Select Point" ) , HintInfo :: keys( [ Key :: Shift ] , "Extend" ) . prepend_plus( ) ] ) ,
2448- HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: LmbDrag , "Select Area" ) , HintInfo :: keys( [ Key :: Control ] , "Lasso" ) . prepend_plus( ) ] ) ,
2449- HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Lmb , "Insert Point on Segment" ) ] ) ,
2450- HintGroup ( vec![ HintInfo :: keys_and_mouse( [ Key :: Alt ] , MouseMotion :: Lmb , "Delete Segment" ) ] ) ,
2451- ] ;
2445+ let mut hint_data = match ( tool_data. segment . is_some ( ) , tool_options. path_editing_mode . segment_editing_mode ) {
2446+ ( true , true ) => {
2447+ vec ! [
2448+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Lmb , "Select Segment" ) , HintInfo :: keys( [ Key :: Shift ] , "Extend" ) . prepend_plus( ) ] ) ,
2449+ HintGroup ( vec![ HintInfo :: keys_and_mouse( [ Key :: KeyA ] , MouseMotion :: Lmb , "Mold Segment" ) ] ) ,
2450+ ]
2451+ }
2452+ ( true , false ) => {
2453+ vec ! [
2454+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Lmb , "Insert Point on Segment" ) ] ) ,
2455+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: LmbDrag , "Mold Segment" ) ] ) ,
2456+ HintGroup ( vec![ HintInfo :: keys_and_mouse( [ Key :: Alt ] , MouseMotion :: Lmb , "Delete Segment" ) ] ) ,
2457+ ]
2458+ }
2459+ ( false , _) => {
2460+ vec ! [
2461+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: Lmb , "Select Point" ) , HintInfo :: keys( [ Key :: Shift ] , "Extend" ) . prepend_plus( ) ] ) ,
2462+ HintGroup ( vec![ HintInfo :: mouse( MouseMotion :: LmbDrag , "Select Area" ) , HintInfo :: keys( [ Key :: Control ] , "Lasso" ) . prepend_plus( ) ] ) ,
2463+ ]
2464+ }
2465+ } ;
24522466
24532467 if at_least_one_anchor_selected {
24542468 // TODO: Dynamically show either "Smooth" or "Sharp" based on the current state
0 commit comments