transport compact mode

This commit is contained in:
🪞👃🪞 2025-01-02 15:32:49 +01:00
parent 6776e2ec55
commit 92459b5f82
6 changed files with 134 additions and 83 deletions

View file

@ -10,7 +10,7 @@ pub struct SequencerTui {
pub transport: bool,
pub selectors: bool,
pub clock: Clock,
pub phrases: PoolModel,
pub pool: PoolModel,
pub player: MidiPlayer,
pub editor: MidiEditor,
pub size: Measure<Tui>,
@ -29,7 +29,7 @@ from_jack!(|jack|SequencerTui {
_jack: jack.clone(),
transport: true,
selectors: true,
phrases: PoolModel::from(&phrase),
pool: PoolModel::from(&phrase),
editor: MidiEditor::from(&phrase),
player: MidiPlayer::from((&clock, &phrase)),
size: Measure::new(),
@ -43,8 +43,8 @@ from_jack!(|jack|SequencerTui {
render!(Tui: (self: SequencerTui) => {
let w = self.size.w();
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
let pool_w = if self.phrases.visible { phrase_w } else { 0 };
let pool = Pull::y(1, Fill::y(Align::e(PoolView(&self.phrases))));
let pool_w = if self.pool.visible { phrase_w } else { 0 };
let pool = Pull::y(1, Fill::y(Align::e(PoolView(&self.pool))));
let with_pool = move|x|Bsp::w(Fixed::x(pool_w, pool), x);
let status = SequencerStatus::from(self);
let with_status = |x|Bsp::n(Fixed::x(if self.status { 2 } else { 0 }, status), x);
@ -56,7 +56,7 @@ render!(Tui: (self: SequencerTui) => {
p.as_ref().map(|p|p.read().unwrap().color)
).flatten().clone();
let toolbar = Tui::when(self.transport, TransportView(&self.clock));
let toolbar = Tui::when(self.transport, TransportView::new(true, &self.clock));
let play_queue = Tui::when(self.selectors, row!(
PhraseSelector::play_phrase(&self.player),
@ -88,7 +88,7 @@ audio!(|self:SequencerTui, client, scope|{
});
has_size!(<Tui>|self:SequencerTui|&self.size);
has_clock!(|self:SequencerTui|&self.clock);
has_phrases!(|self:SequencerTui|self.phrases.phrases);
has_phrases!(|self:SequencerTui|self.pool.phrases);
has_editor!(|self:SequencerTui|self.editor);
handle!(<Tui>|self:SequencerTui,input|SequencerCommand::execute_with_state(self, input));
#[derive(Clone, Debug)] pub enum SequencerCommand {
@ -114,15 +114,15 @@ input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input
// Shift-U: redo
key_pat!(Char('U')) => Cmd::History( 1),
// Tab: Toggle visibility of phrase pool column
key_pat!(Tab) => Cmd::Pool(PoolCommand::Show(!state.phrases.visible)),
key_pat!(Tab) => Cmd::Pool(PoolCommand::Show(!state.pool.visible)),
// q: Enqueue currently edited phrase
key_pat!(Char('q')) => Cmd::Enqueue(Some(state.phrases.phrase().clone())),
key_pat!(Char('q')) => Cmd::Enqueue(Some(state.pool.phrase().clone())),
// 0: Enqueue phrase 0 (stop all)
key_pat!(Char('0')) => Cmd::Enqueue(Some(state.phrases.phrases()[0].clone())),
key_pat!(Char('0')) => Cmd::Enqueue(Some(state.phrases()[0].clone())),
// e: Toggle between editing currently playing or other phrase
key_pat!(Char('e')) => if let Some((_, Some(playing))) = state.player.play_phrase() {
let editing = state.editor.phrase().as_ref().map(|p|p.read().unwrap().clone());
let selected = state.phrases.phrase().clone();
let selected = state.pool.phrase().clone();
Cmd::Editor(Show(Some(if Some(selected.read().unwrap().clone()) != editing {
selected
} else {
@ -135,7 +135,7 @@ input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input
// The ones defined above supersede them.
_ => if let Some(command) = MidiEditCommand::input_to_command(&state.editor, input) {
Cmd::Editor(command)
} else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) {
} else if let Some(command) = PoolCommand::input_to_command(&state.pool, input) {
Cmd::Pool(command)
} else {
return None
@ -144,19 +144,19 @@ input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input
command!(|self: SequencerCommand, state: SequencerTui|match self {
Self::Pool(cmd) => {
let mut default = |cmd: PoolCommand|cmd
.execute(&mut state.phrases)
.execute(&mut state.pool)
.map(|x|x.map(Cmd::Pool));
match cmd {
// autoselect: automatically load selected phrase in editor
PoolCommand::Select(_) => {
let undo = default(cmd)?;
state.editor.set_phrase(Some(state.phrases.phrase()));
state.editor.set_phrase(Some(state.pool.phrase()));
undo
},
// update color in all places simultaneously
PoolCommand::Phrase(SetColor(index, _)) => {
let undo = default(cmd)?;
state.editor.set_phrase(Some(state.phrases.phrase()));
state.editor.set_phrase(Some(state.pool.phrase()));
undo
},
_ => default(cmd)?