name focused section in sequencer status bar

This commit is contained in:
🪞👃🪞 2024-11-26 13:27:48 +01:00
parent e4027619e8
commit bbd784f58b
2 changed files with 27 additions and 6 deletions

View file

@ -97,6 +97,7 @@ pub struct SequencerStatusBar {
pub(crate) cpu: Option<String>,
pub(crate) size: String,
pub(crate) sr: String,
pub(crate) mode: &'static str,
}
impl StatusBar for SequencerStatusBar {
@ -111,10 +112,25 @@ impl StatusBar for SequencerStatusBar {
impl From<&SequencerTui> for SequencerStatusBar {
fn from (state: &SequencerTui) -> Self {
use SequencerFocus::*;
use TransportFocus::*;
Self {
cpu: state.perf.percentage().map(|cpu|format!(" {cpu:.01}% ")),
size: format!(" {}x{} ", state.size.w(), state.size.h()),
sr: format!(" {}Hz ", state.clock.current.timebase.sr.get())
sr: format!(" {}Hz ", state.clock.current.timebase.sr.get()),
mode: match state.focused() {
Transport(focus) => match focus {
PlayPause => " PLAY/PAUSE ",
Bpm => " TEMPO ",
Sync => " LAUNCH SYNC ",
Quant => " REC QUANT ",
Clock => " SEEK ",
},
PhraseList => " PHRASES ",
PhraseEditor => " EDIT MIDI ",
PhrasePlay => " TO PLAY ",
PhraseNext => " UP NEXT ",
}
}
}
}

View file

@ -20,10 +20,15 @@ impl Content for SequencerTui {
impl Content for SequencerStatusBar {
type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> {
let orange = Color::Rgb(255,128,0);
let black = Color::Rgb(0,0,0);
lay!(
widget(&self.mode).bg(orange).fg(black).bold(true),
row!(
widget(&self.cpu).fg(Color::Rgb(255,128,0)),
widget(&self.sr).fg(Color::Rgb(255,128,0)),
widget(&self.size).fg(Color::Rgb(255,128,0)),
widget(&self.cpu).fg(orange),
widget(&self.sr).fg(orange),
widget(&self.size).fg(orange),
).align_se().fill_x()
)
}
}