mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
parent
06c26f44d0
commit
255cdead28
7 changed files with 35 additions and 3 deletions
|
|
@ -212,8 +212,8 @@ impl Document {
|
|||
/// Adds a new layer to the folder specified by `path`.
|
||||
/// Passing a negative `insert_index` indexes relative to the end.
|
||||
/// -1 is equivalent to adding the layer to the top.
|
||||
pub fn add_layer(&mut self, path: &[LayerId], layer: Layer, insert_index: isize) -> Result<LayerId, DocumentError> {
|
||||
let _ = self.layer_mut(path).map(|x| x.cache_dirty = true);
|
||||
pub fn add_layer(&mut self, path: &[LayerId], mut layer: Layer, insert_index: isize) -> Result<LayerId, DocumentError> {
|
||||
layer.render();
|
||||
let folder = self.folder_mut(path)?;
|
||||
folder.add_layer(layer, insert_index).ok_or(DocumentError::IndexOutOfBounds)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ impl Folder {
|
|||
self.layers.as_slice()
|
||||
}
|
||||
|
||||
pub fn layers_mut(&mut self) -> &mut [Layer] {
|
||||
self.layers.as_mut_slice()
|
||||
}
|
||||
|
||||
pub fn layer(&self, id: LayerId) -> Option<&Layer> {
|
||||
let pos = self.layer_ids.iter().position(|x| *x == id)?;
|
||||
Some(&self.layers[pos])
|
||||
|
|
|
|||
|
|
@ -175,6 +175,10 @@ impl Layer {
|
|||
self.data.to_kurbo_path(self.transform, self.style)
|
||||
}
|
||||
|
||||
pub fn current_bounding_box(&self) -> Option<[DVec2; 2]> {
|
||||
self.bounding_box(self.transform, self.style)
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self, transform: glam::DAffine2, style: style::PathStyle) -> Option<[DVec2; 2]> {
|
||||
if let Ok(folder) = self.as_folder() {
|
||||
folder.bounding_box(transform)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue