Skip to content

Commit eac9999

Browse files
authored
Change the select tool to immediately start dragging when clicking a shape (#424)
* Change the select tool to immediately start dragging when clicking a shape * Fix operation order * Fix holding shift to add to selection
1 parent b142423 commit eac9999

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

editor/src/tool/tools/select.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,9 @@ impl Fsm for SelectToolFsmState {
167167
let mut buffer = Vec::new();
168168
let mut selected: Vec<_> = document.selected_layers().map(|path| path.to_vec()).collect();
169169
let quad = data.selection_quad();
170-
let intersection = document.graphene_document.intersects_quad_root(quad);
171-
// If no layer is currently selected and the user clicks on a shape, select that.
172-
if selected.is_empty() {
173-
if let Some(layer) = intersection.last() {
174-
selected.push(layer.clone());
175-
buffer.push(DocumentMessage::SetSelectedLayers(selected.clone()).into());
176-
}
177-
}
170+
let mut intersection = document.graphene_document.intersects_quad_root(quad);
178171
// If the user clicks on a layer that is in their current selection, go into the dragging mode.
172+
// If the user clicks on new shape, make that layer their new selection.
179173
// Otherwise enter the box select mode
180174
let state = if selected.iter().any(|path| intersection.contains(path)) {
181175
buffer.push(DocumentMessage::StartTransaction.into());
@@ -184,9 +178,19 @@ impl Fsm for SelectToolFsmState {
184178
} else {
185179
if !input.keyboard.get(add_to_selection as usize) {
186180
buffer.push(DocumentMessage::DeselectAllLayers.into());
181+
data.layers_dragging.clear();
182+
}
183+
184+
if let Some(intersection) = intersection.pop() {
185+
selected = vec![intersection];
186+
buffer.push(DocumentMessage::AddSelectedLayers(selected.clone()).into());
187+
buffer.push(DocumentMessage::StartTransaction.into());
188+
data.layers_dragging.append(&mut selected);
189+
Dragging
190+
} else {
191+
data.drag_box_id = Some(add_bounding_box(&mut buffer));
192+
DrawingBox
187193
}
188-
data.drag_box_id = Some(add_bounding_box(&mut buffer));
189-
DrawingBox
190194
};
191195
buffer.into_iter().rev().for_each(|message| responses.push_front(message));
192196

0 commit comments

Comments
 (0)