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