mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-08 15:28:00 +00:00
Allow groups to work with the node graph (#1452)
* Initial groups * Improve graph arangement * Fix selecting nested layers * Code review pass * Change log --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
f4ec76f35e
commit
58660f5548
19 changed files with 397 additions and 306 deletions
|
@ -616,13 +616,23 @@ impl NodeNetwork {
|
|||
FlowIter {
|
||||
stack: self.outputs.iter().map(|output| output.node_id).collect(),
|
||||
network: self,
|
||||
primary: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primary_flow_from_opt(&self, id: Option<NodeId>) -> impl Iterator<Item = (&DocumentNode, u64)> {
|
||||
pub fn primary_flow_from_node(&self, id: Option<NodeId>) -> impl Iterator<Item = (&DocumentNode, u64)> {
|
||||
FlowIter {
|
||||
stack: id.map_or_else(|| self.outputs.iter().map(|output| output.node_id).collect(), |id| vec![id]),
|
||||
network: self,
|
||||
primary: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_dependencies(&self, id: NodeId) -> impl Iterator<Item = (&DocumentNode, u64)> {
|
||||
FlowIter {
|
||||
stack: vec![id],
|
||||
network: self,
|
||||
primary: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,6 +674,7 @@ impl NodeNetwork {
|
|||
struct FlowIter<'a> {
|
||||
stack: Vec<NodeId>,
|
||||
network: &'a NodeNetwork,
|
||||
primary: bool,
|
||||
}
|
||||
impl<'a> Iterator for FlowIter<'a> {
|
||||
type Item = (&'a DocumentNode, NodeId);
|
||||
|
@ -671,13 +682,11 @@ impl<'a> Iterator for FlowIter<'a> {
|
|||
loop {
|
||||
let node_id = self.stack.pop()?;
|
||||
if let Some(document_node) = self.network.nodes.get(&node_id) {
|
||||
self.stack.extend(
|
||||
document_node
|
||||
.inputs
|
||||
.iter()
|
||||
.take(1) // Only show the primary input
|
||||
.filter_map(|input| if let NodeInput::Node { node_id: ref_id, .. } = input { Some(*ref_id) } else { None }),
|
||||
);
|
||||
let inputs = document_node.inputs.iter().take(if self.primary { 1 } else { usize::MAX });
|
||||
let node_ids = inputs.filter_map(|input| if let NodeInput::Node { node_id, .. } = input { Some(*node_id) } else { None });
|
||||
|
||||
self.stack.extend(node_ids);
|
||||
|
||||
return Some((document_node, node_id));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue