mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: refactor pt.25: 15 errors
This commit is contained in:
parent
76644e32ba
commit
7384950302
2 changed files with 21 additions and 32 deletions
|
|
@ -188,6 +188,7 @@ impl<E: Engine> Command<ArrangerView<E>> for ArrangerViewCommand {
|
||||||
},
|
},
|
||||||
Self::Select(selected) => {
|
Self::Select(selected) => {
|
||||||
view.selected = selected;
|
view.selected = selected;
|
||||||
|
Ok(None)
|
||||||
},
|
},
|
||||||
Self::Edit(command) => {
|
Self::Edit(command) => {
|
||||||
return Ok(command.execute(&mut view.model)?.map(Self::Edit))
|
return Ok(command.execute(&mut view.model)?.map(Self::Edit))
|
||||||
|
|
|
||||||
|
|
@ -17,37 +17,37 @@ impl InputToCommand<Tui, TransportView<Tui>> for TransportViewCommand {
|
||||||
use TransportViewFocus as Focus;
|
use TransportViewFocus as Focus;
|
||||||
use FocusCommand as FocusCmd;
|
use FocusCommand as FocusCmd;
|
||||||
use TransportCommand as Cmd;
|
use TransportCommand as Cmd;
|
||||||
let model = view.model.read().unwrap();
|
let clock = view.model.clock();
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
|
|
||||||
key!(KeyCode::Left) => Self::Focus(FocusCmd::Prev),
|
key!(KeyCode::Left) => Self::Focus(FocusCmd::Prev),
|
||||||
key!(KeyCode::Right) => Self::Focus(FocusCmd::Next),
|
key!(KeyCode::Right) => Self::Focus(FocusCmd::Next),
|
||||||
|
|
||||||
key!(KeyCode::Char('.')) => Self::Transport(match view.focus {
|
key!(KeyCode::Char('.')) => Self::Transport(match view.focus {
|
||||||
Focus::Bpm => Cmd::SetBpm(model.clock.timebase().bpm.get() + 1.0),
|
Focus::Bpm => Cmd::SetBpm(clock.timebase().bpm.get() + 1.0),
|
||||||
Focus::Quant => Cmd::SetQuant(next_note_length(model.clock.quant.get()as usize)as f64),
|
Focus::Quant => Cmd::SetQuant(next_note_length(clock.quant.get()as usize)as f64),
|
||||||
Focus::Sync => Cmd::SetSync(next_note_length(model.clock.sync.get()as usize)as f64+1.),
|
Focus::Sync => Cmd::SetSync(next_note_length(clock.sync.get()as usize)as f64+1.),
|
||||||
Focus::PlayPause => {todo!()},
|
Focus::PlayPause => {todo!()},
|
||||||
Focus::Clock => {todo!()}
|
Focus::Clock => {todo!()}
|
||||||
}),
|
}),
|
||||||
key!(KeyCode::Char(',')) => Self::Transport(match view.focus {
|
key!(KeyCode::Char(',')) => Self::Transport(match view.focus {
|
||||||
Focus::Bpm => Cmd::SetBpm(model.clock.timebase().bpm.get() - 1.0),
|
Focus::Bpm => Cmd::SetBpm(clock.timebase().bpm.get() - 1.0),
|
||||||
Focus::Quant => Cmd::SetQuant(prev_note_length(model.clock.quant.get()as usize)as f64),
|
Focus::Quant => Cmd::SetQuant(prev_note_length(clock.quant.get()as usize)as f64),
|
||||||
Focus::Sync => Cmd::SetSync(prev_note_length(model.clock.sync.get()as usize)as f64+1.),
|
Focus::Sync => Cmd::SetSync(prev_note_length(clock.sync.get()as usize)as f64+1.),
|
||||||
Focus::PlayPause => {todo!()},
|
Focus::PlayPause => {todo!()},
|
||||||
Focus::Clock => {todo!()}
|
Focus::Clock => {todo!()}
|
||||||
}),
|
}),
|
||||||
key!(KeyCode::Char('>')) => Self::Transport(match view.focus {
|
key!(KeyCode::Char('>')) => Self::Transport(match view.focus {
|
||||||
Focus::Bpm => Cmd::SetBpm(model.clock.timebase().bpm.get() + 0.001),
|
Focus::Bpm => Cmd::SetBpm(clock.timebase().bpm.get() + 0.001),
|
||||||
Focus::Quant => Cmd::SetQuant(next_note_length(model.clock.quant.get()as usize)as f64),
|
Focus::Quant => Cmd::SetQuant(next_note_length(clock.quant.get()as usize)as f64),
|
||||||
Focus::Sync => Cmd::SetSync(next_note_length(model.clock.sync.get()as usize)as f64+1.),
|
Focus::Sync => Cmd::SetSync(next_note_length(clock.sync.get()as usize)as f64+1.),
|
||||||
Focus::PlayPause => {todo!()},
|
Focus::PlayPause => {todo!()},
|
||||||
Focus::Clock => {todo!()}
|
Focus::Clock => {todo!()}
|
||||||
}),
|
}),
|
||||||
key!(KeyCode::Char('<')) => Self::Transport(match view.focus {
|
key!(KeyCode::Char('<')) => Self::Transport(match view.focus {
|
||||||
Focus::Bpm => Cmd::SetBpm(model.clock.timebase().bpm.get() - 0.001),
|
Focus::Bpm => Cmd::SetBpm(clock.timebase().bpm.get() - 0.001),
|
||||||
Focus::Quant => Cmd::SetQuant(prev_note_length(model.clock.quant.get()as usize)as f64),
|
Focus::Quant => Cmd::SetQuant(prev_note_length(clock.quant.get()as usize)as f64),
|
||||||
Focus::Sync => Cmd::SetSync(prev_note_length(model.clock.sync.get()as usize)as f64+1.),
|
Focus::Sync => Cmd::SetSync(prev_note_length(clock.sync.get()as usize)as f64+1.),
|
||||||
Focus::PlayPause => {todo!()},
|
Focus::PlayPause => {todo!()},
|
||||||
Focus::Clock => {todo!()}
|
Focus::Clock => {todo!()}
|
||||||
}),
|
}),
|
||||||
|
|
@ -59,34 +59,22 @@ impl InputToCommand<Tui, TransportView<Tui>> for TransportViewCommand {
|
||||||
|
|
||||||
impl<E: Engine> Command<TransportView<E>> for TransportViewCommand {
|
impl<E: Engine> Command<TransportView<E>> for TransportViewCommand {
|
||||||
fn execute (self, view: &mut TransportView<E>) -> Perhaps<Self> {
|
fn execute (self, view: &mut TransportView<E>) -> Perhaps<Self> {
|
||||||
let model = view.model.read().unwrap();
|
let clock = view.model.clock();
|
||||||
Ok(Some(match self {
|
Ok(Some(match self {
|
||||||
Self::Focus(command) => Self::Focus({
|
Self::Focus(command) => Self::Focus({
|
||||||
use FocusCommand::*;
|
use FocusCommand::*;
|
||||||
match command {
|
match command {
|
||||||
Next => {
|
Next => { todo!() },
|
||||||
todo!()
|
Prev => { todo!() },
|
||||||
},
|
_ => { todo!() }
|
||||||
Prev => {
|
|
||||||
todo!()
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Self::Transport(command) => Self::Transport({
|
Self::Transport(command) => Self::Transport({
|
||||||
use TransportCommand::*;
|
use TransportCommand::*;
|
||||||
match command {
|
match command {
|
||||||
SetBpm(bpm) => SetBpm(
|
SetBpm(bpm) => SetBpm(clock.timebase().bpm.set(bpm)),
|
||||||
model.clock.timebase().bpm.set(bpm)
|
SetQuant(quant) => SetQuant(clock.quant.set(quant)),
|
||||||
),
|
SetSync(sync) => SetSync(clock.sync.set(sync)),
|
||||||
SetQuant(quant) => SetQuant(
|
|
||||||
model.clock.quant.set(quant)
|
|
||||||
),
|
|
||||||
SetSync(sync) => SetSync(
|
|
||||||
model.clock.sync.set(sync)
|
|
||||||
),
|
|
||||||
_ => {
|
_ => {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue