mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: refactor pt.10, 301 errors
This commit is contained in:
parent
8aa1ba8d0f
commit
1405b82341
10 changed files with 199 additions and 177 deletions
|
|
@ -10,41 +10,68 @@ impl Handle<Tui> for TransportView<Tui> {
|
|||
}
|
||||
}
|
||||
impl InputToCommand<Tui, TransportView<Tui>> for TransportViewCommand {
|
||||
fn input_to_command (_: &TransportView<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
match input.event() {
|
||||
key!(KeyCode::Char(' ')) => Some(Self::FocusPrev),
|
||||
key!(Shift-KeyCode::Char(' ')) => Some(Self::FocusPrev),
|
||||
key!(KeyCode::Left) => Some(Self::FocusPrev),
|
||||
key!(KeyCode::Right) => Some(Self::FocusNext),
|
||||
key!(KeyCode::Char('.')) => Some(match state.focus {
|
||||
Bpm => SetBpm(state.clock.timebase().bpm.get() + 1.0),
|
||||
Quant => SetQuant(next_note_length(state.clock.quant.get()as usize)as f64),
|
||||
Sync => SetSync(next_note_length(state.clock.sync.get()as usize)as f64+1.),
|
||||
PlayPause => {todo!()},
|
||||
Clock => {todo!()}
|
||||
fn input_to_command (state: &TransportView<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
use TransportViewFocus as Focus;
|
||||
use FocusCommand as FocusCmd;
|
||||
use TransportCommand as Cmd;
|
||||
Some(match input.event() {
|
||||
|
||||
key!(KeyCode::Left) => Self::Focus(FocusCmd::Prev),
|
||||
key!(KeyCode::Right) => Self::Focus(FocusCmd::Next),
|
||||
|
||||
key!(KeyCode::Char('.')) => Self::Transport(match state.focus {
|
||||
Focus::Bpm => Cmd::SetBpm(state.state.clock.timebase().bpm.get() + 1.0),
|
||||
Focus::Quant => Cmd::SetQuant(next_note_length(state.state.clock.quant.get()as usize)as f64),
|
||||
Focus::Sync => Cmd::SetSync(next_note_length(state.state.clock.sync.get()as usize)as f64+1.),
|
||||
Focus::PlayPause => {todo!()},
|
||||
Focus::Clock => {todo!()}
|
||||
}),
|
||||
key!(KeyCode::Char(',')) => Some(match state.focus {
|
||||
Bpm => SetBpm(state.clock.timebase().bpm.get() - 1.0),
|
||||
Quant => SetQuant(prev_note_length(state.clock.quant.get()as usize)as f64),
|
||||
Sync => SetSync(prev_note_length(state.clock.sync.get()as usize)as f64+1.),
|
||||
PlayPause => {todo!()},
|
||||
Clock => {todo!()}
|
||||
key!(KeyCode::Char(',')) => Self::Transport(match state.focus {
|
||||
Focus::Bpm => Cmd::SetBpm(state.state.clock.timebase().bpm.get() - 1.0),
|
||||
Focus::Quant => Cmd::SetQuant(prev_note_length(state.state.clock.quant.get()as usize)as f64),
|
||||
Focus::Sync => Cmd::SetSync(prev_note_length(state.state.clock.sync.get()as usize)as f64+1.),
|
||||
Focus::PlayPause => {todo!()},
|
||||
Focus::Clock => {todo!()}
|
||||
}),
|
||||
key!(KeyCode::Char('>')) => Some(match state.focus {
|
||||
Bpm => SetBpm(state.clock.timebase().bpm.get() + 0.001),
|
||||
Quant => SetQuant(next_note_length(state.clock.quant.get()as usize)as f64),
|
||||
Sync => SetSync(next_note_length(state.clock.sync.get()as usize)as f64+1.),
|
||||
PlayPause => {todo!()},
|
||||
Clock => {todo!()}
|
||||
key!(KeyCode::Char('>')) => Self::Transport(match state.focus {
|
||||
Focus::Bpm => Cmd::SetBpm(state.state.clock.timebase().bpm.get() + 0.001),
|
||||
Focus::Quant => Cmd::SetQuant(next_note_length(state.state.clock.quant.get()as usize)as f64),
|
||||
Focus::Sync => Cmd::SetSync(next_note_length(state.state.clock.sync.get()as usize)as f64+1.),
|
||||
Focus::PlayPause => {todo!()},
|
||||
Focus::Clock => {todo!()}
|
||||
}),
|
||||
key!(KeyCode::Char('<')) => Some(match state.focus {
|
||||
Bpm => SetBpm(state.clock.timebase().bpm.get() - 0.001),
|
||||
Quant => SetQuant(prev_note_length(state.clock.quant.get()as usize)as f64),
|
||||
Sync => SetSync(prev_note_length(state.clock.sync.get()as usize)as f64+1.),
|
||||
PlayPause => {todo!()},
|
||||
Clock => {todo!()}
|
||||
key!(KeyCode::Char('<')) => Self::Transport(match state.focus {
|
||||
Focus::Bpm => Cmd::SetBpm(state.state.clock.timebase().bpm.get() - 0.001),
|
||||
Focus::Quant => Cmd::SetQuant(prev_note_length(state.state.clock.quant.get()as usize)as f64),
|
||||
Focus::Sync => Cmd::SetSync(prev_note_length(state.state.clock.sync.get()as usize)as f64+1.),
|
||||
Focus::PlayPause => {todo!()},
|
||||
Focus::Clock => {todo!()}
|
||||
}),
|
||||
_ => None
|
||||
}
|
||||
|
||||
_ => return None
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine> Command<TransportView<E>> for TransportViewCommand {
|
||||
fn execute (self, state: &mut TransportView<E>) -> Perhaps<Self> {
|
||||
Ok(match self {
|
||||
Self::Focus(command) => {
|
||||
use FocusCommand::*;
|
||||
match command {
|
||||
Next => { todo!() },
|
||||
Prev => { todo!() },
|
||||
}
|
||||
},
|
||||
Self::Transport(command) => {
|
||||
use TransportCommand::*;
|
||||
match command {
|
||||
SetBpm(bpm) => SetBpm(state.state.clock.timebase().bpm.set(bpm)),
|
||||
SetQuant(quant) => SetQuant(state.state.clock.quant.set(quant)),
|
||||
SetSync(sync) => SetSync(state.state.clock.sync.set(sync)),
|
||||
_ => { todo!() }
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue