edn arranger

This commit is contained in:
🪞👃🪞 2025-01-11 14:25:51 +01:00
parent 1fe60bff5f
commit f7d9d2e107
2 changed files with 30 additions and 21 deletions

3
tek/src/arranger.edn Normal file
View file

@ -0,0 +1,3 @@
(bsp/s :toolbar
(fill/x (align/c (bsp/w :pool
(bsp/n :inputs (bsp/s :outputs (bsp/s :tracks :scenes)))))))

View file

@ -27,35 +27,41 @@ pub struct Arranger {
} }
pub(crate) const HEADER_H: u16 = 0; // 5 pub(crate) const HEADER_H: u16 = 0; // 5
pub(crate) const SCENES_W_OFFSET: u16 = 0; pub(crate) const SCENES_W_OFFSET: u16 = 0;
render!(TuiOut: (self: Arranger) => { render!(TuiOut: (self: Arranger) => self.size.of(EdnView::from_source(self, Self::EDN)));
impl EdnViewData<TuiOut> for &Arranger {
fn get_content <'a> (&'a self, item: EdnItem<&'a str>) -> RenderBox<'a, TuiOut> {
use EdnItem::*;
let scenes_w = self.sidebar_w(); let scenes_w = self.sidebar_w();
let tracks_w = self.tracks_with_sizes().last().unwrap().3 as u16; let tracks_w = self.tracks_with_sizes().last().unwrap().3 as u16;
let h = self.size.h() as u16; match item {
let ins = 1 + self.midi_ins[0].connect.len() as u16; Nil => Box::new(()),
let outs = 1 + self.midi_outs[0].connect.len() as u16; Exp(items) => Box::new(EdnView::from_items(*self, items.as_slice())),
let toolbar = |x|Bsp::s(self.toolbar_view(), x); Sym(":editor") => (&self.editor).boxed(),
let pool = |x|Bsp::w(self.pool_view(), x); Sym(":pool") => self.pool().boxed(),
let editing = |x|Bsp::n(Bsp::e(self.editor.clip_status(), self.editor.edit_status()), x); Sym(":status") => self.status().boxed(),
let playing = |x|x;//Bsp::s(self.play_row(tracks_w), Fill::y(x)); Sym(":toolbar") => self.toolbar().boxed(),
let next = |x|x;//Bsp::s(self.next_row(tracks_w), Fill::y(x)); Sym(":tracks") => self.track_row(tracks_w).boxed(),
let tracks = |x|Bsp::s(self.track_row(tracks_w), Fill::y(Align::c(x))); Sym(":scenes") => self.scene_row(tracks_w).boxed(),
let outputs = |x|Bsp::s(self.output_row(tracks_w), Fill::y(x)); Sym(":inputs") => self.input_row(tracks_w).boxed(),
let scenes = |x|Bsp::s(self.scene_row(tracks_w), x); Sym(":outputs") => self.output_row(tracks_w).boxed(),
let inputs = |x|Bsp::n(self.input_row(tracks_w), Fill::y(x)); _ => panic!("no content for {item:?}")
self.size.of(toolbar(Fill::xy(Align::c( }
editing(pool(inputs(outputs(playing(next(tracks(scenes(Fill::xy(""))))))))) }
)))) }
});
impl Arranger { impl Arranger {
const EDN: &'static str = include_str!("arranger.edn");
pub const LEFT_SEP: char = '▎'; pub const LEFT_SEP: char = '▎';
pub const TRACK_MIN_WIDTH: usize = 4; pub const TRACK_MIN_WIDTH: usize = 4;
fn toolbar_view (&self) -> impl Content<TuiOut> + use<'_> { fn toolbar (&self) -> impl Content<TuiOut> + use<'_> {
Fill::x(Fixed::y(2, Align::x(TransportView::new(true, &self.clock)))) Fill::x(Fixed::y(2, Align::x(TransportView::new(true, &self.clock))))
} }
fn pool_view (&self) -> impl Content<TuiOut> + use<'_> { fn pool (&self) -> impl Content<TuiOut> + use<'_> {
Align::e(Fixed::x(self.sidebar_w(), PoolView(self.compact, &self.pool))) Align::e(Fixed::x(self.sidebar_w(), PoolView(self.compact, &self.pool)))
} }
fn status (&self) -> impl Content<TuiOut> + use<'_> {
Bsp::e(self.editor.clip_status(), self.editor.edit_status())
}
fn is_editing (&self) -> bool { fn is_editing (&self) -> bool {
!self.pool.visible !self.pool.visible
} }