Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions editor/src/messages/tool/common_functionality/utility_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Vector>
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<Vector>)) {
// Must be a layer with a path-editable input type.
if !layer_can_be_path_editable_input(first_layer, network_interface) {
return None;
}

Expand All @@ -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<Vector>)) || output_type.compiled_nested_type() == Some(&concrete!(Table<Graphic>))
}
22 changes: 20 additions & 2 deletions editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<Vec<_>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: New descendant-expansion selection logic desynchronizes shape_editor layer targeting from document-selected nodes, but later edits still resolve layer from document selection, causing wrong-layer operations or aborted actions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At editor/src/messages/tool/tool_messages/path_tool.rs, line 1581:

<comment>New descendant-expansion selection logic desynchronizes `shape_editor` layer targeting from document-selected nodes, but later edits still resolve layer from document selection, causing wrong-layer operations or aborted actions.</comment>

<file context>
@@ -1578,7 +1578,26 @@ impl Fsm for PathToolFsmState {
 			(_, 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::<Vec<_>>();
+
+				let mut i = 0;
</file context>


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);

Expand Down
Loading