-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix hardcoded input indices #3829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
945e712
d4ae26e
8ea25ac
c0d60b7
1fb2cfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,8 @@ impl<'a> ModifyInputsContext<'a> { | |
| let mut post_node_input_connector = if parent == LayerNodeIdentifier::ROOT_PARENT { | ||
| InputConnector::Export(0) | ||
| } else { | ||
| InputConnector::node(parent.to_node(), 1) | ||
| const LAYER_SECONDARY_INPUT_INDEX: usize = 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Duplicated local Prompt for AI agents |
||
| InputConnector::node(parent.to_node(), LAYER_SECONDARY_INPUT_INDEX) | ||
| }; | ||
| // Skip layers based on skip_layer_nodes, which inserts the new layer at a certain index of the layer stack. | ||
| let mut current_index = 0; | ||
|
|
@@ -91,7 +92,7 @@ impl<'a> ModifyInputsContext<'a> { | |
| current_index += 1; | ||
| } | ||
| // Input as a sibling to the Layer node above | ||
| post_node_input_connector = InputConnector::node(*next_node_in_stack_id, 0); | ||
| post_node_input_connector = InputConnector::node(*next_node_in_stack_id, InputConnector::PRIMARY_INPUT_INDEX); | ||
| } else { | ||
| log::error!("Error getting post node: insert_index out of bounds"); | ||
| break; | ||
|
|
@@ -107,7 +108,7 @@ impl<'a> ModifyInputsContext<'a> { | |
| match pre_node_output_connector { | ||
| Some(OutputConnector::Node { node_id: pre_node_id, .. }) if !network_interface.is_layer(&pre_node_id, &[]) => { | ||
| // Update post_node_input_connector for the next iteration | ||
| post_node_input_connector = InputConnector::node(pre_node_id, 0); | ||
| post_node_input_connector = InputConnector::node(pre_node_id, InputConnector::PRIMARY_INPUT_INDEX); | ||
| // Insert directly under layer if moving to the end of a layer stack that ends with a non layer node that does not have an exposed primary input | ||
| let primary_is_exposed = network_interface.input_from_connector(&post_node_input_connector, &[]).is_some_and(|input| input.is_exposed()); | ||
| if !primary_is_exposed { | ||
|
|
@@ -320,7 +321,8 @@ impl<'a> ModifyInputsContext<'a> { | |
| // If inserting a 'Path' node, insert a 'Flatten Path' node if the type is `Graphic`. | ||
| // TODO: Allow the 'Path' node to operate on table data by utilizing the reference (index or ID?) for each row. | ||
| if node_definition.identifier == "Path" { | ||
| let layer_input_type = self.network_interface.input_type(&InputConnector::node(output_layer.to_node(), 1), &[]); | ||
| const LAYER_SECONDARY_INPUT_INDEX: usize = 1; | ||
| let layer_input_type = self.network_interface.input_type(&InputConnector::node(output_layer.to_node(), LAYER_SECONDARY_INPUT_INDEX), &[]); | ||
| if layer_input_type.compiled_nested_type() == Some(&concrete!(Table<Graphic>)) { | ||
| let Some(flatten_path_definition) = resolve_proto_node_type(graphene_std::vector_nodes::flatten_path::IDENTIFIER) else { | ||
| log::error!("Flatten Path does not exist in ModifyInputsContext::existing_node_id"); | ||
|
|
@@ -367,23 +369,23 @@ impl<'a> ModifyInputsContext<'a> { | |
| let Some(blend_node_id) = self.existing_proto_node_id(graphene_std::blending_nodes::blending::IDENTIFIER, true) else { | ||
| return; | ||
| }; | ||
| let input_connector = InputConnector::node(blend_node_id, 1); | ||
| let input_connector = InputConnector::node(blend_node_id, graphene_std::blending_nodes::blending::BlendModeInput::INDEX); | ||
| self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::BlendMode(blend_mode), false), false); | ||
| } | ||
|
|
||
| pub fn opacity_set(&mut self, opacity: f64) { | ||
| let Some(blend_node_id) = self.existing_proto_node_id(graphene_std::blending_nodes::blending::IDENTIFIER, true) else { | ||
| return; | ||
| }; | ||
| let input_connector = InputConnector::node(blend_node_id, 2); | ||
| let input_connector = InputConnector::node(blend_node_id, graphene_std::blending_nodes::blending::OpacityInput::INDEX); | ||
| self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::F64(opacity * 100.), false), false); | ||
| } | ||
|
|
||
| pub fn blending_fill_set(&mut self, fill: f64) { | ||
| let Some(blend_node_id) = self.existing_proto_node_id(graphene_std::blending_nodes::blending::IDENTIFIER, true) else { | ||
| return; | ||
| }; | ||
| let input_connector = InputConnector::node(blend_node_id, 3); | ||
| let input_connector = InputConnector::node(blend_node_id, graphene_std::blending_nodes::blending::FillInput::INDEX); | ||
| self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::F64(fill * 100.), false), false); | ||
| } | ||
|
|
||
|
|
@@ -392,7 +394,7 @@ impl<'a> ModifyInputsContext<'a> { | |
| let Some(clip_node_id) = self.existing_proto_node_id(graphene_std::blending_nodes::blending::IDENTIFIER, true) else { | ||
| return; | ||
| }; | ||
| let input_connector = InputConnector::node(clip_node_id, 4); | ||
| let input_connector = InputConnector::node(clip_node_id, graphene_std::blending_nodes::blending::ClipInput::INDEX); | ||
| self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::Bool(clip), false), false); | ||
| } | ||
|
|
||
|
|
@@ -505,10 +507,18 @@ impl<'a> ModifyInputsContext<'a> { | |
| let Some(brush_node_id) = self.existing_network_node_id("Brush", true) else { | ||
| return; | ||
| }; | ||
| self.set_input_with_refresh(InputConnector::node(brush_node_id, 1), NodeInput::value(TaggedValue::BrushStrokes(strokes), false), false); | ||
| const BRUSH_STROKES_INDEX: usize = 1; | ||
| self.set_input_with_refresh( | ||
| InputConnector::node(brush_node_id, BRUSH_STROKES_INDEX), | ||
| NodeInput::value(TaggedValue::BrushStrokes(strokes), false), | ||
| false, | ||
| ); | ||
| } | ||
|
|
||
| pub fn resize_artboard(&mut self, location: IVec2, dimensions: IVec2) { | ||
| const ARTBOARD_LOCATION_INDEX: usize = 2; | ||
| const ARTBOARD_DIMENSIONS_INDEX: usize = 3; | ||
|
|
||
| let Some(artboard_node_id) = self.existing_network_node_id("Artboard", true) else { | ||
| return; | ||
| }; | ||
|
|
@@ -524,8 +534,16 @@ impl<'a> ModifyInputsContext<'a> { | |
| dimensions.y *= -1; | ||
| location.y -= dimensions.y; | ||
| } | ||
| self.set_input_with_refresh(InputConnector::node(artboard_node_id, 2), NodeInput::value(TaggedValue::DVec2(location.into()), false), false); | ||
| self.set_input_with_refresh(InputConnector::node(artboard_node_id, 3), NodeInput::value(TaggedValue::DVec2(dimensions.into()), false), false); | ||
| self.set_input_with_refresh( | ||
| InputConnector::node(artboard_node_id, ARTBOARD_LOCATION_INDEX), | ||
| NodeInput::value(TaggedValue::DVec2(location.into()), false), | ||
| false, | ||
| ); | ||
| self.set_input_with_refresh( | ||
| InputConnector::node(artboard_node_id, ARTBOARD_DIMENSIONS_INDEX), | ||
| NodeInput::value(TaggedValue::DVec2(dimensions.into()), false), | ||
| false, | ||
| ); | ||
| } | ||
|
|
||
| /// Set the input, refresh the properties panel, and run the document graph if skip_rerender is false | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.