From a0ce7522c32b727ad95f7e00b4ea7e017e03f66c Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 10 Jan 2025 18:03:23 +0100 Subject: [PATCH] make vertical space for editor --- output/src/map.rs | 2 +- tek/src/arranger/arranger_tui.rs | 64 ++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/output/src/map.rs b/output/src/map.rs index edc87f29..6d15d8e1 100644 --- a/output/src/map.rs +++ b/output/src/map.rs @@ -5,7 +5,7 @@ pub fn map_south( item_height: O::Unit, item: impl Content ) -> impl Content { - Push::y(item_offset, Align::n(Fixed::y(item_height, Fill::x(item)))) + Push::y(item_offset, Align::n(Fixed::y(item_height, Align::n(Fill::x(item))))) } pub fn map_south_west( diff --git a/tek/src/arranger/arranger_tui.rs b/tek/src/arranger/arranger_tui.rs index 94f431b3..5a050faa 100644 --- a/tek/src/arranger/arranger_tui.rs +++ b/tek/src/arranger/arranger_tui.rs @@ -74,9 +74,10 @@ impl Arranger { (move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), i| { let color: ItemPalette = track.color(); let color: ItemPalette = track.color().dark.into(); - let until_next = Self::cell(color, Tui::bold(true, Self::cell_until_next(track, &self.clock().playhead))); - let value = Tui::fg_bg(color.lightest.rgb, color.base.rgb, until_next); - let cell = Bsp::s(value, phat_hi(color.dark.rgb, color.darker.rgb)); + let cell = Self::cell_until_next(track, &self.clock().playhead); + let cell = Self::cell(color, Tui::bold(true, cell)); + let cell = Tui::fg_bg(color.lightest.rgb, color.base.rgb, cell); + let cell = Bsp::s(cell, phat_hi(color.dark.rgb, color.darker.rgb)); Tui::bg(color.base.rgb, map_east(x1 as u16, (x2 - x1) as u16, cell)) })).boxed()).into() } @@ -107,6 +108,22 @@ impl Arranger { })).boxed()).into() } + pub fn scenes_with_heights (&self, h: usize) -> impl Iterator { + let mut y = 0; + let editing = self.editing; + let (selected_track, selected_scene) = match self.selected { + ArrangerSelection::Clip(t, s) => (Some(t), Some(s)), + _ => (None, None) + }; + self.scenes.iter().enumerate().map(move|(s, scene)|{ + let active = editing && selected_track.is_some() && selected_scene == Some(s); + let height = if active { 15 } else { h }; + let data = (s, scene, y, y + height); + y += height; + data + }) + } + fn scene_row_headers <'a> (&'a self) -> BoxThunk<'a, TuiOut> { (||{ let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16); @@ -138,7 +155,7 @@ impl Arranger { Color::Rgb(0, 0, 0) ); *last_color.write().unwrap() = color; - map_south(y1 as u16, 3, Fill::x(cell)) + map_south(y1 as u16, h + 1, Fixed::y(h + 1, cell)) } ))).boxed() }).into() @@ -174,22 +191,21 @@ impl Arranger { //TuiTheme::g(32).into(), //); let active = editing && selected_track == Some(t) && selected_scene == Some(s); - let cell = Either(active, - Thunk::new(||&self.editor), - Thunk::new(move||phat_sel_3( - selected_track == Some(t) && selected_scene == Some(s), - Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))), - Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))), - if selected_track == Some(t) && selected_scene.map(|s|s+1) == Some(s) { - None - } else { - Some(TuiTheme::g(32).into()) - }, - TuiTheme::g(32).into(), - TuiTheme::g(32).into(), - )) - ); - map_south(y1 as u16, 3, Fill::x(cell)) + let editor = Thunk::new(||&self.editor); + let cell = Thunk::new(move||phat_sel_3( + selected_track == Some(t) && selected_scene == Some(s), + Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))), + Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))), + if selected_track == Some(t) && selected_scene.map(|s|s+1) == Some(s) { + None + } else { + Some(TuiTheme::g(32).into()) + }, + TuiTheme::g(32).into(), + TuiTheme::g(32).into(), + )); + let cell = Either(active, editor, cell); + map_south(y1 as u16, h + 1, Fill::x(cell)) } ))).boxed() )) @@ -239,14 +255,6 @@ impl Arranger { Some(result) } - pub fn scenes_with_heights (&self, h: usize) -> impl Iterator { - let mut y = 0; - self.scenes.iter().enumerate().map(move|(index, scene)|{ - let data = (index, scene, y, y + h); - y += h; - data - }) - } fn scene_rows (&self) -> impl Content + use<'_> { let scenes_w = 16.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16); Map::new(||self.scenes_with_heights(1), move|(_, scene, y1, y2), i| {