remove HasFocus from SequencerTui; update status bar

This commit is contained in:
🪞👃🪞 2024-12-14 23:20:57 +01:00
parent a5bcf3798e
commit f783984a74
3 changed files with 20 additions and 61 deletions

View file

@ -107,9 +107,10 @@ impl Command<SequencerTui> for SequencerCommand {
impl Command<SequencerTui> for FocusCommand<SequencerFocus> {
fn execute (self, state: &mut SequencerTui) -> Perhaps<FocusCommand<SequencerFocus>> {
if let FocusCommand::Set(to) = self {
state.set_focused(to);
}
// Focus commands can be received but are ignored.
//if let FocusCommand::Set(to) = self {
//state.set_focused(to);
//}
Ok(None)
}
}
@ -300,18 +301,6 @@ impl HasPhraseList for SequencerTui {
}
}
impl HasFocus for SequencerTui {
type Item = SequencerFocus;
/// Get the currently focused item.
fn focused (&self) -> Self::Item {
self.focus
}
/// Get the currently focused item.
fn set_focused (&mut self, to: Self::Item) {
self.focus = to
}
}
impl Into<Option<TransportFocus>> for SequencerFocus {
fn into (self) -> Option<TransportFocus> {
if let Self::Transport(transport) = self {

View file

@ -214,7 +214,7 @@ impl Handle<Tui> for TransportTui {
}
}
pub trait TransportControl<T>: HasClock + HasFocus<Item = T> {
pub trait TransportControl<T>: HasClock + {
fn transport_focused (&self) -> Option<TransportFocus>;
}

View file

@ -50,60 +50,30 @@ impl StatusBar for SequencerStatusBar {
impl From<&SequencerTui> for SequencerStatusBar {
fn from (state: &SequencerTui) -> Self {
use super::app_transport::TransportFocus::*;
use super::app_sequencer::SequencerFocus::*;
let samples = state.clock.chunk.load(Ordering::Relaxed);
let rate = state.clock.timebase.sr.get() as f64;
let buffer = samples as f64 / rate;
let width = state.size.w();
let default_help = &[("", "", " enter"), ("", "", " navigate")];
Self {
width,
cpu: state.perf.percentage().map(|cpu|format!("{cpu:.01}%")),
size: format!("{}x{}│", width, state.size.h()),
res: format!("│{}s│{:.1}kHz│{:.1}ms│", samples, rate / 1000., buffer * 1000.),
mode: match state.focused() {
Transport(PlayPause) => " PLAY/PAUSE ",
Transport(Bpm) => " TEMPO ",
Transport(Sync) => " LAUNCH SYNC ",
Transport(Quant) => " REC QUANT ",
Transport(Clock) => " SEEK ",
//PhrasePlay => " TO PLAY ",
//PhraseNext => " UP NEXT ",
PhraseList => " PHRASES ",
PhraseEditor => " EDIT MIDI ",
},
help: match state.focused() {
Transport(PlayPause) => &[
("", "", " play/pause"),
("", "", " navigate"),
],
Transport(Bpm) => &[
("", ".,", " inc/dec"),
("", "><", " fine"),
],
Transport(Sync) => &[
("", ".,", " inc/dec"),
],
Transport(Quant) => &[
("", ".,", " inc/dec"),
],
Transport(Clock) => &[
("", ".,", " by beat"),
("", "<>", " by time"),
],
PhraseList => &[
("", "", " pick"),
("", ".,", " move"),
("", "", " play"),
("", "e", " edit"),
],
PhraseEditor => &[
mode: " SEQUENCER ",
help: &[
("", "SPACE", " play/pause"),
("", "", " cursor"),
("", "Ctrl-✣", " scroll"),
],
_ => default_help,
}
("", ".,", " length"),
("", "><", " triplet"),
("", "[]", " phrase"),
("", "{}", " order"),
("en", "q", "ueue"),
("", "e", "dit"),
("", "a", "dd note"),
("", "A", "dd phrase"),
("", "D", "uplicate phrase"),
]
}
}
}