much more like it

This commit is contained in:
🪞👃🪞 2025-01-10 22:25:40 +01:00
parent 54414e2114
commit d5db15f5a1
2 changed files with 30 additions and 28 deletions

View file

@ -48,9 +48,9 @@ pub enum TekMode {
/// Multi-track MIDI sequencer. /// Multi-track MIDI sequencer.
Arranger { Arranger {
/// Number of scenes /// Number of scenes
#[arg(short = 'y', long, default_value_t = 12)] scenes: usize, #[arg(short = 'y', long, default_value_t = 1)] scenes: usize,
/// Number of tracks /// Number of tracks
#[arg(short = 'x', long, default_value_t = 8)] tracks: usize, #[arg(short = 'x', long, default_value_t = 1)] tracks: usize,
/// Width of tracks /// Width of tracks
#[arg(short = 'w', long, default_value_t = 8)] track_width: usize, #[arg(short = 'w', long, default_value_t = 8)] track_width: usize,
}, },

View file

@ -110,15 +110,14 @@ impl 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) => {
let scenes_w = 16; let scenes_w = self.sidebar_w();
let tracks_w = self.tracks_with_widths().last().unwrap().3 as u16; let tracks_w = self.tracks_with_widths().last().unwrap().3 as u16;
let row = move|h, header, cells|Fixed::y(h, Bsp::e( let row_head = |h, head|Fixed::x(scenes_w, head);
Fixed::x(scenes_w, header), let row_cells = |h, cells|Fill::x(Align::c(Fixed::xy(tracks_w, h, cells)));
Fill::x(Align::c(Fixed::xy(tracks_w, h, cells))) let row = move|h, head, cells|Fixed::y(h, Bsp::e(row_head(h, head), row_cells(h, cells)));
)); let big = move|h, head, cells|Fill::y(Bsp::e(
let big = move|h, header, cells|Fixed::y(h, Bsp::e( Tui::bg(Color::Reset, row_head(h, head)),
Fill::y(Align::c(Fixed::x(scenes_w, header))), Tui::bg(Color::Reset, row_cells(h, cells))
Fill::x(Align::c(Fixed::xy(tracks_w, h, cells)))
)); ));
//let row = move|h, header, cells|Align::w(Bsp::e( //let row = move|h, header, cells|Align::w(Bsp::e(
//Align::w(Fixed::xy(scenes_w, h, header)), //Align::w(Fixed::xy(scenes_w, h, header)),
@ -132,9 +131,9 @@ render!(TuiOut: (self: Arranger) => {
let playing = |x|Bsp::s(row(2, self.elapsed_row_header(), self.elapsed_row_cells()), Fill::y(x)); let playing = |x|Bsp::s(row(2, self.elapsed_row_header(), self.elapsed_row_cells()), Fill::y(x));
let next = |x|Bsp::s(row(2, self.next_row_header(), self.next_row_cells()), Fill::y(x)); let next = |x|Bsp::s(row(2, self.next_row_header(), self.next_row_cells()), Fill::y(x));
let tracks = |x|Bsp::s(row(3, self.track_row_header(), self.track_row_cells()), Fill::y(Align::c(x))); let tracks = |x|Bsp::s(row(3, self.track_row_header(), self.track_row_cells()), Fill::y(Align::c(x)));
let scenes = |x|Bsp::s(big(h.saturating_sub(13), self.scene_row_headers(), Tui::bg(Color::Green, self.scene_row_cells())), x); let scenes = |x|Bsp::s(big(h.saturating_sub(13), self.scene_row_headers(), self.scene_row_cells()), x);
let inputs = |x|Bsp::n(row(2, self.input_row_header(), self.input_row_cells()), Fill::y(x)); let inputs = |x|Bsp::n(row(2, self.input_row_header(), self.input_row_cells()), Fill::y(x));
self.size.of(toolbar(pool(Fill::xy(Align::c(editing(inputs(outputs(playing(next(tracks(scenes(Fill::xy(""))))))))))))) self.size.of(toolbar(Fill::xy(Align::c(editing(pool(inputs(outputs(playing(next(tracks(scenes(Fill::xy("")))))))))))))
//let enclosed = |x|Outer(Style::default().fg(Color::Rgb(72,72,72))).enclose(x); //let enclosed = |x|Outer(Style::default().fg(Color::Rgb(72,72,72))).enclose(x);
//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16); //.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16);
//Bsp::s(arrrrrr, enclosed(&self.editor)) //Bsp::s(arrrrrr, enclosed(&self.editor))
@ -173,7 +172,7 @@ impl Arranger {
{ {
let mut x = 0; let mut x = 0;
tracks.iter().enumerate().map(move |(index, track)|{ tracks.iter().enumerate().map(move |(index, track)|{
let width = if Some(index) == active { 40 } else { track.width }; let width = if Some(index) == active { 40 } else { track.width.max(8) };
let data = (index, track, x, x + width); let data = (index, track, x, x + width);
x += width; x += width;
data data
@ -265,7 +264,7 @@ impl Arranger {
ArrangerSelection::Scene(s) => Some(s), ArrangerSelection::Scene(s) => Some(s),
_ => None _ => None
}; };
Tui::bg(Color::Reset, Fill::y(Map::new( Fill::y(Align::y(Map::new(
||self.scenes_with_heights(2), ||self.scenes_with_heights(2),
move|(_, scene, y1, y2), i| { move|(_, scene, y1, y2), i| {
let h = (y2 - y1) as u16; let h = (y2 - y1) as u16;
@ -301,7 +300,7 @@ impl Arranger {
}; };
let tracks = move||self.tracks_with_widths(); let tracks = move||self.tracks_with_widths();
let scenes = ||self.scenes_with_heights(2); let scenes = ||self.scenes_with_heights(2);
(move||Align::x(Map::new(tracks, move|(_, track, x1, x2), t| { (move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
let w = (x2 - x1) as u16; let w = (x2 - x1) as u16;
let color: ItemPalette = track.color().dark.into(); let color: ItemPalette = track.color().dark.into();
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0)))); let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
@ -346,9 +345,9 @@ impl Arranger {
map_east( map_east(
x1 as u16, x1 as u16,
w, w,
Fixed::x(w, Tui::bg(Color::Reset, Fill::y(cells)).boxed()) Fixed::x(w, Tui::bg(Color::Reset, Align::y(cells)).boxed())
) )
})).boxed()).into() }))).boxed()).into()
} }
fn track_column_separators <'a> (&'a self) -> impl Content<TuiOut> + 'a { fn track_column_separators <'a> (&'a self) -> impl Content<TuiOut> + 'a {
@ -442,12 +441,15 @@ impl Arranger {
fn toolbar_view (&self) -> impl Content<TuiOut> + use<'_> { fn toolbar_view (&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 sidebar_w (&self) -> u16 {
let w = self.size.w(); let w = self.size.w();
let clip_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 }; let w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
let pool_w = if self.pool.visible { clip_w } else { 0 }; let w = if self.pool.visible { w } else { 0 };
w
}
fn pool_view (&self) -> impl Content<TuiOut> + use<'_> {
let pool = Pull::y(1, Fill::y(Align::e(PoolView(self.pool.visible, &self.pool)))); let pool = Pull::y(1, Fill::y(Align::e(PoolView(self.pool.visible, &self.pool))));
Fixed::x(pool_w, Align::e(Fill::y(PoolView(self.compact, &self.pool)))) Fixed::x(self.sidebar_w(), Align::e(Fill::y(PoolView(self.compact, &self.pool))))
} }
pub fn track_widths (tracks: &[ArrangerTrack]) -> Vec<(usize, usize)> { pub fn track_widths (tracks: &[ArrangerTrack]) -> Vec<(usize, usize)> {
@ -579,13 +581,13 @@ fn phat_sel_3 <T: Content<TuiOut>> (
) -> impl Content<TuiOut> { ) -> impl Content<TuiOut> {
let border = Style::default().fg(Color::Rgb(255,255,255)).bg(middle); let border = Style::default().fg(Color::Rgb(255,255,255)).bg(middle);
Either(selected, Either(selected,
Tui::bg(middle, Outer(border).enclose( Align::w(Bsp::s("", Bsp::s(field_1, ""))))), Tui::bg(middle, Outer(border).enclose(Align::w(Bsp::s("", Bsp::n("", Fill::y(field_1)))))),
Bsp::s( Bsp::s(Fixed::y(1, top.map(|top|phat_lo(middle, top))),
Fixed::y(1, top.map(|top|phat_lo(middle, top))), Bsp::n(Fixed::y(1, phat_hi(middle, bottom)),
Bsp::n(phat_hi(middle, bottom), Fill::xy(Tui::bg(middle, field_2)),
Fixed::y(1, Fill::x(Tui::bg(middle, field_2))), )
)
) )
))
} }
//pub struct ArrangerVCursor { //pub struct ArrangerVCursor {