mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
nice top level command dispatch
This commit is contained in:
parent
aad7aa6c5e
commit
8dcf73c18c
8 changed files with 137 additions and 144 deletions
|
|
@ -13,6 +13,6 @@ impl HasClips for ExampleClips {
|
|||
|
||||
fn main () -> Usually<()> {
|
||||
let mut phrases = ExampleClips(vec![]);
|
||||
MidiPoolCommand::Import(0, String::from("./example.mid")).execute(&mut phrases)?;
|
||||
PoolClipCommand::Import(0, String::from("./example.mid")).execute(&mut phrases)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use GrooveboxCommand as GrvCmd;
|
|||
use ArrangerCommand as ArrCmd;
|
||||
use SamplerCommand as SmplCmd;
|
||||
use MidiEditCommand as EditCmd;
|
||||
use MidiPoolCommand as PoolCmd;
|
||||
use PoolClipCommand as PoolCmd;
|
||||
|
||||
handle!(TuiIn: |self: App, input| Ok(None));
|
||||
//handle!(TuiIn: |self: Sequencer, input|SequencerCommand::execute_with_state(self, input.event()));
|
||||
|
|
@ -34,36 +34,28 @@ handle!(TuiIn: |self: App, input| Ok(None));
|
|||
impl EdnCommand<App> for AppCommand {
|
||||
fn from_edn <'a> (state: &App, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
match (head, tail) {
|
||||
(Key("clear"), [ ]) =>
|
||||
Self::Clear,
|
||||
(Key("clip"), [a, b @ ..]) =>
|
||||
Self::Clip(ClipCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("clock"), [a, b @ ..]) =>
|
||||
Self::Clock(ClockCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("color"), [a ]) =>
|
||||
Self::Color(ItemPalette::default()),
|
||||
(Key("compact"), [a ]) =>
|
||||
Self::Compact(true),
|
||||
(Key("editor"), [a, b @ ..]) =>
|
||||
Self::Editor(MidiEditCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("enqueue"), [a ]) =>
|
||||
Self::Enqueue(None),
|
||||
(Key("history"), [a ]) =>
|
||||
Self::History(0),
|
||||
(Key("pool"), [a, b @ ..]) =>
|
||||
Self::Pool(PoolCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("sampler"), [a, b @ ..]) =>
|
||||
Self::Sampler(SamplerCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("scene"), [a, b @ ..]) =>
|
||||
Self::Scene(SceneCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("select"), [a ]) =>
|
||||
Self::Select(ArrangerSelection::Mix),
|
||||
(Key("stop-all"), [ ]) =>
|
||||
Self::StopAll,
|
||||
(Key("track"), [a, b @ ..]) =>
|
||||
Self::Track(TrackCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("zoom"), [a ]) =>
|
||||
Self::Zoom(0),
|
||||
(Key("clear"), []) => Self::Clear,
|
||||
(Key("stop-all"), []) => Self::StopAll,
|
||||
|
||||
(Key("color"), [a]) => Self::Color(ItemPalette::default()),
|
||||
(Key("compact"), [a]) => Self::Compact(true),
|
||||
(Key("enqueue"), [a]) => Self::Enqueue(None),
|
||||
(Key("history"), [a]) => Self::History(0),
|
||||
(Key("select"), [a]) => Self::Select(ArrangerSelection::Mix),
|
||||
(Key("zoom"), [a]) => Self::Zoom(0),
|
||||
|
||||
(Key("clock"), [a, b @ ..]) => Self::Clock(ClockCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("track"), [a, b @ ..]) => Self::Track(TrackCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("scene"), [a, b @ ..]) => Self::Scene(SceneCommand::from_edn(state, &a.to_ref(), b)),
|
||||
(Key("clip"), [a, b @ ..]) => Self::Clip(ClipCommand::from_edn(state, &a.to_ref(), b)),
|
||||
|
||||
(Key("pool"), [a, b @ ..]) if let Some(pool) = state.pool.as_ref() =>
|
||||
Self::Pool(PoolCommand::from_edn(pool, &a.to_ref(), b)),
|
||||
(Key("editor"), [a, b @ ..]) if let Some(editor) = state.editor.as_ref() =>
|
||||
Self::Editor(MidiEditCommand::from_edn(editor, &a.to_ref(), b)),
|
||||
(Key("sampler"), [a, b @ ..]) if let Some(sampler) = state.sampler.as_ref() =>
|
||||
Self::Sampler(SamplerCommand::from_edn(sampler, &a.to_ref(), b)),
|
||||
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +335,7 @@ command!(|self: TrackCommand, state: App|match self { _ => todo!("track command"
|
|||
//undo
|
||||
//},
|
||||
//// reload clip in editor to update color
|
||||
//PoolCommand::Clip(MidiPoolCommand::SetColor(index, _)) => {
|
||||
//PoolCommand::Clip(PoolClipCommand::SetColor(index, _)) => {
|
||||
//let undo = cmd.delegate(&mut state.pool, Self::Pool)?;
|
||||
//state.editor.set_clip(state.pool.clip().as_ref());
|
||||
//undo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue