mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* Remove boolean ops and unused doc-legacy Operations * Remove Shape legacy layers * Remove legacy layer Properties panel code * Remove additional unused doc-legacy Operations * Removed unused rendering-related legacy-layer code * Upgrade dep so CI builds * Remove various additional unused functions and messages * Remove the LayerData trait * Remove RenderData struct and usages * Banish the Operations system * Further removals
28 lines
1.0 KiB
Rust
28 lines
1.0 KiB
Rust
use super::layer_info::LegacyLayer;
|
|
use crate::document::LayerId;
|
|
use crate::DocumentError;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// A layer that encapsulates other layers, including potentially more folders.
|
|
/// The contained layers are rendered in the same order they are stored.
|
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Default)]
|
|
pub struct FolderLegacyLayer {
|
|
/// The IDs of the [Layer]s contained within the Folder
|
|
pub layer_ids: Vec<LayerId>,
|
|
/// The [Layer]s contained in the folder
|
|
pub layers: Vec<LegacyLayer>,
|
|
}
|
|
|
|
impl FolderLegacyLayer {
|
|
pub fn layer(&self, layer_id: LayerId) -> Option<&LegacyLayer> {
|
|
let index = self.layer_ids.iter().position(|x| *x == layer_id).ok_or_else(|| DocumentError::LayerNotFound([layer_id].into())).ok()?;
|
|
Some(&self.layers[index])
|
|
}
|
|
|
|
pub fn layer_mut(&mut self, layer_id: LayerId) -> Option<&mut LegacyLayer> {
|
|
let index = self.layer_ids.iter().position(|x| *x == layer_id).ok_or_else(|| DocumentError::LayerNotFound([layer_id].into())).ok()?;
|
|
Some(&mut self.layers[index])
|
|
}
|
|
}
|