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
This commit is contained in:
TrueDoctor 2021-12-28 14:05:02 +01:00 committed by Keavon Chambers
parent 1186f33113
commit b605466819

View file

@ -167,15 +167,9 @@ impl Fsm for SelectToolFsmState {
let mut buffer = Vec::new();
let mut selected: Vec<_> = document.selected_layers().map(|path| path.to_vec()).collect();
let quad = data.selection_quad();
let intersection = document.graphene_document.intersects_quad_root(quad);
// If no layer is currently selected and the user clicks on a shape, select that.
if selected.is_empty() {
if let Some(layer) = intersection.last() {
selected.push(layer.clone());
buffer.push(DocumentMessage::SetSelectedLayers(selected.clone()).into());
}
}
let mut intersection = document.graphene_document.intersects_quad_root(quad);
// If the user clicks on a layer that is in their current selection, go into the dragging mode.
// If the user clicks on new shape, make that layer their new selection.
// Otherwise enter the box select mode
let state = if selected.iter().any(|path| intersection.contains(path)) {
buffer.push(DocumentMessage::StartTransaction.into());
@ -184,9 +178,19 @@ impl Fsm for SelectToolFsmState {
} else {
if !input.keyboard.get(add_to_selection as usize) {
buffer.push(DocumentMessage::DeselectAllLayers.into());
data.layers_dragging.clear();
}
if let Some(intersection) = intersection.pop() {
selected = vec![intersection];
buffer.push(DocumentMessage::AddSelectedLayers(selected.clone()).into());
buffer.push(DocumentMessage::StartTransaction.into());
data.layers_dragging.append(&mut selected);
Dragging
} else {
data.drag_box_id = Some(add_bounding_box(&mut buffer));
DrawingBox
}
data.drag_box_id = Some(add_bounding_box(&mut buffer));
DrawingBox
};
buffer.into_iter().rev().for_each(|message| responses.push_front(message));