Add an editor preference for touched/enclosed/directional based selection (#2156)

* implemented left selection logic

* added logic for right ward selection

* removed the logs code

* corrected capitalization error

* corrected capitalization error

* added radio buttons for selection_mode

* fixed multiple selection of checkboxes

* adapted to the RadioEntryData

* State management bug

* integrated message system to selection_mode

* updated

* updated

* added selection mode to transition arms

* removed from portfolio message and added preference in ToolMessageData

* removed dead code of selection_mode from frontend logic

* removed dead code for zoomWithScroll

* Cleanup

* Rename, simplify, use dashed box, and highlight only outlines of layers that'll get selected

* More code review

---------

Co-authored-by: Pratik Agrawal <patrik@Pratiks-MacBook-Air.local>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Pratik Agrawal
2025-01-26 06:34:37 +00:00
committed by GitHub
co-authored by Pratik Agrawal Keavon Chambers
parent 93880abc4c
commit 96c57605b7
17 changed files with 266 additions and 113 deletions
@@ -1407,6 +1407,29 @@ impl DocumentMessageHandler {
self.intersect_quad(viewport_quad, ipp).filter(|layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
}
pub fn is_layer_fully_inside(&self, layer: &LayerNodeIdentifier, quad: graphene_core::renderer::Quad) -> bool {
// Get the bounding box of the layer in document space
let Some(bounding_box) = self.metadata().bounding_box_viewport(*layer) else { return false };
// Check if the bounding box is fully within the selection quad
let [top_left, bottom_right] = bounding_box;
let quad_bbox = quad.bounding_box();
let quad_left = quad_bbox[0].x;
let quad_right = quad_bbox[1].x;
let quad_top = quad_bbox[0].y.max(quad_bbox[1].y); // Correct top
let quad_bottom = quad_bbox[0].y.min(quad_bbox[1].y); // Correct bottom
// Extract layer's bounding box coordinates
let layer_left = top_left.x;
let layer_right = bottom_right.x;
let layer_top = bottom_right.y;
let layer_bottom = top_left.y;
layer_left >= quad_left && layer_right <= quad_right && layer_top <= quad_top && layer_bottom >= quad_bottom
}
/// Find all of the layers that were clicked on from a viewport space location
pub fn click_xray(&self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + '_ {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
@@ -460,7 +460,7 @@ impl DoubleEndedIterator for DescendantsIter<'_> {
#[derive(Debug, Clone, Copy, Default)]
pub struct NodeRelations {
parent: Option<LayerNodeIdentifier>,
pub parent: Option<LayerNodeIdentifier>,
previous_sibling: Option<LayerNodeIdentifier>,
next_sibling: Option<LayerNodeIdentifier>,
first_child: Option<LayerNodeIdentifier>,