mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-04-04 05:10:44 +02:00
use Arc<str> where applicable; use konst split_at
This commit is contained in:
parent
411fc0c4bc
commit
305481adee
35 changed files with 286 additions and 273 deletions
109
src/arranger.rs
109
src/arranger.rs
|
|
@ -94,6 +94,11 @@ from_jack!(|jack| Arranger {
|
|||
compact: true,
|
||||
}
|
||||
});
|
||||
has_clock!(|self: Arranger|&self.clock);
|
||||
has_phrases!(|self: Arranger|self.pool.phrases);
|
||||
has_editor!(|self: Arranger|self.editor);
|
||||
handle!(TuiIn: |self: Arranger, input|ArrangerCommand::execute_with_state(self, input.event()));
|
||||
|
||||
//render!(TuiOut: (self: Arranger) => {
|
||||
//let pool_w = if self.pool.visible { self.splits[1] } else { 0 };
|
||||
//let color = self.color;
|
||||
|
|
@ -108,58 +113,54 @@ from_jack!(|jack| Arranger {
|
|||
//Self::render_mode(self))))), Fill::y(&"fixme: self.editor"))))));
|
||||
//self.size.of(layout)
|
||||
//});
|
||||
has_clock!(|self: Arranger|&self.clock);
|
||||
has_phrases!(|self: Arranger|self.pool.phrases);
|
||||
has_editor!(|self: Arranger|self.editor);
|
||||
handle!(TuiIn: |self: Arranger, input|ArrangerCommand::execute_with_state(self, input.event()));
|
||||
|
||||
/// Status bar for arranger app
|
||||
#[derive(Clone)]
|
||||
pub struct ArrangerStatus {
|
||||
pub(crate) width: usize,
|
||||
pub(crate) cpu: Option<String>,
|
||||
pub(crate) size: String,
|
||||
pub(crate) playing: bool,
|
||||
}
|
||||
from!(|state:&Arranger|ArrangerStatus = {
|
||||
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!(TuiOut: (self: ArrangerStatus) => Fixed::y(2, lay!(
|
||||
Self::help(),
|
||||
Fill::xy(Align::se(Tui::fg_bg(TuiTheme::orange(), TuiTheme::g(25), self.stats()))),
|
||||
)));
|
||||
impl ArrangerStatus {
|
||||
fn help () -> impl Content<TuiOut> {
|
||||
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"),
|
||||
single(" Ctrl", " scroll"),
|
||||
single(" ▲▼▶◀", " cell"),
|
||||
double(("p", "put"), ("g", "get")),
|
||||
double(("q", "enqueue"), ("e", "edit")),
|
||||
single(" wsad", " note"),
|
||||
double(("a", "append"), ("s", "set"),),
|
||||
double((",.", "length"), ("<>", "triplet"),),
|
||||
double(("[]", "phrase"), ("{}", "order"),),
|
||||
))
|
||||
}
|
||||
fn stats (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
row!(&self.cpu, &self.size)
|
||||
}
|
||||
}
|
||||
///// Status bar for arranger app
|
||||
//#[derive(Clone)]
|
||||
//pub struct ArrangerStatus {
|
||||
//pub(crate) width: usize,
|
||||
//pub(crate) cpu: Option<Arc<str>>,
|
||||
//pub(crate) size: Arc<str>,
|
||||
//pub(crate) playing: bool,
|
||||
//}
|
||||
//from!(|state:&Arranger|ArrangerStatus = {
|
||||
//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}%").into()),
|
||||
//size: format!("{}x{}│", width, state.size.h()).into(),
|
||||
//}
|
||||
//});
|
||||
//render!(TuiOut: (self: ArrangerStatus) => Fixed::y(2, lay!(
|
||||
//Self::help(),
|
||||
//Fill::xy(Align::se(Tui::fg_bg(TuiTheme::orange(), TuiTheme::g(25), self.stats()))),
|
||||
//)));
|
||||
//impl ArrangerStatus {
|
||||
//fn help () -> impl Content<TuiOut> {
|
||||
//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"),
|
||||
//single(" Ctrl", " scroll"),
|
||||
//single(" ▲▼▶◀", " cell"),
|
||||
//double(("p", "put"), ("g", "get")),
|
||||
//double(("q", "enqueue"), ("e", "edit")),
|
||||
//single(" wsad", " note"),
|
||||
//double(("a", "append"), ("s", "set"),),
|
||||
//double((",.", "length"), ("<>", "triplet"),),
|
||||
//double(("[]", "phrase"), ("{}", "order"),),
|
||||
//))
|
||||
//}
|
||||
//fn stats (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//row!(&self.cpu, &self.size)
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue