From 46609855eb37fd4a921a74c6f62b77bddabac96e Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 31 Dec 2024 15:20:38 +0100 Subject: [PATCH] remove usage of layers for optional rendering --- src/arranger/arranger_v/v_clips.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/arranger/arranger_v/v_clips.rs b/src/arranger/arranger_v/v_clips.rs index 0aac140c..ec2f1a20 100644 --- a/src/arranger/arranger_v/v_clips.rs +++ b/src/arranger/arranger_v/v_clips.rs @@ -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 + 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>).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])))); })) } }