@@ -322,7 +322,7 @@ impl SelectToolData {
322322 Quad :: from_box ( bbox)
323323 }
324324
325- pub fn calculate_direction ( & mut self ) -> SelectionMode {
325+ pub fn calculate_selection_mode_from_direction ( & mut self ) -> SelectionMode {
326326 let bbox: [ DVec2 ; 2 ] = self . selection_box ( ) ;
327327 let above_threshold = bbox[ 1 ] . distance_squared ( bbox[ 0 ] ) > DRAG_DIRECTION_MODE_DETERMINATION_THRESHOLD . powi ( 2 ) ;
328328
@@ -535,18 +535,18 @@ impl Fsm for SelectToolFsmState {
535535 // Get the updated selection box bounds
536536 let quad = Quad :: from_box ( [ tool_data. drag_start , tool_data. drag_current ] ) ;
537537
538- let mut selection_direction = tool_action_data. preferences . get_selection_mode ( ) ;
539- if selection_direction == SelectionMode :: Directional {
540- selection_direction = tool_data . calculate_direction ( ) ;
541- }
538+ let selection_mode = match tool_action_data. preferences . get_selection_mode ( ) {
539+ SelectionMode :: Directional => tool_data . calculate_selection_mode_from_direction ( ) ,
540+ selection_mode => selection_mode ,
541+ } ;
542542
543543 // Draw outline visualizations on the layers to be selected
544544 let mut draw_layer_outline = |layer| overlay_context. outline ( document. metadata ( ) . layer_outline ( layer) , document. metadata ( ) . transform_to_viewport ( layer) ) ;
545545 let intersection: Vec < LayerNodeIdentifier > = match selection_shape {
546546 SelectionShapeType :: Box => document. intersect_quad_no_artboards ( quad, input) . collect ( ) ,
547547 SelectionShapeType :: Lasso => tool_data. intersect_lasso_no_artboards ( document, input) ,
548548 } ;
549- if selection_direction == SelectionMode :: Enclosed {
549+ if selection_mode == SelectionMode :: Enclosed {
550550 let is_inside = |layer : & LayerNodeIdentifier | match selection_shape {
551551 SelectionShapeType :: Box => document. is_layer_fully_inside ( layer, quad) ,
552552 SelectionShapeType :: Lasso => tool_data. is_layer_inside_lasso_polygon ( layer, document, input) ,
@@ -570,7 +570,7 @@ impl Fsm for SelectToolFsmState {
570570
571571 let polygon = & tool_data. lasso_polygon ;
572572
573- match ( selection_shape, selection_direction ) {
573+ match ( selection_shape, selection_mode ) {
574574 ( SelectionShapeType :: Box , SelectionMode :: Enclosed ) => overlay_context. dashed_quad ( quad, fill_color, Some ( 4. ) , Some ( 4. ) , Some ( 0.5 ) ) ,
575575 ( SelectionShapeType :: Lasso , SelectionMode :: Enclosed ) => overlay_context. dashed_polygon ( polygon, fill_color, Some ( 4. ) , Some ( 4. ) , Some ( 0.5 ) ) ,
576576 ( SelectionShapeType :: Box , _) => overlay_context. quad ( quad, fill_color) ,
@@ -1122,16 +1122,16 @@ impl Fsm for SelectToolFsmState {
11221122 ( SelectToolFsmState :: Drawing { selection_shape } , SelectToolMessage :: DragStop { remove_from_selection } ) => {
11231123 let quad = tool_data. selection_quad ( ) ;
11241124
1125- let mut selection_direction = tool_action_data. preferences . get_selection_mode ( ) ;
1126- if selection_direction == SelectionMode :: Directional {
1127- selection_direction = tool_data . calculate_direction ( ) ;
1128- }
1125+ let selection_mode = match tool_action_data. preferences . get_selection_mode ( ) {
1126+ SelectionMode :: Directional => tool_data . calculate_selection_mode_from_direction ( ) ,
1127+ selection_mode => selection_mode ,
1128+ } ;
11291129
11301130 let intersection: Vec < LayerNodeIdentifier > = match selection_shape {
11311131 SelectionShapeType :: Box => document. intersect_quad_no_artboards ( quad, input) . collect ( ) ,
11321132 SelectionShapeType :: Lasso => tool_data. intersect_lasso_no_artboards ( document, input) ,
11331133 } ;
1134- let new_selected: HashSet < _ > = if selection_direction == SelectionMode :: Enclosed {
1134+ let new_selected: HashSet < _ > = if selection_mode == SelectionMode :: Enclosed {
11351135 let is_inside = |layer : & LayerNodeIdentifier | match selection_shape {
11361136 SelectionShapeType :: Box => document. is_layer_fully_inside ( layer, quad) ,
11371137 SelectionShapeType :: Lasso => tool_data. is_layer_inside_lasso_polygon ( layer, document, input) ,
0 commit comments