mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
tab toggles pool visibility in sequencer
This commit is contained in:
parent
33259d1526
commit
f71ee5c521
2 changed files with 34 additions and 26 deletions
|
|
@ -20,12 +20,12 @@ pub struct SequencerCli {
|
||||||
impl SequencerCli {
|
impl SequencerCli {
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
Tui::run(JackClient::new("tek_sequencer")?.activate_with(|jack|{
|
Tui::run(JackClient::new("tek_sequencer")?.activate_with(|jack|{
|
||||||
let mut app = SequencerTui::try_from(jack)?;
|
let midi_in = jack.read().unwrap().register_port("in", MidiIn::default())?;
|
||||||
|
let midi_out = jack.read().unwrap().register_port("out", MidiOut::default())?;
|
||||||
|
let mut app = SequencerTui::try_from(jack)?;
|
||||||
//app.editor.view_mode.set_time_zoom(1);
|
//app.editor.view_mode.set_time_zoom(1);
|
||||||
// TODO: create from arguments
|
// TODO: create from arguments
|
||||||
let midi_in = app.jack.read().unwrap().register_port("in", MidiIn::default())?;
|
|
||||||
app.player.midi_ins.push(midi_in);
|
app.player.midi_ins.push(midi_in);
|
||||||
let midi_out = app.jack.read().unwrap().register_port("out", MidiOut::default())?;
|
|
||||||
app.player.midi_outs.push(midi_out);
|
app.player.midi_outs.push(midi_out);
|
||||||
if let Some(_) = self.name.as_ref() {
|
if let Some(_) = self.name.as_ref() {
|
||||||
// TODO: sequencer.name = Arc::new(RwLock::new(name.clone()));
|
// TODO: sequencer.name = Arc::new(RwLock::new(name.clone()));
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,16 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
|
||||||
Some(ItemColor::random().into())
|
Some(ItemColor::random().into())
|
||||||
)));
|
)));
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
jack: jack.clone(),
|
_jack: jack.clone(),
|
||||||
phrases: PhraseListModel::from(&phrase),
|
phrases: PhraseListModel::from(&phrase),
|
||||||
editor: PhraseEditorModel::from(&phrase),
|
editor: PhraseEditorModel::from(&phrase),
|
||||||
player: PhrasePlayerModel::from((&clock, &phrase)),
|
player: PhrasePlayerModel::from((&clock, &phrase)),
|
||||||
clock,
|
clock,
|
||||||
size: Measure::new(),
|
size: Measure::new(),
|
||||||
cursor: (0, 0),
|
midi_buf: vec![vec![];65536],
|
||||||
split: 20,
|
note_buf: vec![],
|
||||||
midi_buf: vec![vec![];65536],
|
perf: PerfModel::default(),
|
||||||
note_buf: vec![],
|
show_pool: true,
|
||||||
perf: PerfModel::default(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -34,17 +33,16 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
|
||||||
|
|
||||||
/// Root view for standalone `tek_sequencer`.
|
/// Root view for standalone `tek_sequencer`.
|
||||||
pub struct SequencerTui {
|
pub struct SequencerTui {
|
||||||
pub jack: Arc<RwLock<JackClient>>,
|
_jack: Arc<RwLock<JackClient>>,
|
||||||
pub clock: ClockModel,
|
pub(crate) clock: ClockModel,
|
||||||
pub phrases: PhraseListModel,
|
pub(crate) phrases: PhraseListModel,
|
||||||
pub player: PhrasePlayerModel,
|
pub(crate) player: PhrasePlayerModel,
|
||||||
pub editor: PhraseEditorModel,
|
pub(crate) editor: PhraseEditorModel,
|
||||||
pub size: Measure<Tui>,
|
pub(crate) size: Measure<Tui>,
|
||||||
pub cursor: (usize, usize),
|
pub(crate) show_pool: bool,
|
||||||
pub split: u16,
|
pub(crate) note_buf: Vec<u8>,
|
||||||
pub note_buf: Vec<u8>,
|
pub(crate) midi_buf: Vec<Vec<Vec<u8>>>,
|
||||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
pub(crate) perf: PerfModel,
|
||||||
pub perf: PerfModel,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -53,6 +51,7 @@ pub enum SequencerCommand {
|
||||||
Phrases(PhrasesCommand),
|
Phrases(PhrasesCommand),
|
||||||
Editor(PhraseCommand),
|
Editor(PhraseCommand),
|
||||||
Enqueue(Option<Arc<RwLock<Phrase>>>),
|
Enqueue(Option<Arc<RwLock<Phrase>>>),
|
||||||
|
ShowPool(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command<SequencerTui> for SequencerCommand {
|
impl Command<SequencerTui> for SequencerCommand {
|
||||||
|
|
@ -75,6 +74,10 @@ impl Command<SequencerTui> for SequencerCommand {
|
||||||
state.player.enqueue_next(phrase.as_ref());
|
state.player.enqueue_next(phrase.as_ref());
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
Self::ShowPool(value) => {
|
||||||
|
state.show_pool = value;
|
||||||
|
None
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +91,9 @@ impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
|
||||||
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
|
|
||||||
|
// Toggle visibility of phrase pool column
|
||||||
|
key_pat!(Tab) => ShowPool(!state.show_pool),
|
||||||
|
|
||||||
// Enqueue currently edited phrase
|
// Enqueue currently edited phrase
|
||||||
key_pat!(Char('q')) => Enqueue(Some(
|
key_pat!(Char('q')) => Enqueue(Some(
|
||||||
state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()
|
state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()
|
||||||
|
|
@ -137,7 +143,7 @@ pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<S
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
audio!(|self:SequencerTui,client,scope|{
|
audio!(|self:SequencerTui, client, scope|{
|
||||||
// Start profiling cycle
|
// Start profiling cycle
|
||||||
let t0 = self.perf.get_t0();
|
let t0 = self.perf.get_t0();
|
||||||
// Update transport clock
|
// Update transport clock
|
||||||
|
|
@ -160,7 +166,9 @@ render!(|self: SequencerTui|lay!([self.size, Tui::split_n(false, 5,
|
||||||
PhraseEditStatus(&self.editor),
|
PhraseEditStatus(&self.editor),
|
||||||
SequencerStatusBar::from(self),
|
SequencerStatusBar::from(self),
|
||||||
])),
|
])),
|
||||||
Tui::split_w(false, if self.size.w() > 60 {
|
Tui::split_w(false, if !self.show_pool{
|
||||||
|
0
|
||||||
|
} else if self.size.w() > 60 {
|
||||||
20
|
20
|
||||||
} else if self.size.w() > 40 {
|
} else if self.size.w() > 40 {
|
||||||
15
|
15
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue