Skip to content

Show all nodes with no selection #893

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

Merged
merged 4 commits into from
Dec 21, 2022
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,35 @@ impl NodeGraphMessageHandler {
);
}

pub fn collate_properties(&self, node_graph_frame: &NodeGraphFrameLayer, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
pub fn collate_properties(&self, node_graph_frame: &NodeGraphFrameLayer, context: &mut NodePropertiesContext, sections: &mut Vec<LayoutGroup>) {
let mut network = &node_graph_frame.network;
for segement in &self.nested_path {
network = network.nodes.get(segement).and_then(|node| node.implementation.get_network()).unwrap();
}

let mut section = Vec::new();
// If empty, show all nodes in the network starting with the output
if self.selected_nodes.is_empty() {
let mut stack = vec![network.output];
let mut nodes = Vec::new();
while let Some(node_id) = stack.pop() {
let Some(document_node) = network.nodes.get(&node_id) else {
continue;
};

stack.extend(document_node.inputs.iter().filter_map(|input| if let NodeInput::Node(ref_id) = input { Some(*ref_id) } else { None }));
nodes.push((document_node, node_id));
}
for &(document_node, node_id) in nodes.iter().rev() {
sections.push(node_properties::generate_node_properties(document_node, node_id, context));
}
}
for node_id in &self.selected_nodes {
let Some(document_node) = network.nodes.get(node_id) else {
continue;
};

section.push(node_properties::generate_node_properties(document_node, *node_id, context));
sections.push(node_properties::generate_node_properties(document_node, *node_id, context));
}

section
}

fn send_graph(network: &NodeNetwork, responses: &mut VecDeque<Message>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static DOCUMENT_NODE_TYPES: &[DocumentNodeType] = &[
default: NodeInput::Network,
}],
outputs: &[FrontendGraphDataType::Raster],
properties: |_document_node, _node_id, _context| node_properties::string_properties("The input to the graph is the bitmap under the frame".to_string()),
properties: |_document_node, _node_id, _context| node_properties::string_properties("The graph's input is the artwork under the frame layer".to_string()),
},
DocumentNodeType {
name: "Output",
Expand All @@ -85,7 +85,7 @@ static DOCUMENT_NODE_TYPES: &[DocumentNodeType] = &[
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
}],
outputs: &[],
properties: |_document_node, _node_id, _context| node_properties::string_properties("The output to the graph is rendered in the frame".to_string()),
properties: |_document_node, _node_id, _context| node_properties::string_properties("The graph's output is rendered into the frame".to_string()),
},
DocumentNodeType {
name: "Grayscale",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,21 +291,17 @@ pub fn register_artwork_layer_properties(
vec![node_section_transform(layer, persistent_data)]
}
LayerDataType::NodeGraphFrame(node_graph_frame) => {
let is_graph_open = node_graph_message_handler.layer_path.as_ref().filter(|node_graph| *node_graph == &layer_path).is_some();
let selected_nodes = &node_graph_message_handler.selected_nodes;

let mut properties_sections = vec![node_section_transform(layer, persistent_data)];
if !selected_nodes.is_empty() && is_graph_open {
let mut context = crate::messages::portfolio::document::node_graph::NodePropertiesContext {
persistent_data,
document,
responses,
nested_path: &node_graph_message_handler.nested_path,
layer_path: &layer_path,
};
let parameters_sections = node_graph_message_handler.collate_properties(node_graph_frame, &mut context);
properties_sections.extend(parameters_sections.into_iter());
}

let mut context = crate::messages::portfolio::document::node_graph::NodePropertiesContext {
persistent_data,
document,
responses,
nested_path: &node_graph_message_handler.nested_path,
layer_path: &layer_path,
};
node_graph_message_handler.collate_properties(node_graph_frame, &mut context, &mut properties_sections);

properties_sections
}
LayerDataType::Folder(_) => {
Expand Down
3 changes: 3 additions & 0 deletions libraries/dyn-any/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ proc-macro = true
proc-macro2 = "1"
quote = "1"
syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro", "printing"] }

[dev-dependencies]
dyn-any = { path = "..", features = ["derive"] }