mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 12:08:11 +08: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:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
80d39c2be7
commit
4f637ee18b
Generated
+1
@@ -905,6 +905,7 @@ dependencies = [
|
|||||||
name = "dyn-any-derive"
|
name = "dyn-any-derive"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"dyn-any",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"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;
|
let mut network = &node_graph_frame.network;
|
||||||
for segement in &self.nested_path {
|
for segement in &self.nested_path {
|
||||||
network = network.nodes.get(segement).and_then(|node| node.implementation.get_network()).unwrap();
|
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 {
|
for node_id in &self.selected_nodes {
|
||||||
let Some(document_node) = network.nodes.get(node_id) else {
|
let Some(document_node) = network.nodes.get(node_id) else {
|
||||||
continue;
|
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>) {
|
fn send_graph(network: &NodeNetwork, responses: &mut VecDeque<Message>) {
|
||||||
|
|||||||
+2
-2
@@ -73,7 +73,7 @@ static DOCUMENT_NODE_TYPES: &[DocumentNodeType] = &[
|
|||||||
default: NodeInput::Network,
|
default: NodeInput::Network,
|
||||||
}],
|
}],
|
||||||
outputs: &[FrontendGraphDataType::Raster],
|
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 {
|
DocumentNodeType {
|
||||||
name: "Output",
|
name: "Output",
|
||||||
@@ -85,7 +85,7 @@ static DOCUMENT_NODE_TYPES: &[DocumentNodeType] = &[
|
|||||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||||
}],
|
}],
|
||||||
outputs: &[],
|
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 {
|
DocumentNodeType {
|
||||||
name: "Grayscale",
|
name: "Grayscale",
|
||||||
|
|||||||
@@ -291,21 +291,17 @@ pub fn register_artwork_layer_properties(
|
|||||||
vec![node_section_transform(layer, persistent_data)]
|
vec![node_section_transform(layer, persistent_data)]
|
||||||
}
|
}
|
||||||
LayerDataType::NodeGraphFrame(node_graph_frame) => {
|
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)];
|
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 {
|
let mut context = crate::messages::portfolio::document::node_graph::NodePropertiesContext {
|
||||||
persistent_data,
|
persistent_data,
|
||||||
document,
|
document,
|
||||||
responses,
|
responses,
|
||||||
nested_path: &node_graph_message_handler.nested_path,
|
nested_path: &node_graph_message_handler.nested_path,
|
||||||
layer_path: &layer_path,
|
layer_path: &layer_path,
|
||||||
};
|
};
|
||||||
let parameters_sections = node_graph_message_handler.collate_properties(node_graph_frame, &mut context);
|
node_graph_message_handler.collate_properties(node_graph_frame, &mut context, &mut properties_sections);
|
||||||
properties_sections.extend(parameters_sections.into_iter());
|
|
||||||
}
|
|
||||||
properties_sections
|
properties_sections
|
||||||
}
|
}
|
||||||
LayerDataType::Folder(_) => {
|
LayerDataType::Folder(_) => {
|
||||||
|
|||||||
@@ -17,3 +17,6 @@ proc-macro = true
|
|||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro", "printing"] }
|
syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro", "printing"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
dyn-any = { path = "..", features = ["derive"] }
|
||||||
|
|||||||
Reference in New Issue
Block a user