mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
wip: simplify clip traits to implement upsert
This commit is contained in:
parent
8b96ddb411
commit
c5d6ce24b2
5 changed files with 178 additions and 184 deletions
19
src/pool.rs
19
src/pool.rs
|
|
@ -19,6 +19,21 @@ use crate::*;
|
|||
#[cfg(feature = "sampler")] pub samples: Arc<RwLock<Vec<Arc<RwLock<Sample>>>>>,
|
||||
}
|
||||
|
||||
impl HasClips for Pool {
|
||||
fn clip (&self) -> Option<Arc<RwLock<MidiClip>>> {
|
||||
self.clips.read().get(self.clip_index()).map(|c|c.clone())
|
||||
}
|
||||
fn clip_mut (&self) -> &mut Option<Arc<RwLock<MidiClip>>> {
|
||||
todo!()
|
||||
}
|
||||
fn clips <'a> (&'a self) -> RwLockReadGuard<'a, Clips> {
|
||||
self.clips.read()
|
||||
}
|
||||
fn clips_mut <'a> (&'a self) -> RwLockWriteGuard<'a, Clips> {
|
||||
self.clips.write()
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays and edits clip length.
|
||||
#[derive(Clone, Debug, Default)] pub struct ClipLength {
|
||||
/// Pulses per beat (quaver)
|
||||
|
|
@ -326,10 +341,6 @@ pub trait PoolController: HasPool
|
|||
|
||||
}
|
||||
|
||||
has_clip!(|self: Pool|self.clips().get(self.clip_index()).map(|c|c.clone()));
|
||||
|
||||
impl_has_clips!(|self: Pool|self.clips);
|
||||
|
||||
impl_from!(Pool: |clip:&Arc<RwLock<MidiClip>>|{
|
||||
let model = Self::default();
|
||||
model.clips.try_write().unwrap().push(clip.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue