Fix interactive outlining of layers within the Select tool's box selection (#1727)

* changes made to correct outlining behavior

* Comment fixups

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Shyam Jayakannan 2024-04-18 10:18:29 +05:30 committed by GitHub
parent 67ba5bcecf
commit e55578a016
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 9 deletions

View File

@ -407,13 +407,6 @@ impl Fsm for SelectToolFsmState {
overlay_context.outline(document.metadata().layer_outline(layer), document.metadata().transform_to_viewport(layer));
}
// Get the layer the user is hovering over
let click = document.click(input.mouse.position, &document.network);
let not_selected_click = click.filter(|&hovered_layer| !document.selected_nodes.selected_layers_contains(hovered_layer, document.metadata()));
if let Some(layer) = not_selected_click {
overlay_context.outline(document.metadata().layer_outline(layer), document.metadata().transform_to_viewport(layer));
}
// Update bounds
let transform = document
.selected_nodes
@ -444,9 +437,25 @@ impl Fsm for SelectToolFsmState {
// Update pivot
tool_data.pivot.update_pivot(document, &mut overlay_context);
// Update dragging box
// Check if the tool is in box selection mode
if matches!(self, Self::DrawingBox { .. }) {
overlay_context.quad(Quad::from_box([tool_data.drag_start, tool_data.drag_current]));
// Get the updated selection box bounds
let quad = Quad::from_box([tool_data.drag_start, tool_data.drag_current]);
// Draw outline visualizations on the layers to be selected
for layer in document.intersect_quad(quad, &document.network) {
overlay_context.outline(document.metadata().layer_outline(layer), document.metadata().transform_to_viewport(layer));
}
// Update the selection box
overlay_context.quad(quad);
} else {
// Get the layer the user is hovering over
let click = document.click(input.mouse.position, &document.network);
let not_selected_click = click.filter(|&hovered_layer| !document.selected_nodes.selected_layers_contains(hovered_layer, document.metadata()));
if let Some(layer) = not_selected_click {
overlay_context.outline(document.metadata().layer_outline(layer), document.metadata().transform_to_viewport(layer));
}
}
self