almost centered arranger

This commit is contained in:
🪞👃🪞 2025-01-10 21:18:52 +01:00
parent d3d1670af2
commit 54414e2114
2 changed files with 26 additions and 22 deletions

View file

@ -43,16 +43,16 @@ pub enum TekMode {
Sequencer, Sequencer,
/// A MIDI-controlled audio sampler. /// A MIDI-controlled audio sampler.
Sampler, Sampler,
/// Sequencer and sampler together. /// Sequencer and sampler together.12
Groovebox, Groovebox,
/// Multi-track MIDI sequencer. /// Multi-track MIDI sequencer.
Arranger { Arranger {
/// Number of scenes
#[arg(short = 'y', long, default_value_t = 12)] scenes: usize,
/// Number of tracks /// Number of tracks
#[arg(short = 'x', long, default_value_t = 4)] tracks: usize, #[arg(short = 'x', long, default_value_t = 8)] 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,
/// Number of scenes
#[arg(short = 'y', long, default_value_t = 16)] scenes: usize,
}, },
/// TODO: A MIDI-controlled audio mixer /// TODO: A MIDI-controlled audio mixer
Mixer, Mixer,
@ -177,7 +177,7 @@ pub fn main () -> Usually<()> {
clock, clock,
pool: (&clip).into(), pool: (&clip).into(),
editor: (&clip).into(), editor: (&clip).into(),
selected: ArrangerSelection::Scene(4), selected: ArrangerSelection::Clip(0, 0),
scenes: vec![], scenes: vec![],
tracks: vec![], tracks: vec![],
splits: [12, 20], splits: [12, 20],

View file

@ -111,9 +111,14 @@ 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 = 16;
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 = move|h, header, cells|Fixed::y(h, Bsp::e(
Fixed::x(scenes_w, header), Fixed::x(scenes_w, header),
Fixed::y(h, Fill::x(Align::x(cells))) Fill::x(Align::c(Fixed::xy(tracks_w, h, cells)))
));
let big = move|h, header, cells|Fixed::y(h, Bsp::e(
Fill::y(Align::c(Fixed::x(scenes_w, header))),
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)),
@ -126,10 +131,10 @@ render!(TuiOut: (self: Arranger) => {
let outputs = |x|Bsp::s(row(2, self.output_row_header(), self.output_row_cells()), Fill::y(x)); let outputs = |x|Bsp::s(row(2, self.output_row_header(), self.output_row_cells()), Fill::y(x));
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(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(row(h.saturating_sub(13), self.scene_row_headers(), self.scene_row_cells()), 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 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(editing(inputs(outputs(playing(next(tracks(scenes(Fill::xy(""))))))))))) self.size.of(toolbar(pool(Fill::xy(Align::c(editing(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))
@ -182,7 +187,7 @@ impl Arranger {
} }
fn output_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn output_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
//let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16); //let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16);
(move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| { (move||Align::x(Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| {
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 cell = Bsp::s(format!(" M S "), phat_hi(color.dark.rgb, color.darker.rgb)); let cell = Bsp::s(format!(" M S "), phat_hi(color.dark.rgb, color.darker.rgb));
@ -194,7 +199,7 @@ impl Arranger {
(||Tui::bold(true, Tui::fg(TuiTheme::g(128), "Playing")).boxed()).into() (||Tui::bold(true, Tui::fg(TuiTheme::g(128), "Playing")).boxed()).into()
} }
fn elapsed_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn elapsed_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
(move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| { (move||Align::x(Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| {
//let color = track.color(); //let color = track.color();
let color: ItemPalette = track.color().dark.into(); let color: ItemPalette = track.color().dark.into();
let timebase = self.clock().timebase(); let timebase = self.clock().timebase();
@ -215,7 +220,7 @@ impl Arranger {
(||Tui::bold(true, Tui::fg(TuiTheme::g(128), "Next")).boxed()).into() (||Tui::bold(true, Tui::fg(TuiTheme::g(128), "Next")).boxed()).into()
} }
fn next_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn next_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
(move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| { (move||Align::x(Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| {
let color: ItemPalette = track.color(); let color: ItemPalette = track.color();
let color: ItemPalette = track.color().dark.into(); let color: ItemPalette = track.color().dark.into();
let cell = Self::cell_until_next(track, &self.clock().playhead); let cell = Self::cell_until_next(track, &self.clock().playhead);
@ -231,20 +236,20 @@ impl Arranger {
} }
fn track_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn track_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
let iter = ||self.tracks_with_widths(); let iter = ||self.tracks_with_widths();
(move||Fixed::y(2, Map::new(iter, move|(_, track, x1, x2), i| { (move||Align::x(Map::new(iter, move|(_, track, x1, x2), i| {
let color = track.color(); let color = track.color();
let name = Push::x(1, &track.name); let name = Push::x(1, &track.name);
Tui::bg(color.base.rgb, map_east(x1 as u16, (x2 - x1) as u16, Tui::bg(color.base.rgb, map_east(x1 as u16, (x2 - x1) as u16,
Tui::fg_bg(color.lightest.rgb, color.base.rgb, Tui::fg_bg(color.lightest.rgb, color.base.rgb,
phat_cell(color, color.darkest.rgb.into(), //phat_cell(color, color.darkest.rgb.into(),
Tui::bold(true, name))))) })).boxed()).into() Tui::bold(true, Fill::x(Align::x(name)))))) })).boxed()).into()
} }
fn input_row_header <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn input_row_header <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
(||Fill::x(Tui::bold(true, Tui::fg_bg(TuiTheme::g(0), TuiTheme::g(200), "[ ] In 1: Korg"))).boxed()).into() (||Fill::x(Tui::bold(true, Tui::fg_bg(TuiTheme::g(0), TuiTheme::g(200), "[ ] In 1: Korg"))).boxed()).into()
} }
fn input_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> { fn input_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
(move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| { (move||Align::x(Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| {
let w = (x2 - x1) as u16; let w = (x2 - x1) as u16;
let cell = Bsp::s("[Rec]", "[Mon]"); let cell = Bsp::s("[Rec]", "[Mon]");
let color: ItemPalette = track.color().dark.into(); let color: ItemPalette = track.color().dark.into();
@ -260,7 +265,7 @@ impl Arranger {
ArrangerSelection::Scene(s) => Some(s), ArrangerSelection::Scene(s) => Some(s),
_ => None _ => None
}; };
Tui::bg(Color::Rgb(0,0,0), Fill::y(Map::new( Tui::bg(Color::Reset, Fill::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;
@ -296,9 +301,8 @@ 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||Fixed::y(2, Map::new(tracks, move|(_, track, x1, x2), t| { (move||Align::x(Map::new(tracks, move|(_, track, x1, x2), t| {
let w = (x2 - x1) as u16; let w = (x2 - x1) as u16;
let cell = Bsp::s("[Rec]", "[Mon]");
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))));
let cells = Map::new(scenes, move|(_, scene, y1, y2), s| { let cells = Map::new(scenes, move|(_, scene, y1, y2), s| {
@ -318,7 +322,7 @@ impl Arranger {
//TuiTheme::g(32).into(), //TuiTheme::g(32).into(),
//TuiTheme::g(32).into(), //TuiTheme::g(32).into(),
//); //);
let active = editing && selected_track == Some(t) && selected_scene == Some(s); let active = editing && selected_scene == Some(s) && selected_track == Some(t);
let editor = Thunk::new(||&self.editor); let editor = Thunk::new(||&self.editor);
let cell = Thunk::new(move||phat_sel_3( let cell = Thunk::new(move||phat_sel_3(
selected_track == Some(t) && selected_scene == Some(s), selected_track == Some(t) && selected_scene == Some(s),
@ -342,7 +346,7 @@ impl Arranger {
map_east( map_east(
x1 as u16, x1 as u16,
w, w,
Fixed::x(w, Tui::bg(Color::Rgb(0,0,0), Fill::y(cells)).boxed()) Fixed::x(w, Tui::bg(Color::Reset, Fill::y(cells)).boxed())
) )
})).boxed()).into() })).boxed()).into()
} }