Skip to content

Commit

Permalink
switch from shift toggle to shift hold
Browse files Browse the repository at this point in the history
  • Loading branch information
0SlowPoke0 committed Jan 2, 2025
1 parent 3cf3cdb commit 0f9ed57
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn input_mappings() -> Mapping {
entry!(PointerMove; refresh_keys=[Control, Shift], action_dispatch=TransformLayerMessage::PointerMove { slow_key: Shift, snap_key: Control }),
//
// SelectToolMessage
entry!(KeyDownNoRepeat(Shift); action_dispatch=SelectToolMessage::RestoreSelection),
entry!(KeyDown(Shift); refresh_keys=[Shift], action_dispatch=SelectToolMessage::RestoreSelection),
entry!(PointerMove; refresh_keys=[Control, Alt, Shift], action_dispatch=SelectToolMessage::PointerMove(SelectToolPointerKeys { axis_align: Shift, snap_angle: Control, center: Alt, duplicate: Alt })),
entry!(KeyDown(MouseLeft); action_dispatch=SelectToolMessage::DragStart { extend_selection: Shift, select_deepest: Accel }),
entry!(KeyUp(MouseLeft); action_dispatch=SelectToolMessage::DragStop { remove_from_selection: Shift, negative_box_selection: Control }),
Expand Down
27 changes: 15 additions & 12 deletions editor/src/messages/tool/tool_messages/select_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,17 +1103,23 @@ impl Fsm for SelectToolFsmState {
self
}
(SelectToolFsmState::DrawingBox { selection, previous_selected }, SelectToolMessage::RestoreSelection) => {
// Toggle the selection state based on the previous_selected flag
if previous_selected {
let selection_set: HashSet<_> = tool_data.previously_selected_layers.iter().collect();
tool_data.layers_dragging.retain(|layer| !selection_set.contains(layer));
let selection_set: HashSet<_> = tool_data.previously_selected_layers.iter().collect();
if input.keyboard.key(Key::Shift) {
if previous_selected {
// if selected deselect it
tool_data.layers_dragging.retain(|layer| !selection_set.contains(layer));
} else {
tool_data.layers_dragging.extend(&tool_data.previously_selected_layers);
}
} else {
tool_data.layers_dragging.extend(&tool_data.previously_selected_layers);
// On Shift release, finalize selection state
if previous_selected {
tool_data.layers_dragging.extend(&tool_data.previously_selected_layers);
} else {
tool_data.layers_dragging.retain(|layer| !selection_set.contains(layer));
}
}

// Update the previous_selected flag
let new_previous_selected = !previous_selected;

let selected_nodes: Vec<_> = tool_data
.layers_dragging
.iter()
Expand All @@ -1131,10 +1137,7 @@ impl Fsm for SelectToolFsmState {

responses.add(OverlaysMessage::Draw);

SelectToolFsmState::DrawingBox {
selection,
previous_selected: new_previous_selected,
}
SelectToolFsmState::DrawingBox { selection, previous_selected }
}
_ => self,
}
Expand Down

0 comments on commit 0f9ed57

Please sign in to comment.