make horizontal space for editor

This commit is contained in:
🪞👃🪞 2025-01-10 18:12:19 +01:00
parent a0ce7522c3
commit eee10cc3eb

View file

@ -160,20 +160,41 @@ impl Arranger {
))).boxed()
}).into()
}
pub fn tracks_with_widths (&self)
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
{
let active = match self.selected {
ArrangerSelection::Track(t) => Some(t),
ArrangerSelection::Clip(t, _) => Some(t),
_ => None
};
Self::tracks_with_widths_static(self.tracks.as_slice(), active)
}
fn tracks_with_widths_static (tracks: &[ArrangerTrack], active: Option<usize>)
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
{
let mut x = 0;
tracks.iter().enumerate().map(move |(index, track)|{
let width = if Some(index) == active { 40 } else { track.width };
let data = (index, track, x, x + width);
x += width;
data
})
}
fn scene_row_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
let editing = self.editing;
(move||Fixed::y(2, Map::new(||self.tracks_with_widths(), move|(_, track, x1, x2), t| {
let w = (x2 - x1) as u16;
let cell = Bsp::s("[Rec]", "[Mon]");
let color: ItemPalette = track.color().dark.into();
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
let (selected_track, selected_scene) = match self.selected {
ArrangerSelection::Clip(t, s) => (Some(t), Some(s)),
_ => (None, None)
};
map_east(x1 as u16, w, Fixed::x(w, Tui::bg(Color::Rgb(0,0,0), Fill::y(Map::new(
||self.scenes_with_heights(2),
move|(_, scene, y1, y2), s| {
let tracks = move||self.tracks_with_widths();
let scenes = ||self.scenes_with_heights(2);
(move||Fixed::y(2, Map::new(tracks, move|(_, track, x1, x2), t| {
let w = (x2 - x1) as u16;
let cell = Bsp::s("[Rec]", "[Mon]");
let color: ItemPalette = track.color().dark.into();
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 h = (y2 - y1) as u16;
let color = scene.color();
let name = "";
@ -205,28 +226,20 @@ impl Arranger {
TuiTheme::g(32).into(),
));
let cell = Either(active, editor, cell);
map_south(y1 as u16, h + 1, Fill::x(cell))
}
))).boxed()
))
map_south(
y1 as u16,
h + 1,
Fill::x(cell)
)
});
map_east(
x1 as u16,
w,
Fixed::x(w, Tui::bg(Color::Rgb(0,0,0), Fill::y(cells)).boxed())
)
})).boxed()).into()
}
pub fn tracks_with_widths (&self)
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
{
Self::tracks_with_widths_static(self.tracks.as_slice())
}
fn tracks_with_widths_static (tracks: &[ArrangerTrack])
-> impl Iterator<Item = (usize, &ArrangerTrack, usize, usize)>
{
let mut x = 0;
tracks.iter().enumerate().map(move |(index, track)|{
let data = (index, track, x, x + track.width);
x += track.width;
data
})
}
fn track_column_separators <'a> (&'a self) -> impl Content<TuiOut> + 'a {
let scenes_w = 16;//.max(SCENES_W_OFFSET + ArrangerScene::longest_name(&self.scenes) as u16);
let fg = Color::Rgb(64,64,64);
@ -291,7 +304,7 @@ impl Arranger {
let name = Tui::fg_bg(scene.color.lightest.rgb, scene.color.base.rgb,
Expand::x(1, Tui::bold(true, scene.name.clone()))
);
let clips = Map::new(||Arranger::tracks_with_widths_static(tracks), move|(index, track, x1, x2), _|
let clips = Map::new(||Arranger::tracks_with_widths_static(tracks, None), move|(index, track, x1, x2), _|
Push::x((x2 - x1) as u16, Self::cell_clip(scene, index, track, (x2 - x1) as u16, height))
);
Fixed::y(height, Bsp::e(icon, Bsp::e(name, clips)))