mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
enable transport commands in all contexts
This commit is contained in:
parent
571d475657
commit
8f10117a9c
3 changed files with 43 additions and 27 deletions
|
|
@ -145,10 +145,9 @@ fn to_arranger_command (state: &ArrangerTui, input: &TuiInput) -> Option<Arrange
|
||||||
AppFocus::Menu => { todo!() },
|
AppFocus::Menu => { todo!() },
|
||||||
AppFocus::Content(focused) => match focused {
|
AppFocus::Content(focused) => match focused {
|
||||||
ArrangerFocus::Transport(_) => {
|
ArrangerFocus::Transport(_) => {
|
||||||
use TransportCommand::{Clock, Focus};
|
|
||||||
match TransportCommand::input_to_command(state, input)? {
|
match TransportCommand::input_to_command(state, input)? {
|
||||||
Clock(_) => { todo!() },
|
TransportCommand::Clock(command) => Cmd::Clock(command),
|
||||||
Focus(command) => Cmd::Focus(command)
|
_ => return None,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ArrangerFocus::PhraseEditor => {
|
ArrangerFocus::PhraseEditor => {
|
||||||
|
|
|
||||||
|
|
@ -53,27 +53,23 @@ pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<S
|
||||||
key!(Char('e')) => Editor(
|
key!(Char('e')) => Editor(
|
||||||
PhraseCommand::Show(state.phrase_to_edit().clone())
|
PhraseCommand::Show(state.phrase_to_edit().clone())
|
||||||
),
|
),
|
||||||
key!(Char(' ')) => Clock(
|
key!(Char(' ')) => Clock(if state.is_stopped() {
|
||||||
if let Some(TransportState::Stopped) = *state.clock.playing.read().unwrap() {
|
|
||||||
ClockCommand::Play(None)
|
ClockCommand::Play(None)
|
||||||
} else {
|
} else {
|
||||||
ClockCommand::Pause(None)
|
ClockCommand::Pause(None)
|
||||||
}
|
}),
|
||||||
),
|
key!(Shift-Char(' ')) => Clock(if state.is_stopped() {
|
||||||
key!(Shift-Char(' ')) => Clock(
|
|
||||||
if let Some(TransportState::Stopped) = *state.clock.playing.read().unwrap() {
|
|
||||||
ClockCommand::Play(Some(0))
|
ClockCommand::Play(Some(0))
|
||||||
} else {
|
} else {
|
||||||
ClockCommand::Pause(Some(0))
|
ClockCommand::Pause(Some(0))
|
||||||
}
|
}),
|
||||||
),
|
|
||||||
_ => match state.focused() {
|
_ => match state.focused() {
|
||||||
AppFocus::Menu => { todo!() },
|
AppFocus::Menu => { todo!() },
|
||||||
AppFocus::Content(focused) => match focused {
|
AppFocus::Content(focused) => match focused {
|
||||||
SequencerFocus::Transport(_) => {
|
SequencerFocus::Transport(_) => {
|
||||||
match TransportCommand::input_to_command(state, input)? {
|
match TransportCommand::input_to_command(state, input)? {
|
||||||
TransportCommand::Clock(_) => { todo!() },
|
TransportCommand::Clock(command) => Clock(command),
|
||||||
TransportCommand::Focus(command) => Focus(command),
|
_ => return None,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SequencerFocus::Phrases => Phrases(
|
SequencerFocus::Phrases => Phrases(
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ impl<T: TransportControl> Command<T> for TransportCommand {
|
||||||
use ClockCommand::{SetBpm, SetQuant, SetSync};
|
use ClockCommand::{SetBpm, SetQuant, SetSync};
|
||||||
Ok(match self {
|
Ok(match self {
|
||||||
Focus(cmd) => cmd.execute(state)?.map(Focus),
|
Focus(cmd) => cmd.execute(state)?.map(Focus),
|
||||||
Clock(SetBpm(bpm)) => Some(Clock(SetBpm(state.bpm().set(bpm)))),
|
Clock(cmd) => cmd.execute(state)?.map(Clock),
|
||||||
Clock(SetQuant(quant)) => Some(Clock(SetQuant(state.quant().set(quant)))),
|
//Clock(SetBpm(bpm)) => Some(Clock(SetBpm(state.bpm().set(bpm)))),
|
||||||
Clock(SetSync(sync)) => Some(Clock(SetSync(state.sync().set(sync)))),
|
//Clock(SetQuant(quant)) => Some(Clock(SetQuant(state.quant().set(quant)))),
|
||||||
|
//Clock(SetSync(sync)) => Some(Clock(SetSync(state.sync().set(sync)))),
|
||||||
_ => return Ok(None)
|
_ => return Ok(None)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -78,8 +79,16 @@ where
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key!(Left) => Focus(FocusCommand::Prev),
|
key!(Left) => Focus(FocusCommand::Prev),
|
||||||
key!(Right) => Focus(FocusCommand::Next),
|
key!(Right) => Focus(FocusCommand::Next),
|
||||||
key!(Char(' ')) => todo!("toolbar space"),
|
key!(Char(' ')) => Clock(if state.is_stopped() {
|
||||||
key!(Shift-Char(' ')) => todo!("toolbar shift-space"),
|
ClockCommand::Play(None)
|
||||||
|
} else {
|
||||||
|
ClockCommand::Pause(None)
|
||||||
|
}),
|
||||||
|
key!(Shift-Char(' ')) => Clock(if state.is_stopped() {
|
||||||
|
ClockCommand::Play(Some(0))
|
||||||
|
} else {
|
||||||
|
ClockCommand::Pause(Some(0))
|
||||||
|
}),
|
||||||
_ => match state.transport_focused().unwrap() {
|
_ => match state.transport_focused().unwrap() {
|
||||||
TransportFocus::Bpm => match input.event() {
|
TransportFocus::Bpm => match input.event() {
|
||||||
key!(Char(',')) => Clock(SetBpm(state.bpm().get() - 1.0)),
|
key!(Char(',')) => Clock(SetBpm(state.bpm().get() - 1.0)),
|
||||||
|
|
@ -110,8 +119,20 @@ where
|
||||||
_ => return None,
|
_ => return None,
|
||||||
},
|
},
|
||||||
TransportFocus::PlayPause => match input.event() {
|
TransportFocus::PlayPause => match input.event() {
|
||||||
key!(Enter) => todo!("transport play toggle"),
|
key!(Enter) => Clock(
|
||||||
key!(Shift-Enter) => todo!("transport shift-play toggle"),
|
if state.is_stopped() {
|
||||||
|
ClockCommand::Play(None)
|
||||||
|
} else {
|
||||||
|
ClockCommand::Pause(None)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
key!(Shift-Enter) => Clock(
|
||||||
|
if state.is_stopped() {
|
||||||
|
ClockCommand::Play(Some(0))
|
||||||
|
} else {
|
||||||
|
ClockCommand::Pause(Some(0))
|
||||||
|
}
|
||||||
|
),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue