remove usage of layers for optional rendering

This commit is contained in:
🪞👃🪞 2024-12-31 15:20:38 +01:00
parent 49adf34b02
commit 46609855eb

View file

@ -46,23 +46,19 @@ impl<'a> ArrangerVClips<'a> {
fn format_clip ( fn format_clip (
scene: &'a ArrangerScene, index: usize, track: &'a ArrangerTrack, w: u16, h: u16 scene: &'a ArrangerScene, index: usize, track: &'a ArrangerTrack, w: u16, h: u16
) -> impl Content<Tui> + use<'a> { ) -> impl Content<Tui> + use<'a> {
Fixed::xy(w, h, Layers::new(move |add|{ scene.clips.get(index).map(|clip|clip.as_ref().map(|phrase|{
if let Some(Some(phrase)) = scene.clips.get(index) { let phrase = phrase.read().unwrap();
let mut bg = TuiTheme::border_bg(); let mut bg = TuiTheme::border_bg();
let name = &(phrase as &Arc<RwLock<MidiClip>>).read().unwrap().name.to_string(); let name = phrase.name.to_string();
let max_w = name.len().min((w as usize).saturating_sub(2)); let max_w = name.len().min((w as usize).saturating_sub(2));
let color = phrase.read().unwrap().color; let color = phrase.color;
bg = color.dark.rgb; bg = color.dark.rgb;
if let Some((_, Some(ref playing))) = track.player.play_phrase() { if let Some((_, Some(ref playing))) = track.player.play_phrase() {
if *playing.read().unwrap() == *phrase.read().unwrap() { if *playing.read().unwrap() == *phrase {
bg = color.light.rgb bg = color.light.rgb
} }
}; };
add(&Tui::bg(bg, Fixed::xy(w, h, &Tui::bg(bg, Push::x(1, Fixed::x(w, &name.as_str()[0..max_w]))));
Push::x(1, Fixed::x(w, &name.as_str()[0..max_w])))
)?;
}
Ok(())
})) }))
} }
} }