pub struct Document {
pub format_version: u32,
pub compositions: CompMap,
pub nodes: NodeMap,
pub assets: AssetMap,
pub asset_order: Vec<AssetId>,
pub main: CompId,
}Fields§
§format_version: u32§compositions: CompMap§nodes: NodeMap§assets: AssetMap§asset_order: Vec<AssetId>Live/attached assets in UI order.
main: CompIdImplementations§
Source§impl Document
impl Document
pub fn empty() -> Self
pub fn create_node(&mut self, node: Node) -> NodeId
pub fn attach( &mut self, id: NodeId, parent: Parent, index: usize, ) -> Result<(), ModelError>
pub fn detach(&mut self, id: NodeId) -> Result<(Parent, usize), ModelError>
pub fn locate(&self, id: NodeId) -> Option<(Parent, usize)>
Sourcepub fn garbage_collect(&mut self)
pub fn garbage_collect(&mut self)
Drop arena nodes not reachable from any composition (call before save).
Sourcepub fn normalize_assets(&mut self)
pub fn normalize_assets(&mut self)
Rebuild asset_order to match the arena: every attached id must exist
and be unique. Any arena asset missing from the order gets appended.
(Call after loading legacy projects that predate asset_order.)
Sourcepub fn image_asset(&self, id: AssetId) -> Option<&ImageAsset>
pub fn image_asset(&self, id: AssetId) -> Option<&ImageAsset>
The embedded image asset behind id, if it is an image.
Sourcepub fn image_usage_count(&self, asset: AssetId) -> usize
pub fn image_usage_count(&self, asset: AssetId) -> usize
Number of image-layer nodes referencing asset.
Sourcepub fn font_asset_for_family(
&self,
family: &str,
) -> Option<(AssetId, &FontAsset)>
pub fn font_asset_for_family( &self, family: &str, ) -> Option<(AssetId, &FontAsset)>
The font asset whose family matches family, if the project has one.
Surfaces the AssetId (for removal) alongside the asset.
Sourcepub fn font_families(&self) -> Vec<String>
pub fn font_families(&self) -> Vec<String>
Sorted, deduplicated family keys of every font asset in the project.
Source§impl Document
impl Document
Sourcepub fn find_nodes_by_name<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = NodeId> + 'a
pub fn find_nodes_by_name<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = NodeId> + 'a
All live node ids whose name equals name. Lets hosts (games) find
nodes by name without tracking NodeIds across document loads.
Sourcepub fn set_static(
&mut self,
id: NodeId,
prop: &PropPath,
v: &Value,
) -> Result<Value, ModelError>
pub fn set_static( &mut self, id: NodeId, prop: &PropPath, v: &Value, ) -> Result<Value, ModelError>
Set the base value; returns previous base (for undo).
Sourcepub fn add_keyframe(
&mut self,
id: NodeId,
prop: &PropPath,
frame: Frame,
v: &Value,
) -> Result<Option<KeyframeData>, ModelError>
pub fn add_keyframe( &mut self, id: NodeId, prop: &PropPath, frame: Frame, v: &Value, ) -> Result<Option<KeyframeData>, ModelError>
Insert/update key at frame; returns replaced key if any (for undo).
pub fn remove_keyframe( &mut self, id: NodeId, prop: &PropPath, frame: Frame, ) -> Result<KeyframeData, ModelError>
pub fn restore_keyframe( &mut self, id: NodeId, prop: &PropPath, key: &KeyframeData, ) -> Result<(), ModelError>
pub fn move_keyframe( &mut self, id: NodeId, prop: &PropPath, from: Frame, to: Frame, ) -> Result<(), ModelError>
Sourcepub fn set_easing(
&mut self,
id: NodeId,
prop: &PropPath,
frame: Frame,
i: Interpolation,
o: EasingHandle,
e: EasingHandle,
) -> Result<(Interpolation, EasingHandle, EasingHandle), ModelError>
pub fn set_easing( &mut self, id: NodeId, prop: &PropPath, frame: Frame, i: Interpolation, o: EasingHandle, e: EasingHandle, ) -> Result<(Interpolation, EasingHandle, EasingHandle), ModelError>
Returns previous easing (for undo).