diff --git a/editor/src/messages/tool/common_functionality/utility_functions.rs b/editor/src/messages/tool/common_functionality/utility_functions.rs index e8d4293721..f8bc8cd887 100644 --- a/editor/src/messages/tool/common_functionality/utility_functions.rs +++ b/editor/src/messages/tool/common_functionality/utility_functions.rs @@ -13,6 +13,7 @@ use crate::messages::tool::utility_types::ToolType; use glam::{DAffine2, DVec2}; use graph_craft::concrete; use graph_craft::document::value::TaggedValue; +use graphene_std::Graphic; use graphene_std::renderer::Quad; use graphene_std::subpath::{Bezier, BezierHandles}; use graphene_std::table::Table; @@ -572,11 +573,8 @@ pub fn make_path_editable_is_allowed(network_interface: &mut NodeNetworkInterfac } for _ in selected_layers {} - // Must be a layer of type Table - let node_id = NodeGraphLayer::new(first_layer, network_interface).horizontal_layer_flow().nth(1)?; - - let output_type = network_interface.output_type(&OutputConnector::node(node_id, 0), &[]); - if output_type.compiled_nested_type() != Some(&concrete!(Table)) { + // Must be a layer with a path-editable input type. + if !layer_can_be_path_editable_input(first_layer, network_interface) { return None; } @@ -590,3 +588,13 @@ pub fn make_path_editable_is_allowed(network_interface: &mut NodeNetworkInterfac Some(first_layer) } + +/// Returns whether the layer's main content input can be made path-editable. +pub fn layer_can_be_path_editable_input(layer: LayerNodeIdentifier, network_interface: &mut NodeNetworkInterface) -> bool { + let Some(node_id) = NodeGraphLayer::new(layer, network_interface).horizontal_layer_flow().nth(1) else { + return false; + }; + + let output_type = network_interface.output_type(&OutputConnector::node(node_id, 0), &[]); + output_type.compiled_nested_type() == Some(&concrete!(Table)) || output_type.compiled_nested_type() == Some(&concrete!(Table)) +} diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 80f0a6faa4..eaf272956c 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -23,7 +23,7 @@ use crate::messages::tool::common_functionality::shape_editor::{ ClosestSegment, ManipulatorAngle, OpposingHandleLengths, SelectedLayerState, SelectedPointsInfo, SelectionChange, SelectionShape, SelectionShapeType, ShapeState, }; use crate::messages::tool::common_functionality::snapping::{SnapCache, SnapCandidatePoint, SnapConstraint, SnapData, SnapManager}; -use crate::messages::tool::common_functionality::utility_functions::{calculate_segment_angle, find_two_param_best_approximate, make_path_editable_is_allowed}; +use crate::messages::tool::common_functionality::utility_functions::{calculate_segment_angle, find_two_param_best_approximate, layer_can_be_path_editable_input, make_path_editable_is_allowed}; use graphene_std::Color; use graphene_std::renderer::Quad; use graphene_std::subpath::pathseg_points; @@ -1578,7 +1578,25 @@ impl Fsm for PathToolFsmState { match (self, event) { (_, PathToolMessage::SelectionChanged) => { // Set the newly targeted layers to visible - let target_layers = document.network_interface.selected_nodes().selected_layers(document.metadata()).collect(); + let mut target_layers = document.network_interface.selected_nodes().selected_layers(document.metadata()).collect::>(); + + let mut i = 0; + while i < target_layers.len() { + let layer = target_layers[i]; + + if layer_can_be_path_editable_input(layer, &mut document.network_interface) { + i += 1; + } else { + let children: Vec<_> = layer.children(document.metadata()).collect(); + + if !children.is_empty() { + target_layers.splice(i..i + 1, children); + } else { + // This layer is not path-editable and has no children, so remove it. + target_layers.remove(i); + } + } + } shape_editor.set_selected_layers(target_layers);