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

@ -6,28 +6,28 @@ use EdnItem::*;
const EDN: &'static str = include_str!("groovebox.edn");
//impl Content<Tui> for Groovebox {
//fn content (&self) -> impl Render<Tui> {
//self.size.of(EdnView::new(self, EDN).expect("failed to build view"))
//}
//}
impl Content<TuiOut> for Groovebox {
fn content (&self) -> impl Render<TuiOut> {
self.size.of(EdnView::new(self, EDN).expect("failed to build view"))
}
}
render!(Tui: (self: Groovebox) => self.size.of(
Bsp::s(self.toolbar_view(),
Bsp::n(self.selector_view(),
Bsp::n(self.sample_view(),
Bsp::n(self.status_view(),
Bsp::w(self.pool_view(), Fill::xy(Bsp::e(self.sampler_view(), &self.editor)))))))));
//render!(TuiOut: (self: Groovebox) => self.size.of(
//Bsp::s(self.toolbar_view(),
//Bsp::n(self.selector_view(),
//Bsp::n(self.sample_view(),
//Bsp::n(self.status_view(),
//Bsp::w(self.pool_view(), Fill::xy(Bsp::e(self.sampler_view(), &self.editor)))))))));
impl Groovebox {
fn toolbar_view (&self) -> impl Content<Tui> + use<'_> {
fn toolbar_view (&self) -> impl Content<TuiOut> + use<'_> {
Fill::x(Fixed::y(2, lay!(
Align::w(Meter("L/", self.sampler.input_meter[0])),
Align::e(Meter("R/", self.sampler.input_meter[1])),
Align::x(TransportView::new(true, &self.player.clock)),
)))
}
fn selector_view (&self) -> impl Content<Tui> + use<'_> {
fn selector_view (&self) -> impl Content<TuiOut> + use<'_> {
row!(
ClipSelected::play_phrase(&self.player),
ClipSelected::next_phrase(&self.player),
@ -35,23 +35,23 @@ impl Groovebox {
MidiEditStatus(&self.editor),
)
}
fn sample_view (&self) -> impl Content<Tui> + use<'_> {
fn sample_view (&self) -> impl Content<TuiOut> + use<'_> {
let note_pt = self.editor.note_point();
let sample_h = if self.compact { 0 } else { 5 };
Max::y(sample_h, Fill::xy(
SampleViewer::from_sampler(&self.sampler, note_pt)))
}
fn status_view (&self) -> impl Content<Tui> + use<'_> {
fn status_view (&self) -> impl Content<TuiOut> + use<'_> {
let note_pt = self.editor.note_point();
Align::w(Fixed::y(1, SamplerStatus(&self.sampler, note_pt)))
}
fn pool_view (&self) -> impl Content<Tui> + use<'_> {
fn pool_view (&self) -> impl Content<TuiOut> + use<'_> {
let w = self.size.w();
let pool_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
Fixed::x(if self.compact { 5 } else { pool_w },
PoolView(self.compact, &self.pool))
}
fn sampler_view (&self) -> impl Content<Tui> + use<'_> {
fn sampler_view (&self) -> impl Content<TuiOut> + use<'_> {
let sampler_w = if self.compact { 4 } else { 11 };
let sampler_y = if self.compact { 1 } else { 0 };
Fixed::x(sampler_w, Push::y(sampler_y, Fill::y(
@ -59,7 +59,7 @@ impl Groovebox {
}
}
//render!(Tui: (self: Groovebox) => self.size.of(
//render!(TuiOut: (self: Groovebox) => self.size.of(
//Bsp::s(self.toolbar_view(),
//Bsp::n(self.selector_view(),
//Bsp::n(self.sample_view(),
@ -68,8 +68,8 @@ impl Groovebox {
//const GROOVEBOX_EDN: &'static str = include_str!("groovebox.edn");
//impl Content<Tui> for Groovebox {
//fn content (&self) -> impl Content<Tui> {
//impl Content<TuiOut> for Groovebox {
//fn content (&self) -> impl Content<TuiOut> {
//EdnView::parse(self.edn.as_slice())
//}
//}
@ -119,17 +119,17 @@ impl Groovebox {
//}
////impl Groovebox {
////fn status_view (&self) -> impl Content<Tui> + use<'_> {
////fn status_view (&self) -> impl Content<TuiOut> + use<'_> {
////let note_pt = self.editor.note_point();
////Align::w(Fixed::y(1, ))
////}
////fn pool_view (&self) -> impl Content<Tui> + use<'_> {
////fn pool_view (&self) -> impl Content<TuiOut> + use<'_> {
////let w = self.size.w();
////let pool_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
////Fixed::x(if self.compact { 5 } else { pool_w },
////)
////}
////fn sampler_view (&self) -> impl Content<Tui> + use<'_> {
////fn sampler_view (&self) -> impl Content<TuiOut> + use<'_> {
////let sampler_w = if self.compact { 4 } else { 11 };
////let sampler_y = if self.compact { 1 } else { 0 };
////Fixed::x(sampler_w, Push::y(sampler_y, Fill::y(