Skip to content

Commit 4bfe55f

Browse files
committed
Enable lasso select when dragging within object
1 parent a4fbea9 commit 4bfe55f

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn input_mappings() -> Mapping {
9797
//
9898
// SelectToolMessage
9999
entry!(PointerMove; refresh_keys=[Control, Alt, Shift], action_dispatch=SelectToolMessage::PointerMove(SelectToolPointerKeys { axis_align: Shift, snap_angle: Shift, center: Alt, duplicate: Alt })),
100-
entry!(KeyDown(MouseLeft); action_dispatch=SelectToolMessage::DragStart { extend_selection: Shift, remove_from_selection: Alt, select_deepest: Accel, lasso_select: Control, skew: Control }),
100+
entry!(KeyDown(MouseLeft); action_dispatch=SelectToolMessage::DragStart { extend_selection: Shift, remove_from_selection: Alt, select_deepest_key: Accel, lasso_select_key: Control, skew: Control }),
101101
entry!(KeyUp(MouseLeft); action_dispatch=SelectToolMessage::DragStop { remove_from_selection: Alt }),
102102
entry!(KeyDown(Enter); action_dispatch=SelectToolMessage::Enter),
103103
entry!(DoubleClick(MouseButton::Left); action_dispatch=SelectToolMessage::EditLayer),

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub enum SelectToolMessage {
8080
DragStart {
8181
extend_selection: Key,
8282
remove_from_selection: Key,
83-
select_deepest: Key,
84-
lasso_select: Key,
83+
select_deepest_key: Key,
84+
lasso_select_key: Key,
8585
skew: Key,
8686
},
8787
DragStop {
@@ -855,8 +855,8 @@ impl Fsm for SelectToolFsmState {
855855
SelectToolMessage::DragStart {
856856
extend_selection,
857857
remove_from_selection,
858-
select_deepest,
859-
lasso_select,
858+
select_deepest_key,
859+
lasso_select_key,
860860
..
861861
},
862862
) => {
@@ -874,7 +874,7 @@ impl Fsm for SelectToolFsmState {
874874
// If the user is dragging the rotate trigger, go into RotatingBounds mode.
875875
// If the user clicks on a layer that is in their current selection, go into the dragging mode.
876876
// If the user clicks on new shape, make that layer their new selection.
877-
// Otherwise enter the box select mode
877+
// Otherwise enter the box or lasso select mode
878878
let bounds = tool_data
879879
.bounding_box_manager
880880
.as_ref()
@@ -910,7 +910,7 @@ impl Fsm for SelectToolFsmState {
910910
else if can_grab_compass_rose || intersection.is_some_and(|intersection| selected.iter().any(|selected_layer| intersection.starts_with(*selected_layer, document.metadata()))) {
911911
responses.add(DocumentMessage::StartTransaction);
912912

913-
if input.keyboard.key(select_deepest) || tool_data.nested_selection_behavior == NestedSelectionBehavior::Deepest {
913+
if input.keyboard.key(select_deepest_key) || tool_data.nested_selection_behavior == NestedSelectionBehavior::Deepest {
914914
tool_data.select_single_layer = intersection;
915915
} else {
916916
tool_data.select_single_layer = intersection.and_then(|intersection| intersection.ancestors(document.metadata()).find(|ancestor| selected.contains(ancestor)));
@@ -927,15 +927,15 @@ impl Fsm for SelectToolFsmState {
927927
axis,
928928
using_compass,
929929
has_dragged: false,
930-
deepest: input.keyboard.key(select_deepest),
930+
deepest: input.keyboard.key(select_deepest_key),
931931
remove: input.keyboard.key(extend_selection),
932932
}
933933
}
934934
// Dragging near the transform cage bounding box to rotate it
935935
else if rotate {
936936
SelectToolFsmState::RotatingBounds
937937
}
938-
// Dragging a selection box
938+
// Dragging a selection box or lasso
939939
else {
940940
tool_data.layers_dragging = selected;
941941
let extend = input.keyboard.key(extend_selection);
@@ -944,12 +944,13 @@ impl Fsm for SelectToolFsmState {
944944
tool_data.layers_dragging.clear();
945945
}
946946

947-
if let Some(intersection) = intersection {
947+
let lasso_select = input.keyboard.key(lasso_select_key);
948+
if !lasso_select && let Some(intersection) = intersection {
948949
tool_data.layer_selected_on_start = Some(intersection);
949950
selected = intersection_list;
950951

951952
match tool_data.nested_selection_behavior {
952-
NestedSelectionBehavior::Shallowest if !input.keyboard.key(select_deepest) => drag_shallowest_manipulation(responses, selected, tool_data, document, false, extend),
953+
NestedSelectionBehavior::Shallowest if !input.keyboard.key(select_deepest_key) => drag_shallowest_manipulation(responses, selected, tool_data, document, false, extend),
953954
_ => drag_deepest_manipulation(responses, selected, tool_data, document, false),
954955
}
955956
tool_data.get_snap_candidates(document, input);
@@ -959,11 +960,11 @@ impl Fsm for SelectToolFsmState {
959960
axis: Axis::None,
960961
using_compass: false,
961962
has_dragged: false,
962-
deepest: input.keyboard.key(select_deepest),
963+
deepest: input.keyboard.key(select_deepest_key),
963964
remove: input.keyboard.key(extend_selection),
964965
}
965966
} else {
966-
let selection_shape = if input.keyboard.key(lasso_select) { SelectionShapeType::Lasso } else { SelectionShapeType::Box };
967+
let selection_shape = if lasso_select { SelectionShapeType::Lasso } else { SelectionShapeType::Box };
967968
SelectToolFsmState::Drawing { selection_shape, has_drawn: false }
968969
}
969970
};

0 commit comments

Comments
 (0)