add status bar to arranger view

This commit is contained in:
🪞👃🪞 2024-12-21 03:51:22 +01:00
parent b671d8e028
commit 685d49fd98
3 changed files with 42 additions and 28 deletions

View file

@ -18,7 +18,7 @@ pub struct ArrangerCli {
/// Number of tracks
#[arg(short = 'x', long, default_value_t = 4)]
tracks: usize,
tracks: usize,
/// Number of scenes
#[arg(short, long, default_value_t = 8)]
@ -38,9 +38,10 @@ impl ArrangerCli {
let track_color_1 = ItemColor::random();
let track_color_2 = ItemColor::random();
for i in 0..self.tracks {
let _track = app.track_add(None, Some(
let track = app.track_add(None, Some(
track_color_1.mix(track_color_2, i as f32 / self.tracks as f32).into()
))?;
track.width = 8;
}
let scene_color_1 = ItemColor::random();
let scene_color_2 = ItemColor::random();

View file

@ -64,14 +64,15 @@ render!(<Tui>|self: ArrangerTui|{
let play = Fixed::wh(5, 2, PlayPause(self.clock.is_rolling()));
let transport = TransportView::from((self, None, true));
let with_transport = |x|col!([row!(![&play, &transport]), &x]);
let with_pool = |x|Split::left(false,
if self.show_pool { self.splits[1] } else { 0 },
PhraseListView(&self.phrases), x);
with_pool(with_transport(col!([
&self.size,
let pool_size = if self.show_pool { self.splits[1] } else { 0 };
let with_pool = |x|Split::left(false, pool_size, PhraseListView(&self.phrases), x);
let status = SequencerStatus::from(self);
let with_status = |x|Tui::split_n(false, 2, status, x);
let with_size = |x|lay!([&self.size, x]);
with_size(with_status(with_pool(with_transport(col!([
Fill::w(Fixed::h(20, arranger())),
Fill::w(Fixed::h(25, &self.editor)),
])))
])))))
});
audio!(|self: ArrangerTui, client, scope|{
// Start profiling cycle

View file

@ -31,16 +31,6 @@ pub struct SequencerStatus {
pub(crate) res: String,
pub(crate) playing: bool,
}
impl Bar for SequencerStatus {
type State = SequencerTui;
fn hotkey_fg () -> Color {
TuiTheme::HOTKEY_FG
}
fn update (&mut self, _: &SequencerTui) {
todo!()
}
}
from!(|state:&SequencerTui|SequencerStatus = {
let samples = state.clock.chunk.load(Ordering::Relaxed);
let rate = state.clock.timebase.sr.get() as f64;
@ -54,8 +44,25 @@ from!(|state:&SequencerTui|SequencerStatus = {
res: format!("│{}s│{:.1}kHz│{:.1}ms│", samples, rate / 1000., buffer * 1000.),
}
});
from!(|state:&ArrangerTui|SequencerStatus = {
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();
Self {
width,
playing: state.clock.is_rolling(),
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.),
}
});
render!(<Tui>|self: SequencerStatus|Fixed::h(2, lay!([
{
Self::help(),
Fill::wh(Align::se({Tui::fg_bg(TuiTheme::orange(), TuiTheme::g(25), self.stats())})),
])));
impl SequencerStatus {
fn help () -> impl Render<Tui> {
let single = |binding, command|row!([" ", col!([
Tui::fg(TuiTheme::yellow(), binding),
command
@ -72,15 +79,20 @@ render!(<Tui>|self: SequencerStatus|Fixed::h(2, lay!([
double(("[]", "phrase"), ("{}", "order"), ),
double(("q", "enqueue"), ("e", "edit"), ),
]))
},
Fill::wh(Align::se({
Tui::fg_bg(TuiTheme::orange(), TuiTheme::g(25), row!([
&self.cpu,
&self.res,
&self.size,
]))
})),
])));
}
fn stats <'a> (&'a self) -> impl Render<Tui> + use<'a> {
row!([&self.cpu, &self.res, &self.size])
}
}
impl Bar for SequencerStatus {
type State = SequencerTui;
fn hotkey_fg () -> Color {
TuiTheme::HOTKEY_FG
}
fn update (&mut self, _: &SequencerTui) {
todo!()
}
}
//impl Bar for ArrangerStatus {
//type State = (ArrangerFocus, ArrangerSelection, bool);