separate Input and Output impls

This commit is contained in:
🪞👃🪞 2025-01-05 22:01:54 +01:00
parent a6efde40f8
commit 0e821e098f
77 changed files with 465 additions and 454 deletions

View file

@ -18,7 +18,7 @@ pub struct Groovebox {
pub sampler: Sampler,
pub compact: bool,
pub size: Measure<Tui>,
pub size: Measure<TuiOut>,
pub status: bool,
pub note_buf: Vec<u8>,
pub midi_buf: Vec<Vec<Vec<u8>>>,
@ -61,7 +61,7 @@ impl Groovebox {
has_clock!(|self: Groovebox|self.player.clock());
impl EdnViewData<Tui> for &Groovebox {
impl EdnViewData<TuiOut> for &Groovebox {
fn get_bool (&self, item: EdnItem<&str>) -> bool { todo!() }
fn get_unit (&self, item: EdnItem<&str>) -> u16 {
use EdnItem::*;
@ -70,13 +70,13 @@ impl EdnViewData<Tui> for &Groovebox {
":samples-w" => if self.compact { 4 } else { 11 },
":samples-y" => if self.compact { 1 } else { 0 },
":pool-w" => if self.compact { 5 } else {
let w = self.size.w();
let w = self.size.w();
if w > 60 { 20 } else if w > 40 { 15 } else { 10 }
},
_ => 0
}
}
fn get_content <'a> (&'a self, item: EdnItem<&str>) -> RenderBox<'a, Tui> {
fn get_content <'a> (&'a self, item: EdnItem<&str>) -> RenderBox<'a, TuiOut> {
use EdnItem::*;
match item.to_str() {
":input-meter-l" => Box::new(Meter("L/", self.sampler.input_meter[0])),
@ -94,7 +94,7 @@ impl EdnViewData<Tui> for &Groovebox {
":sample-stat" => Box::new(SamplerStatus(&self.sampler, self.editor.note_point())),
":samples-view" => Box::new(SampleList::new(self.compact, &self.sampler, &self.editor)),
_ => Box::new(())
_ => panic!("{item:?}")
}
}
}
@ -119,12 +119,12 @@ from!(|state: &Groovebox|GrooveboxStatus = {
size: format!("{}x{}│", width, state.size.h()),
}
});
render!(Tui: (self: GrooveboxStatus) => Fixed::y(2, lay!(
render!(TuiOut: (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> {
fn help () -> impl Content<TuiOut> {
let single = |binding, command|row!(" ", col!(
Tui::fg(TuiTheme::yellow(), binding),
command
@ -143,7 +143,7 @@ impl GrooveboxStatus {
double(("c", "color"), ("", ""),),
))
}
fn stats (&self) -> impl Content<Tui> + use<'_> {
fn stats (&self) -> impl Content<TuiOut> + use<'_> {
row!(&self.cpu, &self.size)
}
}