Fix shallow/deep selection (#1725)

* fix: remove folder #1595 when clicked, except for shallow select.

This should also fix other tools, like Fill tool which hook Lmb hints.

* TODO: shallow select is not working when interval clicks.
* TODO: shallow hover is showed same as deep hover.

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Tiger3018
2024-04-29 16:04:27 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 19eb6ce0ab
commit 282969df3d
2 changed files with 26 additions and 8 deletions
@@ -494,7 +494,8 @@ impl Fsm for SelectToolFsmState {
.unwrap_or_default();
let mut selected: Vec<_> = document.selected_nodes.selected_visible_and_unlocked_layers(document.metadata()).collect();
let intersection = document.click(input.mouse.position, &document.network);
let intersection_list = document.click_list(input.mouse.position, &document.network);
let intersection = document.find_deepest(&intersection_list, &document.network);
// If the user is dragging the bounding box bounds, go into ResizingBounds mode.
// If the user is dragging the rotate trigger, go into RotatingBounds mode.
@@ -591,11 +592,11 @@ impl Fsm for SelectToolFsmState {
responses.add(DocumentMessage::StartTransaction);
tool_data.layer_selected_on_start = Some(intersection);
selected = vec![intersection];
selected = intersection_list;
match tool_data.nested_selection_behavior {
NestedSelectionBehavior::Shallowest if !input.keyboard.key(select_deepest) => drag_shallowest_manipulation(responses, selected, tool_data, document),
_ => drag_deepest_manipulation(responses, selected, tool_data),
_ => drag_deepest_manipulation(responses, selected, tool_data, document),
}
tool_data.get_snap_candidates(document, input);
SelectToolFsmState::Dragging
@@ -1115,8 +1116,8 @@ fn drag_shallowest_manipulation(responses: &mut VecDeque<Message>, selected: Vec
});
}
fn drag_deepest_manipulation(responses: &mut VecDeque<Message>, mut selected: Vec<LayerNodeIdentifier>, tool_data: &mut SelectToolData) {
tool_data.layers_dragging.append(&mut selected);
fn drag_deepest_manipulation(responses: &mut VecDeque<Message>, selected: Vec<LayerNodeIdentifier>, tool_data: &mut SelectToolData, document: &DocumentMessageHandler) {
tool_data.layers_dragging.append(&mut vec![document.find_deepest(&selected, &document.network).unwrap_or_default()]);
responses.add(NodeGraphMessage::SelectedNodesSet {
nodes: tool_data.layers_dragging.iter().map(|layer| layer.to_node()).collect(),
});