mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
fix keymap macros. rendering issue
This commit is contained in:
parent
6f51872856
commit
f3fd88a199
15 changed files with 303 additions and 180 deletions
|
|
@ -58,16 +58,17 @@ impl<'a> Groovebox<'a> {
|
|||
note_buf: vec![],
|
||||
perf: PerfModel::default(),
|
||||
|
||||
view: EdnView::from(include_str!("groovebox/groovebox.edn")),
|
||||
view: EdnView::new(include_str!("groovebox/groovebox.edn"))?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
has_clock!(|self: Groovebox|self.player.clock());
|
||||
has_clock!(|self: Groovebox<'a>|self.player.clock());
|
||||
|
||||
impl<'a> EdnLayout<'a, Tui> for Groovebox {
|
||||
fn get_bool (&self, item: &Item<&str>) -> bool { todo!() }
|
||||
fn get_unit (&self, item: &Item<&str>) -> u16 {
|
||||
impl<'a> EdnLayout<'a, Tui> for Groovebox<'a> {
|
||||
fn get_bool (&self, item: &EdnItem<&str>) -> bool { todo!() }
|
||||
fn get_unit (&self, item: &EdnItem<&str>) -> u16 {
|
||||
use EdnItem::*;
|
||||
match item {
|
||||
Sym(":sample-h") => if self.compact { 0 } else { 5 },
|
||||
Sym(":samples-w") => if self.compact { 4 } else { 11 },
|
||||
|
|
@ -79,7 +80,8 @@ impl<'a> EdnLayout<'a, Tui> for Groovebox {
|
|||
_ => 0
|
||||
}
|
||||
}
|
||||
fn get_content (&self, item: &Item<&str>) -> Box<dyn Render<Tui> + '_> {
|
||||
fn get_content (&'a self, item: &EdnItem<&str>) -> Box<EdnRender<'a, Tui>> {
|
||||
use EdnItem::*;
|
||||
match item {
|
||||
Sym(":input-meter-l") => Box::new(Meter("L/", self.sampler.input_meter[0])),
|
||||
Sym(":input-meter-r") => Box::new(Meter("R/", self.sampler.input_meter[1])),
|
||||
|
|
@ -103,3 +105,52 @@ impl<'a> EdnLayout<'a, Tui> for Groovebox {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 Content<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 Content<Tui> + use<'_> {
|
||||
row!(&self.cpu, &self.size)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue