mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Show all nodes with no selection (#893)
* Show all nodes with no selection * Slight text tweaks * Rename to artwork Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
3a4a0eaf68
commit
81f365c999
5 changed files with 34 additions and 21 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -905,6 +905,7 @@ dependencies = [
|
|||
name = "dyn-any-derive"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"dyn-any",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
|
|
@ -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>) {
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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(_) => {
|
||||
|
|
|
@ -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"] }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue