mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
wip: down to 25 errors woo
This commit is contained in:
parent
89288f2920
commit
6ce83fb27a
25 changed files with 688 additions and 620 deletions
|
|
@ -1,7 +1,83 @@
|
|||
use crate::*;
|
||||
|
||||
#[tengri_proc::expose]
|
||||
impl Arrangement {
|
||||
fn _todo_usize_stub_ (&self) -> usize { todo!() }
|
||||
fn _todo_arc_str_stub_ (&self) -> Arc<str> { todo!() }
|
||||
fn _todo_item_theme_stub (&self) -> ItemTheme { todo!() }
|
||||
fn _todo_opt_item_theme_stub (&self) -> Option<ItemTheme> { todo!() }
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Arrangement)]
|
||||
impl ArrangementCommand {
|
||||
/// Set the selection
|
||||
fn select (arranger: &mut Arrangement, s: Option<Selection>) -> Perhaps<Self> {
|
||||
arranger.selected = s;
|
||||
// autoedit: load focused clip in editor.
|
||||
if let Some(ref mut editor) = arranger.editor {
|
||||
editor.set_clip(match arranger.selected {
|
||||
Some(Selection::TrackClip { track, scene })
|
||||
if let Some(Some(Some(clip))) = arranger
|
||||
.scenes.get(scene)
|
||||
.map(|s|s.clips.get(track)) => Some(clip),
|
||||
_ => None
|
||||
});
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
/// Launch a clip or scene
|
||||
fn launch (arranger: &mut Arrangement) -> Perhaps<Self> {
|
||||
use Selection::*;
|
||||
match arranger.selected {
|
||||
Some(Track(t)) => {
|
||||
arranger.tracks[t].sequencer.enqueue_next(None)
|
||||
},
|
||||
Some(TrackClip { track, scene }) => {
|
||||
arranger.tracks[track].sequencer.enqueue_next(arranger.scenes[scene].clips[track].as_ref())
|
||||
},
|
||||
Some(Scene(s)) => {
|
||||
for t in 0..arranger.tracks.len() {
|
||||
arranger.tracks[t].sequencer.enqueue_next(arranger.scenes[s].clips[t].as_ref())
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
Ok(None)
|
||||
}
|
||||
/// Set the color of the selected entity
|
||||
fn set_color (arranger: &mut Arrangement, palette: Option<ItemTheme>) -> Option<ItemTheme> {
|
||||
use Selection::*;
|
||||
let palette = palette.unwrap_or_else(||ItemTheme::random());
|
||||
Some(match arranger.selected {
|
||||
Some(Mix) => {
|
||||
let old = arranger.color;
|
||||
arranger.color = palette;
|
||||
old
|
||||
},
|
||||
Some(Scene(s)) => {
|
||||
let old = arranger.scenes[s].color;
|
||||
arranger.scenes[s].color = palette;
|
||||
old
|
||||
}
|
||||
Some(Track(t)) => {
|
||||
let old = arranger.tracks[t].color;
|
||||
arranger.tracks[t].color = palette;
|
||||
old
|
||||
}
|
||||
Some(TrackClip { track, scene }) => {
|
||||
if let Some(ref clip) = arranger.scenes[scene].clips[track] {
|
||||
let mut clip = clip.write().unwrap();
|
||||
let old = clip.color;
|
||||
clip.color = palette;
|
||||
old
|
||||
} else {
|
||||
return None
|
||||
}
|
||||
},
|
||||
_ => todo!()
|
||||
})
|
||||
}
|
||||
|
||||
fn track (arranger: &mut Arrangement, track: TrackCommand) -> Perhaps<Self> {
|
||||
todo!("delegate")
|
||||
}
|
||||
|
|
@ -9,9 +85,9 @@ impl ArrangementCommand {
|
|||
let index = arranger.track_add(None, None, &[], &[])?.0;
|
||||
arranger.selected = match arranger.selected {
|
||||
Some(Selection::Track(_)) =>
|
||||
Selection::Track(index),
|
||||
Some(Selection::Track(index)),
|
||||
Some(Selection::TrackClip { track, scene }) =>
|
||||
Selection::TrackClip { track: index, scene },
|
||||
Some(Selection::TrackClip { track: index, scene }),
|
||||
_ => arranger.selected
|
||||
};
|
||||
Ok(Some(Self::TrackDelete { index }))
|
||||
|
|
@ -38,14 +114,14 @@ impl ArrangementCommand {
|
|||
Ok(None)
|
||||
//TODO:Ok(Some(Self::TrackAdd ( index, track: Some(deleted_track) })
|
||||
}
|
||||
fn midi_in (arranger: &mut Arrangement, input: InputCommand) -> Perhaps<Self> {
|
||||
fn midi_in (arranger: &mut Arrangement, input: MidiInputCommand) -> Perhaps<Self> {
|
||||
todo!("delegate")
|
||||
}
|
||||
fn midi_in_add (arranger: &mut Arrangement) -> Perhaps<Self> {
|
||||
arranger.midi_in_add()?;
|
||||
Ok(None)
|
||||
}
|
||||
fn midi_out (arranger: &mut Arrangement, input: OutputCommand) -> Perhaps<Self> {
|
||||
fn midi_out (arranger: &mut Arrangement, input: MidiOutputCommand) -> Perhaps<Self> {
|
||||
todo!("delegate")
|
||||
}
|
||||
fn midi_out_add (arranger: &mut Arrangement) -> Perhaps<Self> {
|
||||
|
|
@ -65,10 +141,10 @@ impl ArrangementCommand {
|
|||
fn scene_add (arranger: &mut Arrangement) -> Perhaps<Self> {
|
||||
let index = arranger.scene_add(None, None)?.0;
|
||||
arranger.selected = match arranger.selected {
|
||||
Selection::Scene(_) =>
|
||||
Selection::Scene(index),
|
||||
Selection::TrackClip { track, scene } =>
|
||||
Selection::TrackClip { track, scene: index },
|
||||
Some(Selection::Scene(_)) =>
|
||||
Some(Selection::Scene(index)),
|
||||
Some(Selection::TrackClip { track, scene }) =>
|
||||
Some(Selection::TrackClip { track, scene: index }),
|
||||
_ => arranger.selected
|
||||
};
|
||||
Ok(None) // TODO
|
||||
|
|
@ -80,7 +156,8 @@ impl ArrangementCommand {
|
|||
fn scene_delete (arranger: &mut Arrangement, index: usize) -> Perhaps<Self> {
|
||||
let scenes = arranger.scenes_mut();
|
||||
Ok(if scenes.get(index).is_some() {
|
||||
Some(scenes.remove(index))
|
||||
let _scene = scenes.remove(index);
|
||||
None
|
||||
} else {
|
||||
None
|
||||
})
|
||||
|
|
@ -90,6 +167,7 @@ impl ArrangementCommand {
|
|||
let clip = arranger.scenes[index].clips[track].as_ref();
|
||||
arranger.tracks[track].sequencer.enqueue_next(clip);
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
fn clip (arranger: &mut Arrangement, scene: ClipCommand) -> Perhaps<Self> {
|
||||
todo!("delegate")
|
||||
|
|
@ -120,52 +198,20 @@ impl ArrangementCommand {
|
|||
//("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap())))
|
||||
todo!()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[tengri_proc::command(MidiClip)]
|
||||
impl ClipCommand {
|
||||
fn set_color (clip: &mut MidiClip, color: Option<ItemTheme>) -> Perhaps<Self> {
|
||||
//(SetColor [t: usize, s: usize, c: ItemTheme]
|
||||
//clip.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
|
||||
//("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random())))
|
||||
todo!()
|
||||
}
|
||||
fn set_loop (clip: &mut MidiClip, looping: Option<bool>) -> Perhaps<Self> {
|
||||
//(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())))
|
||||
todo!()
|
||||
impl<'state> Context<'state, TrackCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<TrackCommand> {
|
||||
Context::get(&self, iter)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Device)]
|
||||
impl DeviceCommand {
|
||||
}
|
||||
|
||||
#[tengri_proc::command(JackMidiIn)]
|
||||
impl InputCommand {
|
||||
}
|
||||
|
||||
#[tengri_proc::command(JackMidiOut)]
|
||||
impl OutputCommand {
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Scene)]
|
||||
impl SceneCommand {
|
||||
fn set_name (scene: &mut Scene, mut name: Arc<str>) -> Perhaps<Self> {
|
||||
std::mem::swap(&mut scene.name, &mut name);
|
||||
Ok(Some(Self::SetName { name }))
|
||||
}
|
||||
fn set_color (scene: &mut Scene, mut color: ItemTheme) -> Perhaps<Self> {
|
||||
std::mem::swap(&mut scene.color, &mut color);
|
||||
Ok(Some(Self::SetColor { color }))
|
||||
}
|
||||
fn set_size (scene: &mut Scene, size: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_zoom (scene: &mut Scene, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
#[tengri_proc::expose]
|
||||
impl Track {
|
||||
fn _todo_opt_bool_stub_ (&self) -> Option<bool> { todo!() }
|
||||
fn _todo_usize_stub_ (&self) -> usize { todo!() }
|
||||
fn _todo_arc_str_stub_ (&self) -> Arc<str> { todo!() }
|
||||
fn _todo_item_theme_stub (&self) -> ItemTheme { todo!() }
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Track)]
|
||||
|
|
@ -174,8 +220,8 @@ impl TrackCommand {
|
|||
std::mem::swap(&mut name, &mut track.name);
|
||||
Ok(Some(Self::SetName { name }))
|
||||
}
|
||||
fn set_color (track: &mut Track, color: ItemTheme) -> Perhaps<Self> {
|
||||
std::mem::swap(color, track.color);
|
||||
fn set_color (track: &mut Track, mut color: ItemTheme) -> Perhaps<Self> {
|
||||
std::mem::swap(&mut color, &mut track.color);
|
||||
Ok(Some(Self::SetColor { color }))
|
||||
}
|
||||
fn set_mute (track: &mut Track, value: Option<bool>) -> Perhaps<Self> {
|
||||
|
|
@ -205,3 +251,66 @@ impl TrackCommand {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'state> Context<'state, SceneCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<SceneCommand> {
|
||||
Context::get(&self, iter)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'state> Context<'state, ClipCommand> for Arrangement {
|
||||
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<ClipCommand> {
|
||||
Context::get(&self, iter)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::expose]
|
||||
impl Scene {
|
||||
fn _todo_opt_bool_stub_ (&self) -> Option<bool> { todo!() }
|
||||
fn _todo_usize_stub_ (&self) -> usize { todo!() }
|
||||
fn _todo_arc_str_stub_ (&self) -> Arc<str> { todo!() }
|
||||
fn _todo_item_theme_stub (&self) -> ItemTheme { todo!() }
|
||||
}
|
||||
|
||||
#[tengri_proc::command(Scene)]
|
||||
impl SceneCommand {
|
||||
fn set_name (scene: &mut Scene, mut name: Arc<str>) -> Perhaps<Self> {
|
||||
std::mem::swap(&mut scene.name, &mut name);
|
||||
Ok(Some(Self::SetName { name }))
|
||||
}
|
||||
fn set_color (scene: &mut Scene, mut color: ItemTheme) -> Perhaps<Self> {
|
||||
std::mem::swap(&mut scene.color, &mut color);
|
||||
Ok(Some(Self::SetColor { color }))
|
||||
}
|
||||
fn set_size (scene: &mut Scene, size: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_zoom (scene: &mut Scene, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::expose]
|
||||
impl MidiClip {
|
||||
fn _todo_opt_bool_stub_ (&self) -> Option<bool> { todo!() }
|
||||
fn _todo_bool_stub_ (&self) -> bool { todo!() }
|
||||
fn _todo_usize_stub_ (&self) -> usize { todo!() }
|
||||
fn _todo_arc_str_stub_ (&self) -> Arc<str> { todo!() }
|
||||
fn _todo_item_theme_stub (&self) -> ItemTheme { todo!() }
|
||||
fn _todo_opt_item_theme_stub (&self) -> Option<ItemTheme> { todo!() }
|
||||
}
|
||||
|
||||
#[tengri_proc::command(MidiClip)]
|
||||
impl ClipCommand {
|
||||
fn set_color (clip: &mut MidiClip, color: Option<ItemTheme>) -> Perhaps<Self> {
|
||||
//(SetColor [t: usize, s: usize, c: ItemTheme]
|
||||
//clip.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
|
||||
//("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random())))
|
||||
todo!()
|
||||
}
|
||||
fn set_loop (clip: &mut MidiClip, looping: Option<bool>) -> Perhaps<Self> {
|
||||
//(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())))
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue