mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
remove to_sequencer_command
This commit is contained in:
parent
f71ee5c521
commit
f5dcd3cba1
1 changed files with 48 additions and 67 deletions
|
|
@ -84,63 +84,51 @@ impl Command<SequencerTui> for SequencerCommand {
|
||||||
|
|
||||||
impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
|
impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
|
||||||
fn input_to_command (state: &SequencerTui, input: &TuiInput) -> Option<Self> {
|
fn input_to_command (state: &SequencerTui, input: &TuiInput) -> Option<Self> {
|
||||||
to_sequencer_command(state, input)
|
Some(match input.event() {
|
||||||
}
|
// Toggle visibility of phrase pool column
|
||||||
}
|
key_pat!(Tab) => ShowPool(!state.show_pool),
|
||||||
|
// Enqueue currently edited phrase
|
||||||
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
key_pat!(Char('q')) => Enqueue(Some(
|
||||||
Some(match input.event() {
|
state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()
|
||||||
|
)),
|
||||||
// Toggle visibility of phrase pool column
|
// 0: Enqueue phrase 0 (stop all)
|
||||||
key_pat!(Tab) => ShowPool(!state.show_pool),
|
key_pat!(Char('0')) => Enqueue(Some(
|
||||||
|
state.phrases.phrases[0].clone()
|
||||||
// Enqueue currently edited phrase
|
)),
|
||||||
key_pat!(Char('q')) => Enqueue(Some(
|
// E: Toggle between editing currently playing or other phrase
|
||||||
state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()
|
key_pat!(Char('e')) => if let Some((_, Some(playing_phrase))) = state.player.play_phrase() {
|
||||||
)),
|
let editing_phrase = state.editor.phrase().as_ref().map(|p|p.read().unwrap().clone());
|
||||||
|
let selected_phrase = state.phrases.phrase().clone();
|
||||||
// 0: Enqueue phrase 0 (stop all)
|
if Some(selected_phrase.read().unwrap().clone()) != editing_phrase {
|
||||||
key_pat!(Char('0')) => Enqueue(Some(
|
Editor(Show(Some(selected_phrase)))
|
||||||
state.phrases.phrases[0].clone()
|
} else {
|
||||||
)),
|
Editor(Show(Some(playing_phrase.clone())))
|
||||||
|
}
|
||||||
// E: Toggle between editing currently playing or other phrase
|
|
||||||
key_pat!(Char('e')) => if let Some((_, Some(playing_phrase))) = state.player.play_phrase() {
|
|
||||||
let editing_phrase = state.editor.phrase().as_ref().map(|p|p.read().unwrap().clone());
|
|
||||||
let selected_phrase = state.phrases.phrase().clone();
|
|
||||||
if Some(selected_phrase.read().unwrap().clone()) != editing_phrase {
|
|
||||||
Editor(Show(Some(selected_phrase)))
|
|
||||||
} else {
|
} else {
|
||||||
Editor(Show(Some(playing_phrase.clone())))
|
return None
|
||||||
|
},
|
||||||
|
// Transport: Play/pause
|
||||||
|
key_pat!(Char(' ')) => Clock(if state.clock().is_stopped() {
|
||||||
|
Play(None)
|
||||||
|
} else {
|
||||||
|
Pause(None)
|
||||||
|
}),
|
||||||
|
// Transport: Play from start or rewind to start
|
||||||
|
key_pat!(Shift-Char(' ')) => Clock(if state.clock().is_stopped() {
|
||||||
|
Play(Some(0))
|
||||||
|
} else {
|
||||||
|
Pause(Some(0))
|
||||||
|
}),
|
||||||
|
// Delegate to components:
|
||||||
|
_ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
||||||
|
Editor(command)
|
||||||
|
} else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) {
|
||||||
|
Phrases(command)
|
||||||
|
} else {
|
||||||
|
return None
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
return None
|
}
|
||||||
},
|
|
||||||
|
|
||||||
// Transport: Play/pause
|
|
||||||
key_pat!(Char(' ')) => Clock(if state.clock().is_stopped() {
|
|
||||||
Play(None)
|
|
||||||
} else {
|
|
||||||
Pause(None)
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Transport: Play from start or rewind to start
|
|
||||||
key_pat!(Shift-Char(' ')) => Clock(if state.clock().is_stopped() {
|
|
||||||
Play(Some(0))
|
|
||||||
} else {
|
|
||||||
Pause(Some(0))
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Delegate to components:
|
|
||||||
_ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
|
||||||
Editor(command)
|
|
||||||
} else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) {
|
|
||||||
Phrases(command)
|
|
||||||
} else {
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio!(|self:SequencerTui, client, scope|{
|
audio!(|self:SequencerTui, client, scope|{
|
||||||
|
|
@ -321,8 +309,6 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([
|
||||||
Tui::fixed_xy(11, 2, PlayPause(self.playing)),
|
Tui::fixed_xy(11, 2, PlayPause(self.playing)),
|
||||||
lay!([
|
lay!([
|
||||||
{
|
{
|
||||||
let bg = TuiTheme::g(50);
|
|
||||||
let fg = TuiTheme::g(255);
|
|
||||||
let single = |binding, command|row!([" ", col!([
|
let single = |binding, command|row!([" ", col!([
|
||||||
Tui::fg(TuiTheme::yellow(), binding),
|
Tui::fg(TuiTheme::yellow(), binding),
|
||||||
command
|
command
|
||||||
|
|
@ -331,7 +317,7 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([
|
||||||
row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1,]),
|
row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1,]),
|
||||||
row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2,]),
|
row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2,]),
|
||||||
]);
|
]);
|
||||||
Tui::bg(bg, Tui::fg(fg, row!([
|
Tui::bg(TuiTheme::g(50), Tui::fg(TuiTheme::g(255), row!([
|
||||||
single("SPACE", "play/pause"),
|
single("SPACE", "play/pause"),
|
||||||
double((" ✣", "cursor"), ("C-✣", "scroll"), ),
|
double((" ✣", "cursor"), ("C-✣", "scroll"), ),
|
||||||
double((",.", "note"), ("<>", "triplet"),),
|
double((",.", "note"), ("<>", "triplet"),),
|
||||||
|
|
@ -340,15 +326,10 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([
|
||||||
])))
|
])))
|
||||||
},
|
},
|
||||||
Tui::fill_xy(Tui::at_se({
|
Tui::fill_xy(Tui::at_se({
|
||||||
let orange = TuiTheme::orange();
|
Tui::bg(TuiTheme::g(25), row!([
|
||||||
let dark = TuiTheme::g(25);
|
Tui::fg(TuiTheme::orange(), &self.cpu),
|
||||||
//let cpu = &self.cpu;
|
Tui::fg(TuiTheme::orange(), &self.res),
|
||||||
//let res = &self.res;
|
Tui::fg(TuiTheme::orange(), &self.size),
|
||||||
let size = &self.size;
|
|
||||||
Tui::bg(dark, row!([
|
|
||||||
//Tui::fg(orange, cpu),
|
|
||||||
//Tui::fg(orange, res),
|
|
||||||
Tui::fg(orange, size),
|
|
||||||
]))
|
]))
|
||||||
})),
|
})),
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue