Skip to content

Commit 655bc61

Browse files
committed
refactored select-tool
1 parent a51713a commit 655bc61

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

editor/src/messages/tool/common_functionality/utility_functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn skew_bounds(
260260
}
261261
}
262262

263-
pub fn transforming_tranform_cage(
263+
pub fn transforming_transform_cage(
264264
document: &DocumentMessageHandler,
265265
mut bounding_box_manager: &mut Option<BoundingBoxManager>,
266266
input: &InputPreprocessorMessageHandler,

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
use super::tool_prelude::*;
44
use crate::consts::{
5-
COLOR_OVERLAY_BLUE, COLOR_OVERLAY_GREEN, COLOR_OVERLAY_RED, COMPASS_ROSE_HOVER_RING_DIAMETER, DRAG_DIRECTION_MODE_DETERMINATION_THRESHOLD, RESIZE_HANDLE_SIZE,
6-
SELECTION_DRAG_ANGLE, SELECTION_TOLERANCE,
5+
COLOR_OVERLAY_BLUE, COLOR_OVERLAY_GREEN, COLOR_OVERLAY_RED, COMPASS_ROSE_HOVER_RING_DIAMETER, DRAG_DIRECTION_MODE_DETERMINATION_THRESHOLD, RESIZE_HANDLE_SIZE, SELECTION_DRAG_ANGLE,
6+
SELECTION_TOLERANCE,
77
};
88
use crate::messages::input_mapper::utility_types::input_mouse::ViewportPosition;
99
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
@@ -21,7 +21,7 @@ use crate::messages::tool::common_functionality::pivot::Pivot;
2121
use crate::messages::tool::common_functionality::shape_editor::SelectionShapeType;
2222
use crate::messages::tool::common_functionality::snapping::{self, SnapCandidatePoint, SnapData, SnapManager};
2323
use crate::messages::tool::common_functionality::transformation_cage::*;
24-
use crate::messages::tool::common_functionality::utility_functions::{resize_bounds, rotate_bounds, skew_bounds, text_bounding_box, transforming_tranform_cage};
24+
use crate::messages::tool::common_functionality::utility_functions::{resize_bounds, rotate_bounds, skew_bounds, text_bounding_box, transforming_transform_cage};
2525
use bezier_rs::Subpath;
2626
use glam::DMat2;
2727
use graph_craft::document::NodeId;
@@ -868,13 +868,7 @@ impl Fsm for SelectToolFsmState {
868868
let intersection_list = document.click_list(input).collect::<Vec<_>>();
869869
let intersection = document.find_deepest(&intersection_list);
870870

871-
let (resize, rotate, skew) = transforming_tranform_cage(
872-
document,
873-
&mut tool_data.bounding_box_manager,
874-
input,
875-
responses,
876-
&mut tool_data.layers_dragging,
877-
);
871+
let (resize, rotate, skew) = transforming_transform_cage(document, &mut tool_data.bounding_box_manager, input, responses, &mut tool_data.layers_dragging);
878872

879873
// If the user is dragging the bounding box bounds, go into ResizingBounds mode.
880874
// If the user is dragging the rotate trigger, go into RotatingBounds mode.
@@ -894,9 +888,9 @@ impl Fsm for SelectToolFsmState {
894888
let show_compass = bounds.is_some_and(|quad| quad.all_sides_at_least_width(COMPASS_ROSE_HOVER_RING_DIAMETER) && quad.contains(mouse_position));
895889
let can_grab_compass_rose = compass_rose_state.can_grab() && (show_compass || bounds.is_none());
896890

897-
let state =
891+
let state = if is_over_pivot
898892
// Dragging the pivot
899-
if is_over_pivot {
893+
{
900894
responses.add(DocumentMessage::StartTransaction);
901895

902896
// tool_data.snap_manager.start_snap(document, input, document.bounding_boxes(), true, true);
@@ -905,13 +899,12 @@ impl Fsm for SelectToolFsmState {
905899
SelectToolFsmState::DraggingPivot
906900
}
907901
// Dragging one (or two, forming a corner) of the transform cage bounding box edges
908-
else if resize {
902+
else if resize {
909903
tool_data.get_snap_candidates(document, input);
910904
SelectToolFsmState::ResizingBounds
911-
}else if skew{
905+
} else if skew {
912906
tool_data.get_snap_candidates(document, input);
913907
SelectToolFsmState::SkewingBounds { skew: Key::Control }
914-
915908
}
916909
// Dragging the selected layers around to transform them
917910
else if can_grab_compass_rose || intersection.is_some_and(|intersection| selected.iter().any(|selected_layer| intersection.starts_with(*selected_layer, document.metadata()))) {
@@ -930,7 +923,13 @@ impl Fsm for SelectToolFsmState {
930923
let axis_state = compass_rose_state.axis_type().filter(|_| can_grab_compass_rose);
931924
(axis_state.unwrap_or_default(), axis_state.is_some())
932925
};
933-
SelectToolFsmState::Dragging { axis, using_compass, has_dragged: false, deepest: input.keyboard.key(select_deepest), remove: input.keyboard.key(extend_selection) }
926+
SelectToolFsmState::Dragging {
927+
axis,
928+
using_compass,
929+
has_dragged: false,
930+
deepest: input.keyboard.key(select_deepest),
931+
remove: input.keyboard.key(extend_selection),
932+
}
934933
}
935934
// Dragging near the transform cage bounding box to rotate it
936935
else if rotate {
@@ -956,7 +955,13 @@ impl Fsm for SelectToolFsmState {
956955
tool_data.get_snap_candidates(document, input);
957956

958957
responses.add(DocumentMessage::StartTransaction);
959-
SelectToolFsmState::Dragging { axis: Axis::None, using_compass: false, has_dragged: false, deepest: input.keyboard.key(select_deepest), remove: input.keyboard.key(extend_selection) }
958+
SelectToolFsmState::Dragging {
959+
axis: Axis::None,
960+
using_compass: false,
961+
has_dragged: false,
962+
deepest: input.keyboard.key(select_deepest),
963+
remove: input.keyboard.key(extend_selection),
964+
}
960965
} else {
961966
let selection_shape = if input.keyboard.key(lasso_select) { SelectionShapeType::Lasso } else { SelectionShapeType::Box };
962967
SelectToolFsmState::Drawing { selection_shape, has_drawn: false }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl Fsm for ShapeToolFsmState {
376376
}
377377
}
378378

379-
let (resize, rotate, skew) = transforming_tranform_cage(document, &mut tool_data.bounding_box_manager, input, responses, &mut tool_data.layers_dragging);
379+
let (resize, rotate, skew) = transforming_transform_cage(document, &mut tool_data.bounding_box_manager, input, responses, &mut tool_data.layers_dragging);
380380

381381
match (resize, rotate, skew) {
382382
(true, false, false) => {

0 commit comments

Comments
 (0)