mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
50 lines
1.8 KiB
Rust
50 lines
1.8 KiB
Rust
use crate::*;
|
|
|
|
/// Status bar for sequencer app
|
|
#[derive(Clone)]
|
|
pub struct GrooveboxStatus {
|
|
pub(crate) width: usize,
|
|
pub(crate) cpu: Option<String>,
|
|
pub(crate) size: String,
|
|
pub(crate) playing: bool,
|
|
}
|
|
from!(|state: &Groovebox|GrooveboxStatus = {
|
|
let samples = state.clock().chunk.load(Relaxed);
|
|
let rate = state.clock().timebase.sr.get();
|
|
let buffer = samples as f64 / rate;
|
|
let width = state.size.w();
|
|
Self {
|
|
width,
|
|
playing: state.clock().is_rolling(),
|
|
cpu: state.perf.percentage().map(|cpu|format!("│{cpu:.01}%")),
|
|
size: format!("{}x{}│", width, state.size.h()),
|
|
}
|
|
});
|
|
render!(<Tui>|self: GrooveboxStatus|Fixed::y(2, lay!([
|
|
Self::help(),
|
|
Fill::xy(Align::se(Tui::fg_bg(TuiTheme::orange(), TuiTheme::g(25), self.stats()))),
|
|
])));
|
|
impl GrooveboxStatus {
|
|
fn help () -> impl Render<Tui> {
|
|
let single = |binding, command|row!([" ", col!([
|
|
Tui::fg(TuiTheme::yellow(), binding),
|
|
command
|
|
])]);
|
|
let double = |(b1, c1), (b2, c2)|col!([
|
|
row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1,]),
|
|
row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2,]),
|
|
]);
|
|
Tui::fg_bg(TuiTheme::g(255), TuiTheme::g(50), row!([
|
|
single("SPACE", "play/pause"),
|
|
double(("▲▼▶◀", "cursor"), ("Ctrl", "scroll"), ),
|
|
double(("a", "append"), ("s", "set note"),),
|
|
double((",.", "length"), ("<>", "triplet"), ),
|
|
double(("[]", "phrase"), ("{}", "order"), ),
|
|
double(("q", "enqueue"), ("e", "edit"), ),
|
|
double(("c", "color"), ("", ""),),
|
|
]))
|
|
}
|
|
fn stats (&self) -> impl Render<Tui> + use<'_> {
|
|
row!([&self.cpu, &self.size])
|
|
}
|
|
}
|