mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
ClipsView: refactor those horrible nested closures
This commit is contained in:
parent
4d0868add8
commit
e9b4a2ca78
1 changed files with 32 additions and 23 deletions
|
|
@ -31,26 +31,36 @@ impl ClipCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl Arrangement {
|
||||
|
||||
}
|
||||
|
||||
impl ClipsView for Arrangement {}
|
||||
|
||||
impl<'a> ClipsView for ArrangerView<'a> {}
|
||||
|
||||
pub trait ClipsView: HasTrackScroll + HasSceneScroll + Send + Sync {
|
||||
fn scenes_clips_2 <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
Fixed::y(self.scenes().len() as u16 * 2,
|
||||
Tui::bg(theme.darker.rgb,
|
||||
Align::w(Fill::x(Map::new(
|
||||
||self.scenes().iter().skip(self.scene_scroll()),
|
||||
move|scene: &'a Scene, index|self.track_scenes(scene, index))))))
|
||||
fn scenes_clips_2 <'a> (
|
||||
&'a self,
|
||||
theme: ItemTheme
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Fixed::y(self.scenes().len() as u16 * 2, Tui::bg(theme.darker.rgb,
|
||||
Align::w(Fill::x(Map::new(||self.scenes().iter().skip(self.scene_scroll()),
|
||||
move|scene: &'a Scene, index|self.track_scenes(index, scene))))))
|
||||
}
|
||||
fn track_scenes (&self, scene: &Scene, scene_index: usize) -> impl Content<TuiOut> {
|
||||
fn track_scenes <'a> (
|
||||
&'a self,
|
||||
scene_index: usize,
|
||||
scene: &'a Scene
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Push::y(scene_index as u16 * 2u16, Fixed::xy(20, 2, Map::new(
|
||||
move||scene.clips.iter().skip(self.track_scroll()),
|
||||
move|clip: &Option<Arc<RwLock<MidiClip>>>, track_index|{
|
||||
move|clip: &'a Option<Arc<RwLock<MidiClip>>>, track_index|
|
||||
self.track_scene_clip(scene_index, scene, track_index, clip))))
|
||||
}
|
||||
fn track_scene_clip (
|
||||
&self,
|
||||
scene_index: usize,
|
||||
scene: &Scene,
|
||||
track_index: usize,
|
||||
clip: &Option<Arc<RwLock<MidiClip>>>
|
||||
) -> impl Content<TuiOut> {
|
||||
let (theme, text) = if let Some(clip) = clip {
|
||||
let clip = clip.read().unwrap();
|
||||
(clip.color, clip.name.clone())
|
||||
|
|
@ -61,6 +71,5 @@ pub trait ClipsView: HasTrackScroll + HasSceneScroll + Send + Sync {
|
|||
format!(" {scene_index:2} {track_index:2} "),
|
||||
Tui::fg(Rgb(255, 255, 255),
|
||||
Tui::bold(true, format!("{}", text))))))
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue