@@ -8,7 +8,7 @@ use crate::consts::{
8
8
use crate :: messages:: input_mapper:: utility_types:: input_mouse:: ViewportPosition ;
9
9
use crate :: messages:: portfolio:: document:: graph_operation:: utility_types:: TransformIn ;
10
10
use crate :: messages:: portfolio:: document:: overlays:: utility_types:: OverlayContext ;
11
- use crate :: messages:: portfolio:: document:: utility_types:: document_metadata:: LayerNodeIdentifier ;
11
+ use crate :: messages:: portfolio:: document:: utility_types:: document_metadata:: { DocumentMetadata , LayerNodeIdentifier } ;
12
12
use crate :: messages:: portfolio:: document:: utility_types:: misc:: { AlignAggregate , AlignAxis , FlipAxis , GroupFolderType } ;
13
13
use crate :: messages:: portfolio:: document:: utility_types:: network_interface:: { FlowType , NodeNetworkInterface , NodeTemplate } ;
14
14
use crate :: messages:: portfolio:: document:: utility_types:: nodes:: SelectedNodes ;
@@ -705,8 +705,14 @@ impl Fsm for SelectToolFsmState {
705
705
draw_layer_outline ( layer) ;
706
706
}
707
707
} else {
708
- for layer in intersection {
709
- draw_layer_outline ( layer) ;
708
+ if tool_data. nested_selection_behavior == NestedSelectionBehavior :: Deepest {
709
+ for layer in intersection. iter ( ) . filter ( |layer| !layer. has_children ( document. metadata ( ) ) ) {
710
+ draw_layer_outline ( * layer) ;
711
+ }
712
+ } else {
713
+ for layer in intersection {
714
+ draw_layer_outline ( layer) ;
715
+ }
710
716
}
711
717
}
712
718
@@ -1387,14 +1393,19 @@ impl Fsm for SelectToolFsmState {
1387
1393
. collect ( ) ;
1388
1394
tool_data. layers_dragging = updated_selection;
1389
1395
} else if selection_modified {
1396
+ let filtered_selections = filter_nested_selection ( document. metadata ( ) , & new_selected) ;
1390
1397
let parent_selected: HashSet < _ > = new_selected
1391
1398
. into_iter ( )
1392
1399
. map ( |layer| {
1393
1400
// Find the parent node
1394
1401
layer. ancestors ( document. metadata ( ) ) . filter ( not_artboard ( document) ) . last ( ) . unwrap_or ( layer)
1395
1402
} )
1396
1403
. collect ( ) ;
1397
- tool_data. layers_dragging . extend ( parent_selected. iter ( ) . copied ( ) ) ;
1404
+ if tool_data. nested_selection_behavior == NestedSelectionBehavior :: Deepest {
1405
+ tool_data. layers_dragging . extend ( filtered_selections) ;
1406
+ } else {
1407
+ tool_data. layers_dragging . extend ( parent_selected. iter ( ) . copied ( ) ) ;
1408
+ }
1398
1409
}
1399
1410
1400
1411
if negative_selection || selection_modified {
@@ -1680,3 +1691,31 @@ pub fn extend_lasso(lasso_polygon: &mut Vec<DVec2>, point: DVec2) {
1680
1691
lasso_polygon. push ( point) ;
1681
1692
}
1682
1693
}
1694
+
1695
+ pub fn filter_nested_selection ( metadata : & DocumentMetadata , new_selected : & HashSet < LayerNodeIdentifier > ) -> HashSet < LayerNodeIdentifier > {
1696
+ let mut filtered_selection = HashSet :: new ( ) ;
1697
+
1698
+ // First collect childless layers
1699
+ for & layer in new_selected {
1700
+ if !layer. has_children ( metadata) {
1701
+ filtered_selection. insert ( layer) ;
1702
+ }
1703
+ }
1704
+
1705
+ // Then process parents with all children selected
1706
+ for & layer in new_selected {
1707
+ if layer. has_children ( metadata) {
1708
+ let all_children_selected = layer. children ( metadata) . all ( |child| new_selected. contains ( & child) ) ;
1709
+
1710
+ if all_children_selected {
1711
+ // Remove all children of the parent
1712
+ layer. children ( metadata) . for_each ( |child| {
1713
+ filtered_selection. remove ( & child) ;
1714
+ } ) ;
1715
+ // Add the parent
1716
+ filtered_selection. insert ( layer) ;
1717
+ }
1718
+ }
1719
+ }
1720
+ filtered_selection
1721
+ }
0 commit comments