ohh why did i begin this refactor. e57

This commit is contained in:
🪞👃🪞 2024-12-31 13:18:12 +01:00
parent 83eb9dd2fa
commit 49adf34b02
6 changed files with 46 additions and 41 deletions

View file

@ -17,12 +17,11 @@ impl<'a> ArrangerVClips<'a> {
}
}
}
impl<'a, E: Engine> Content<E> for ArrangerVClips<'a> {
fn content (&self) -> Option<impl Content<E>> {
impl<'a> Content<Tui> for ArrangerVClips<'a> {
fn content (&self) -> impl Content<Tui> {
let iter = self.scenes.iter().zip(self.rows.iter().map(|row|row.0));
let col = Coll::map(self.scenes.iter().zip(self.rows.iter().map(|row|row.0)), |(scene, pulses), i|
Self::format_scene(self.tracks, scene, pulses));
Some(Fill::xy(col))
let col = Coll::map(iter, |(scene, pulses), i|Self::format_scene(self.tracks, scene, pulses));
Fill::xy(col)
}
}
impl<'a> ArrangerVClips<'a> {
@ -30,15 +29,19 @@ impl<'a> ArrangerVClips<'a> {
fn format_scene (
tracks: &'a [ArrangerTrack], scene: &'a ArrangerScene, pulses: usize
) -> impl Content<Tui> + use<'a> {
let height = 1.max((pulses / PPQ) as u16);
let height = 1.max((pulses / PPQ) as u16);
let playing = scene.is_playing(tracks);
Fixed::y(height, row!(
Tui::bg(scene.color.base.rgb,
if playing { "" } else { " " }),
Tui::fg_bg(scene.color.lightest.rgb, scene.color.base.rgb,
Expand::x(1, Tui::bold(true, scene.name.read().unwrap().as_str()))),
Coll::map(ArrangerTrack::with_widths(tracks), |(index, track, x1, x2), _|
Push::x(Self::format_clip(scene, index, track, (x2 - x1) as u16, height)))))}
let icon = Tui::bg(
scene.color.base.rgb, if playing { "" } else { " " }
);
let name = Tui::fg_bg(scene.color.lightest.rgb, scene.color.base.rgb,
Expand::x(1, Tui::bold(true, scene.name.read().unwrap().clone()))
);
let clips = Coll::map(ArrangerTrack::with_widths(tracks), move|(index, track, x1, x2), _|
Push::x((x2 - x1) as u16, Self::format_clip(scene, index, track, (x2 - x1) as u16, height))
);
Fixed::y(height, row!(icon, name, clips))
}
fn format_clip (
scene: &'a ArrangerScene, index: usize, track: &'a ArrangerTrack, w: u16, h: u16

View file

@ -13,12 +13,12 @@ from!(|state:&ArrangerTui|ArrangerVColSep = Self {
});
render!(Tui: |self: ArrangerVColSep, to| {
let style = Some(Style::default().fg(self.fg));
Ok(for x in self.cols.iter().map(|col|col.1) {
for x in self.cols.iter().map(|col|col.1) {
let x = self.scenes_w + to.area().x() + x as u16;
for y in to.area().y()..to.area().y2() {
to.blit(&"", x, y, style);
}
})
}
});
pub struct ArrangerVRowSep {