Add asset pane

This commit is contained in:
Skyler Lehmkuhl
2025-11-30 06:54:53 -05:00
parent 8f830b7799
commit 4d1e052ee7
22 changed files with 2311 additions and 179 deletions
@@ -3,7 +3,7 @@
//! The Document represents a complete animation project with settings
//! and a root graphics object containing the scene graph.
use crate::clip::{AudioClip, VideoClip, VectorClip};
use crate::clip::{AudioClip, ImageAsset, VideoClip, VectorClip};
use crate::layer::AnyLayer;
use crate::shape::ShapeColor;
use serde::{Deserialize, Serialize};
@@ -103,6 +103,9 @@ pub struct Document {
/// Audio clip library - sampled audio and MIDI clips
pub audio_clips: HashMap<Uuid, AudioClip>,
/// Image asset library - static images for fill textures
pub image_assets: HashMap<Uuid, ImageAsset>,
/// Current playback time in seconds
#[serde(skip)]
pub current_time: f64,
@@ -122,6 +125,7 @@ impl Default for Document {
vector_clips: HashMap::new(),
video_clips: HashMap::new(),
audio_clips: HashMap::new(),
image_assets: HashMap::new(),
current_time: 0.0,
}
}
@@ -272,6 +276,30 @@ impl Document {
pub fn remove_audio_clip(&mut self, id: &Uuid) -> Option<AudioClip> {
self.audio_clips.remove(id)
}
// === IMAGE ASSET METHODS ===
/// Add an image asset to the library
pub fn add_image_asset(&mut self, asset: ImageAsset) -> Uuid {
let id = asset.id;
self.image_assets.insert(id, asset);
id
}
/// Get an image asset by ID
pub fn get_image_asset(&self, id: &Uuid) -> Option<&ImageAsset> {
self.image_assets.get(id)
}
/// Get a mutable image asset by ID
pub fn get_image_asset_mut(&mut self, id: &Uuid) -> Option<&mut ImageAsset> {
self.image_assets.get_mut(id)
}
/// Remove an image asset from the library
pub fn remove_image_asset(&mut self, id: &Uuid) -> Option<ImageAsset> {
self.image_assets.remove(id)
}
}
#[cfg(test)]