show hotkeys in status bar

This commit is contained in:
🪞👃🪞 2024-11-28 13:14:47 +01:00
parent 51889d4b43
commit 86649ef994
3 changed files with 53 additions and 15 deletions

View file

@ -133,24 +133,55 @@ impl From<&SequencerTui> for SequencerStatusBar {
let samples = state.clock.chunk.load(Ordering::Relaxed); let samples = state.clock.chunk.load(Ordering::Relaxed);
let rate = state.clock.current.timebase.sr.get() as f64; let rate = state.clock.current.timebase.sr.get() as f64;
let buffer = samples as f64 / rate; let buffer = samples as f64 / rate;
let default_help = &[("", "", " enter"), ("", "", " navigate")];
Self { Self {
cpu: state.perf.percentage().map(|cpu|format!("{cpu:.01}%")), cpu: state.perf.percentage().map(|cpu|format!("{cpu:.01}%")),
size: format!("{}x{}│", state.size.w(), state.size.h()), size: format!("{}x{}│", state.size.w(), state.size.h()),
res: format!("│{}s│{:.1}kHz│{:.1}ms│", samples, rate / 1000., buffer * 1000.), res: format!("│{}s│{:.1}kHz│{:.1}ms│", samples, rate / 1000., buffer * 1000.),
mode: match state.focused() { mode: match state.focused() {
Transport(focus) => match focus { Transport(PlayPause) => " PLAY/PAUSE ",
PlayPause => " PLAY/PAUSE ", Transport(Bpm) => " TEMPO ",
Bpm => " TEMPO ", Transport(Sync) => " LAUNCH SYNC ",
Sync => " LAUNCH SYNC ", Transport(Quant) => " REC QUANT ",
Quant => " REC QUANT ", Transport(Clock) => " SEEK ",
Clock => " SEEK ", PhraseList => " PHRASES ",
}, PhraseEditor => " EDIT MIDI ",
PhraseList => " PHRASES ", PhrasePlay => " TO PLAY ",
PhraseEditor => " EDIT MIDI ", PhraseNext => " UP NEXT ",
PhrasePlay => " TO PLAY ",
PhraseNext => " UP NEXT ",
}, },
help: &[] help: match state.focused() {
Transport(PlayPause) => &[
("", "", " play/pause"),
("", "", " navigate"),
],
Transport(Bpm) => &[
("", ".,", " inc/dec"),
("", "><", " fine"),
],
Transport(Sync) => &[
("", ".,", " inc/dec"),
],
Transport(Quant) => &[
("", ".,", " inc/dec"),
],
PhraseList => if state.entered() {
&[
("", "", " pick"),
("", ".,", " move"),
("", "", " play"),
("", "e", " edit"),
]
} else {
default_help
}
_ => if state.entered() {
&[
("", "Esc", " exit")
]
} else {
default_help
}
}
} }
} }
} }

View file

@ -122,10 +122,11 @@ impl<'a> Content for PhraseView<'a> {
let piano_roll = row!(keys, note_area).fill_x(); let piano_roll = row!(keys, note_area).fill_x();
let content = piano_roll.bg(Color::Rgb(40, 50, 30)).border(border); let content = piano_roll.bg(Color::Rgb(40, 50, 30)).border(border);
let content = lay!(content, playhead); let content = lay!(content, playhead);
let mut upper_left = format!("[{}] Sequencer", if *entered {""} else {" "}); let mut name = "".to_string();
if let Some(phrase) = phrase { if let Some(phrase) = phrase {
upper_left = format!("{upper_left}: {}", phrase.read().unwrap().name); name = phrase.read().unwrap().name.clone();
} }
let mut upper_left = format!("[{}] {name}", if *entered {""} else {" "},);
let mut lower_right = format!("{}", size.format()); let mut lower_right = format!("{}", size.format());
lower_right = format!("┤Zoom: {}├─{lower_right}", pulses_to_name(time_scale)); lower_right = format!("┤Zoom: {}├─{lower_right}", pulses_to_name(time_scale));
//lower_right = format!("Zoom: {} (+{}:{}*{}|{})", //lower_right = format!("Zoom: {} (+{}:{}*{}|{})",

View file

@ -29,9 +29,15 @@ impl Content for SequencerStatusBar {
type Engine = Tui; type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> { fn content (&self) -> impl Widget<Engine = Tui> {
let orange = Color::Rgb(255,128,0); let orange = Color::Rgb(255,128,0);
let yellow = Color::Rgb(255,255,0);
let black = Color::Rgb(0,0,0); let black = Color::Rgb(0,0,0);
lay!( lay!(
widget(&self.mode).bg(orange).fg(black).bold(true), row!(
widget(&self.mode).bg(orange).fg(black).bold(true),
row!((prefix, hotkey, suffix) in self.help => {
row!(" ", *prefix, TuiStyle::fg(*hotkey, yellow), *suffix)
})
),
row!( row!(
widget(&self.cpu).fg(orange), widget(&self.cpu).fg(orange),
widget(&self.res).fg(orange), widget(&self.res).fg(orange),