Skip to content

Commit 6d52151

Browse files
authored
Improve naming for variables from the lasso selection feature (#2244)
small correction in naming
1 parent 5fedd5c commit 6d52151

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

editor/src/messages/tool/tool_messages/path_tool.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl PathToolData {
341341
Quad::from_box(bbox)
342342
}
343343

344-
pub fn calculate_direction(&mut self) -> SelectionMode {
344+
pub fn calculate_selection_mode_from_direction(&mut self) -> SelectionMode {
345345
let bbox = self.selection_box();
346346
let above_threshold = bbox[1].distance_squared(bbox[0]) > DRAG_DIRECTION_MODE_DETERMINATION_THRESHOLD.powi(2);
347347

@@ -714,15 +714,15 @@ impl Fsm for PathToolFsmState {
714714
fill_color.insert(0, '#');
715715
let fill_color = Some(fill_color.as_str());
716716

717-
let mut selection_direction = tool_action_data.preferences.get_selection_mode();
718-
if selection_direction == SelectionMode::Directional {
719-
selection_direction = tool_data.calculate_direction();
720-
}
717+
let selection_mode = match tool_action_data.preferences.get_selection_mode() {
718+
SelectionMode::Directional => tool_data.calculate_selection_mode_from_direction(),
719+
selection_mode => selection_mode,
720+
};
721721

722722
let quad = tool_data.selection_quad();
723723
let polygon = &tool_data.lasso_polygon;
724724

725-
match (selection_shape, selection_direction) {
725+
match (selection_shape, selection_mode) {
726726
(SelectionShapeType::Box, SelectionMode::Enclosed) => overlay_context.dashed_quad(quad, fill_color, Some(4.), Some(4.), Some(0.5)),
727727
(SelectionShapeType::Lasso, SelectionMode::Enclosed) => overlay_context.dashed_polygon(polygon, fill_color, Some(4.), Some(4.), Some(0.5)),
728728
(SelectionShapeType::Box, _) => overlay_context.quad(quad, fill_color),

editor/src/messages/tool/tool_messages/select_tool.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)