Add the document graph (#1217)

* Thumbnails for the layer node

* Raster node graph frames

* Downscale to a random resolution

* Cleanup and bug fixes

* Generate paths before duplicating outputs

* Fix stable id test

* Add a document node graph

* Fix merge conflict

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-05-26 17:22:58 +01:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 8d778e4848
commit 15eb4df8d4
18 changed files with 264 additions and 152 deletions
+18
View File
@@ -253,6 +253,24 @@ impl Layer {
}
}
/// Gets a child layer of this layer, by a path. If the layer with id 1 is inside a folder with id 0, the path will be [0, 1].
pub fn child(&self, path: &[LayerId]) -> Option<&Layer> {
let mut layer = self;
for id in path {
layer = layer.as_folder().ok()?.layer(*id)?;
}
Some(layer)
}
/// Gets a child layer of this layer, by a path. If the layer with id 1 is inside a folder with id 0, the path will be [0, 1].
pub fn child_mut(&mut self, path: &[LayerId]) -> Option<&mut Layer> {
let mut layer = self;
for id in path {
layer = layer.as_folder_mut().ok()?.layer_mut(*id)?;
}
Some(layer)
}
/// Iterate over the layers encapsulated by this layer.
/// If the [Layer type](Layer::data) is not a folder, the only item in the iterator will be the layer itself.
/// If the [Layer type](Layer::data) wraps a [Folder](LayerDataType::Folder), the iterator will recursively yield all the layers contained in the folder as well as potential sub-folders.