Fix regressions with G/R/S (#3355)

* Better local grab

* Formatting

* Multiply by document_to_viewport.matrix2.y_axis.length()

* Fix logic errors

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay
2025-11-25 15:26:19 -08:00
committed by GitHub
co-authored by Keavon Chambers
parent 5ff399d3f2
commit 117ce301b0
3 changed files with 146 additions and 247 deletions
@@ -593,6 +593,19 @@ impl SelectToolData {
}
}
/// Bounding boxes are unfortunately not axis aligned. The bounding boxes are found after a transformation is applied to all of the layers.
/// This uses some rather confusing logic to determine what transform that should be.
pub fn create_bounding_box_transform(document: &DocumentMessageHandler) -> DAffine2 {
// Update bounds
document
.network_interface
.selected_nodes()
.selected_visible_and_unlocked_layers(&document.network_interface)
.find(|layer| !document.network_interface.is_artboard(&layer.to_node(), &[]))
.map(|layer| document.metadata().transform_to_viewport_with_first_transform_node_if_group(layer, &document.network_interface))
.unwrap_or_default()
}
impl Fsm for SelectToolFsmState {
type ToolData = SelectToolData;
type ToolOptions = ();
@@ -633,14 +646,7 @@ impl Fsm for SelectToolFsmState {
}
}
// Update bounds
let mut transform = document
.network_interface
.selected_nodes()
.selected_visible_and_unlocked_layers(&document.network_interface)
.find(|layer| !document.network_interface.is_artboard(&layer.to_node(), &[]))
.map(|layer| document.metadata().transform_to_viewport_with_first_transform_node_if_group(layer, &document.network_interface))
.unwrap_or_default();
let mut transform = create_bounding_box_transform(document);
// Check if the matrix is not invertible
let mut transform_tampered = false;