Fix artboard thumbnails (#1342)

* Fix artboard thumbnails

* Use GraphIdentifier instead of option

* Fix warnings introduced by artboard nodes
This commit is contained in:
0HyperCube 2023-07-30 20:37:37 +01:00 committed by GitHub
parent f151ba39b5
commit 2b9337406a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 64 deletions

View file

@ -887,24 +887,24 @@ impl NodeNetwork {
/// Create a [`RecursiveNodeIter`] that iterates over all [`DocumentNode`]s, including ones that are deeply nested.
pub fn recursive_nodes(&self) -> RecursiveNodeIter {
let nodes = self.nodes.iter().map(|(id, node)| (node, self, vec![*id])).collect();
let nodes = self.nodes.values().collect();
RecursiveNodeIter { nodes }
}
}
/// An iterator over all [`DocumentNode`]s, including ones that are deeply nested.
pub struct RecursiveNodeIter<'a> {
nodes: Vec<(&'a DocumentNode, &'a NodeNetwork, Vec<NodeId>)>,
nodes: Vec<&'a DocumentNode>,
}
impl<'a> Iterator for RecursiveNodeIter<'a> {
type Item = (&'a DocumentNode, &'a NodeNetwork, Vec<NodeId>);
type Item = &'a DocumentNode;
fn next(&mut self) -> Option<Self::Item> {
let (node, network, path) = self.nodes.pop()?;
let node = self.nodes.pop()?;
if let DocumentNodeImplementation::Network(network) = &node.implementation {
self.nodes.extend(network.nodes.iter().map(|(id, node)| (node, network, [path.as_slice(), &[*id]].concat())));
self.nodes.extend(network.nodes.values());
}
Some((node, network, path))
Some(node)
}
}