mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
more reorg; newtype Binds and Views
This commit is contained in:
parent
3e3276bed0
commit
f10fa309e5
27 changed files with 1017 additions and 892 deletions
|
|
@ -1,5 +1,37 @@
|
|||
use crate::*;
|
||||
|
||||
pub fn get_opt_arc_rwlock_midiclip <'a> (state: &App, src: impl Language)
|
||||
-> Perhaps<Option<Arc<RwLock<MidiClip>>>>
|
||||
{
|
||||
eval_word(src, |word|Ok(match word {
|
||||
|
||||
":selected" if let Selection::TrackClip {
|
||||
track, scene
|
||||
} = state.selection() => {
|
||||
state.scenes()[*scene].clips[*track].clone()
|
||||
},
|
||||
|
||||
//":selected-or-create" if let Selection::TrackClip {
|
||||
//track, scene
|
||||
//} = state.selection() => Some(if let Some(Some(clip)) = state.scenes()[*scene].clips.get(*track) {
|
||||
//clip.clone()
|
||||
//} else {
|
||||
//let clip: Arc<RwLock<MidiClip>> = Arc::new(RwLock::new(Default::default()));
|
||||
//state.scenes()[*scene].clips[*track] = Some(clip.clone());
|
||||
//clip
|
||||
//}),
|
||||
|
||||
_ => return err!("not a clip: {word}")
|
||||
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn get_opt_vec_opt_arc_rwlock_midiclip <'a> (_: &App, _: impl Language)
|
||||
-> Perhaps<Option<Vec<Option<Arc<RwLock<MidiClip>>>>>>
|
||||
{
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// A MIDI sequence.
|
||||
///
|
||||
/// ```
|
||||
|
|
@ -29,11 +61,11 @@ use crate::*;
|
|||
|
||||
impl MidiClip {
|
||||
pub fn new (
|
||||
name: impl AsRef<str>,
|
||||
looped: bool,
|
||||
length: usize,
|
||||
notes: Option<MidiData>,
|
||||
color: Option<ItemTheme>,
|
||||
name: impl AsRef<str>,
|
||||
looped: bool,
|
||||
length: usize,
|
||||
notes: Option<MidiData>,
|
||||
color: Option<ItemTheme>,
|
||||
) -> Self {
|
||||
Self {
|
||||
uuid: uuid::Uuid::new_v4(),
|
||||
|
|
@ -93,6 +125,8 @@ impl MidiClip {
|
|||
}
|
||||
|
||||
pub type MidiData = Vec<Vec<MidiMessage>>;
|
||||
impl PartialEq for MidiClip { fn eq (&self, other: &Self) -> bool { self.uuid == other.uuid } }
|
||||
impl Eq for MidiClip {}
|
||||
|
||||
#[macro_export] macro_rules! has_clip {
|
||||
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
|
|
@ -122,8 +156,12 @@ pub trait MidiClipController: HasMidiClip
|
|||
+ Namespace<Option<bool>>
|
||||
+ Namespace<Option<ItemTheme>>
|
||||
{
|
||||
#[command(Upsert = "upsert")]
|
||||
fn clip_upsert (&mut self) -> Perhaps<MidiClipCommand> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[command(SetColor = "clip/color")]
|
||||
#[command(SetColor = "color")]
|
||||
fn clip_set_color (&mut self, _color: Option<ItemTheme>) -> Perhaps<MidiClipCommand> {
|
||||
//(SetColor [t: usize, s: usize, c: ItemTheme]
|
||||
//clip.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
|
||||
|
|
@ -131,7 +169,7 @@ pub trait MidiClipController: HasMidiClip
|
|||
todo!()
|
||||
}
|
||||
|
||||
#[command(SetLoop = "clip/loop")]
|
||||
#[command(SetLoop = "loop")]
|
||||
fn clip_toggle_loop (&mut self, _looping: Option<bool>) -> Perhaps<MidiClipCommand> {
|
||||
//(SetLoop [t: usize, s: usize, l: bool] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
//("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap())))
|
||||
|
|
@ -139,11 +177,3 @@ pub trait MidiClipController: HasMidiClip
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
impl PartialEq for MidiClip {
|
||||
fn eq (&self, other: &Self) -> bool {
|
||||
self.uuid == other.uuid
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for MidiClip {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue