mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
replace impls with edn_command macro invocations
This commit is contained in:
parent
2afae4b6aa
commit
0d7f78e74f
1 changed files with 37 additions and 41 deletions
|
|
@ -13,19 +13,26 @@ command!(|self: TrackCommand, state: App|match self { _ => todo!("track command"
|
|||
SetLoop(usize, usize, bool),
|
||||
SetColor(usize, usize, ItemPalette),
|
||||
}
|
||||
impl EdnCommand<App> for ClipCommand {
|
||||
fn from_edn <'a> (state: &App, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
match (head, tail) {
|
||||
(Sym("get"), [a, b ]) => Self::Get(0, 0),
|
||||
(Sym("put"), [a, b, c ]) => Self::Put(0, 0, None),
|
||||
(Sym("enqueue"), [a, b ]) => Self::Enqueue(0, 0),
|
||||
(Sym("edit"), [a ]) => Self::Edit(None),
|
||||
(Sym("loop"), [a, b, c ]) => Self::SetLoop(0, 0, true),
|
||||
(Sym("color"), [a, b, c ]) => Self::SetColor(0, 0, ItemPalette::random()),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
edn_command!(ClipCommand: |state: App| {
|
||||
("get" [a: usize
|
||||
,b: usize] Self::Get(a.unwrap(), b.unwrap()))
|
||||
|
||||
("put" [a: usize
|
||||
,b: usize
|
||||
,c: Option<Arc<RwLock<MidiClip>>>] Self::Put(a, b, c))
|
||||
|
||||
("enqueue" [a: usize
|
||||
,b: usize] Self::Enqueue(a, b))
|
||||
|
||||
("edit" [a: Option<Arc<RwLock<MidiClip>>>] Self::Edit(a))
|
||||
|
||||
("loop" [a: usize
|
||||
,b: usize
|
||||
,c: bool] Self::SetLoop(a, b, c))
|
||||
|
||||
("color" [a: usize
|
||||
,b: usize] Self::SetColor(a, b, ItemPalette::random()))
|
||||
});
|
||||
#[derive(Clone, Debug)] pub enum SceneCommand {
|
||||
Add,
|
||||
Del(usize),
|
||||
|
|
@ -35,20 +42,14 @@ impl EdnCommand<App> for ClipCommand {
|
|||
SetColor(usize, ItemPalette),
|
||||
Enqueue(usize),
|
||||
}
|
||||
impl EdnCommand<App> for SceneCommand {
|
||||
fn from_edn <'a> (state: &App, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
match (head, tail) {
|
||||
(Sym("add"), [ ]) => Self::Add,
|
||||
(Sym("del"), [a ]) => Self::Del(0),
|
||||
(Sym("swap"), [a, b ]) => Self::Swap(0, 0),
|
||||
(Sym("size"), [a ]) => Self::SetSize(0),
|
||||
(Sym("zoom"), [a, ]) => Self::SetZoom(0),
|
||||
(Sym("color"), [a, b, ]) => Self::SetColor(0, ItemPalette::random()),
|
||||
(Sym("enqueue"), [a, ]) => Self::Enqueue(0),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
edn_command!(SceneCommand: |state: App| {
|
||||
("add" [] Self::Add)
|
||||
("del" [a: usize] Self::Del(0))
|
||||
("zoom" [a: usize] Self::SetZoom(a))
|
||||
("color" [a: usize] Self::SetColor(a, ItemPalette::random()))
|
||||
("enqueue" [a: usize] Self::Enqueue(a))
|
||||
("swap" [a: usize, b: usize] Self::Swap(a, b))
|
||||
});
|
||||
#[derive(Clone, Debug)] pub enum TrackCommand {
|
||||
Add,
|
||||
Del(usize),
|
||||
|
|
@ -58,20 +59,15 @@ impl EdnCommand<App> for SceneCommand {
|
|||
SetZoom(usize),
|
||||
SetColor(usize, ItemPalette),
|
||||
}
|
||||
impl EdnCommand<App> for TrackCommand {
|
||||
fn from_edn <'a> (state: &App, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
match (head, tail) {
|
||||
(Sym("add"), [ ]) => Self::Add,
|
||||
(Sym("del"), [a ]) => Self::Del(0),
|
||||
(Sym("stop"), [a ]) => Self::Stop(0),
|
||||
(Sym("swap"), [a, b ]) => Self::Swap(0, 0),
|
||||
(Sym("size"), [a ]) => Self::SetSize(0),
|
||||
(Sym("zoom"), [a, ]) => Self::SetZoom(0),
|
||||
(Sym("color"), [a, b, ]) => Self::SetColor(0, ItemPalette::random()),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
edn_command!(TrackCommand: |state: App| {
|
||||
("add" [] Self::Add)
|
||||
("size" [a: usize] Self::SetSize(a))
|
||||
("zoom" [a: usize] Self::SetZoom(a))
|
||||
("color" [a: usize] Self::SetColor(a, ItemPalette::random()))
|
||||
("del" [a: usize] Self::Del(a))
|
||||
("stop" [a: usize] Self::Stop(a))
|
||||
("swap" [a: usize, b: usize] Self::Swap(a, b))
|
||||
});
|
||||
pub trait Arrangement: HasClock + HasJack {
|
||||
fn tracks (&self) -> &Vec<ArrangerTrack>;
|
||||
fn tracks_mut (&mut self) -> &mut Vec<ArrangerTrack>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue