mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: refactor pt.31: 41 errors
This commit is contained in:
parent
28e15d3f56
commit
8b5931c321
3 changed files with 98 additions and 89 deletions
|
|
@ -64,7 +64,7 @@ impl InputToCommand<Tui, ArrangerApp<Tui>> for ArrangerAppCommand {
|
|||
key!(KeyCode::Char(' ')) => {
|
||||
Self::App(Transport(TransportViewCommand::Transport(TransportCommand::Play(None))))
|
||||
},
|
||||
_ => match view.focused() {
|
||||
_ => Self::App(match view.focused() {
|
||||
Content(ArrangerViewFocus::Transport) => Transport(
|
||||
TransportViewCommand::input_to_command(&view.sequencer.transport, input)?
|
||||
),
|
||||
|
|
@ -194,44 +194,17 @@ impl InputToCommand<Tui, ArrangerApp<Tui>> for ArrangerAppCommand {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command<ArrangerApp<Tui>> for ArrangerAppCommand {
|
||||
fn execute (self, state: &mut ArrangerApp<Tui>) -> Perhaps<Self> {
|
||||
use AppViewCommand::*;
|
||||
let undo = match self {
|
||||
Self::Focus(cmd) => {
|
||||
delegate(cmd, Self::Focus, state)
|
||||
},
|
||||
Self::App(cmd) => match cmd {
|
||||
ArrangerViewCommand::Phrases(cmd) => {
|
||||
delegate(cmd, |x|Self::App(ArrangerViewCommand::Phrases(x)), &mut state.app)
|
||||
},
|
||||
ArrangerViewCommand::Editor(cmd) => {
|
||||
delegate(cmd, |x|Self::App(ArrangerViewCommand::Editor(x)), &mut state.app)
|
||||
},
|
||||
ArrangerViewCommand::Transport(cmd) => {
|
||||
delegate(cmd, |x|Self::App(ArrangerViewCommand::Transport(x)), &mut state.app)
|
||||
},
|
||||
ArrangerViewCommand::Zoom(zoom) => {
|
||||
todo!();
|
||||
},
|
||||
ArrangerViewCommand::Select(selected) => {
|
||||
state.selected = selected;
|
||||
Ok(None)
|
||||
},
|
||||
ArrangerViewCommand::Edit(command) => {
|
||||
return Ok(command.execute(&mut state.model)?.map(ArrangerViewCommand::Edit))
|
||||
},
|
||||
ArrangerViewCommand::EditPhrase(phrase) => {
|
||||
app.sequencer.editor.phrase = phrase.clone();
|
||||
state.focus(ArrangerViewFocus::PhraseEditor);
|
||||
state.focus_enter();
|
||||
Ok(None)
|
||||
}
|
||||
},
|
||||
Focus(cmd) => { delegate(cmd, Focus, state) },
|
||||
App(cmd) => { delegate(cmd, App, state) }
|
||||
_ => {todo!()}
|
||||
}?;
|
||||
state.show_phrase();
|
||||
|
|
@ -240,6 +213,28 @@ impl Command<ArrangerApp<Tui>> for ArrangerAppCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl Command<ArrangerApp<Tui>> for ArrangerViewCommand {
|
||||
fn execute (self, state: &mut ArrangerApp<Tui>) -> Perhaps<Self> {
|
||||
use ArrangerViewCommand::*;
|
||||
match self {
|
||||
Phrases(cmd) => { delegate(cmd, Phrases, &mut state.app) },
|
||||
Editor(cmd) => { delegate(cmd, Editor, &mut state.app) },
|
||||
Transport(cmd) => { delegate(cmd, Transport, &mut state.app) },
|
||||
Zoom(zoom) => { todo!(); },
|
||||
Select(selected) => { state.selected = selected; Ok(None) },
|
||||
Edit(command) => {
|
||||
return Ok(command.execute(&mut state.model)?.map(ArrangerViewCommand::Edit))
|
||||
},
|
||||
EditPhrase(phrase) => {
|
||||
state.sequencer.editor.phrase = phrase.clone();
|
||||
state.focus(ArrangerViewFocus::PhraseEditor);
|
||||
state.focus_enter();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Root view for standalone `tek_arranger`
|
||||
pub struct ArrangerView<E: Engine> {
|
||||
pub model: ArrangerModel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue