From 37be2f4add00652148d42bbea5452733f9ee6dcf Mon Sep 17 00:00:00 2001 From: unspeaker Date: Wed, 23 Apr 2025 09:39:45 +0300 Subject: [PATCH] fold-in view_track --- crates/app/src/view.rs | 81 ++++++++++++++++++++++++++++++- crates/app/src/view/view_track.rs | 77 ----------------------------- 2 files changed, 80 insertions(+), 78 deletions(-) delete mode 100644 crates/app/src/view/view_track.rs diff --git a/crates/app/src/view.rs b/crates/app/src/view.rs index 6d7986db..bb8cca96 100644 --- a/crates/app/src/view.rs +++ b/crates/app/src/view.rs @@ -3,7 +3,6 @@ mod view_clock; pub use self::view_clock::*; mod view_color; pub use self::view_color::*; mod view_memo; pub use self::view_memo::*; mod view_meter; pub use self::view_meter::*; -mod view_track; pub use self::view_track::*; mod view_ports; pub use self::view_ports::*; mod view_layout; pub use self::view_layout::*; pub(crate) use std::fmt::Write; @@ -90,6 +89,85 @@ impl<'a> ArrangerView<'a> { } } + /// Render track headers + pub(crate) fn tracks (&'a self) -> impl Content + 'a { + let Self { width_side, width_mid, track_count, track_selected, is_editing, .. } = self; + Tryptich::center(3) + .left(*width_side, button_3("t", "track", format!("{}", *track_count), *is_editing)) + .right(*width_side, button_2("T", "add track", *is_editing)) + .middle(*width_mid, per_track(*width_mid, ||self.tracks_with_sizes_scrolled(), + |index, track|wrap( + if *track_selected == Some(index) { + track.color.light + } else { + track.color.base + }.rgb, + track.color.lightest.rgb, + Tui::bold(true, Fill::x(Align::nw(&track.name))) + ))) + } + + /// Render scenes with clips + pub(crate) fn scenes (&'a self) -> impl Content + 'a { + + let Self { + width, width_side, width_mid, + scenes_height, scene_last, scene_selected, + track_selected, is_editing, app: Tek { editor, .. }, .. + } = self; + + let scene_headers = Map::new(||self.scenes_with_scene_colors(), + move|(index, scene, y1, y2, previous): SceneWithColor, _|{ + let same_track = true; + let height = (1 + y2 - y1) as u16; + let name = Some(scene.name.clone()); + Fill::x(map_south(y1 as u16, height, Fixed::y(height, Phat { + width: 0, + height: 0, + content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⯈ ", name)))), + colors: Tek::colors( + &scene.color, + previous, + same_track && *scene_selected == Some(index), + same_track && index > 0 && *scene_selected == Some(index - 1), + *scene_last == index + ) + }))) + }); + + let scene_track_clips = per_track(*width_mid, ||self.tracks_with_sizes_scrolled(), + move|track_index, track|Map::new(||self.scenes_with_track_colors(), + move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor<'a>, _|{ + let (name, _fg, bg) = if let Some(clip) = &scene.clips[track_index] { + let clip = clip.read().unwrap(); + (Some(clip.name.clone()), clip.color.lightest.rgb, clip.color) + } else { + (None, Tui::g(96), ItemPalette::G[32]) + }; + let same_track = *track_selected == Some(track_index); + let height = (1 + y2 - y1) as u16; + map_south(y1 as u16, height, Bsp::b(Fixed::y(height, Phat { + width: 0, + height: 0, + content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name)))), + colors: Tek::colors( + &bg, + None, + same_track && *scene_selected == Some(scene_index), + same_track && scene_index > 0 && *scene_selected == Some(scene_index - 1), + *scene_last == scene_index + ) + }), When( + *is_editing && same_track && *scene_selected == Some(scene_index), + editor + ))) + })); + + Tryptich::center(*scenes_height) + .left(*width_side, scene_headers) + .middle(*width_mid, scene_track_clips) + } + pub(crate) fn tracks_with_sizes_scrolled (&'a self) -> impl TracksSizes<'a> { @@ -130,6 +208,7 @@ impl<'a> ArrangerView<'a> { } ) } + } impl Tek { diff --git a/crates/app/src/view/view_track.rs b/crates/app/src/view/view_track.rs deleted file mode 100644 index f298a726..00000000 --- a/crates/app/src/view/view_track.rs +++ /dev/null @@ -1,77 +0,0 @@ -use crate::*; - -impl<'a> ArrangerView<'a> { - /// Render track headers - pub(crate) fn tracks (&'a self) -> impl Content + 'a { - let Self { width_side, width_mid, track_count, track_selected, is_editing, .. } = self; - Tryptich::center(3) - .left(*width_side, button_3("t", "track", format!("{}", *track_count), *is_editing)) - .right(*width_side, button_2("T", "add track", *is_editing)) - .middle(*width_mid, per_track(*width_mid, ||self.tracks_with_sizes_scrolled(), - |index, track|wrap( - if *track_selected == Some(index) { - track.color.light - } else { - track.color.base - }.rgb, - track.color.lightest.rgb, - Tui::bold(true, Fill::x(Align::nw(&track.name))) - ))) - } - /// Render scenes with clips - pub(crate) fn scenes (&'a self) -> impl Content + 'a { - - let Self { - width, width_side, width_mid, - scenes_height, scene_last, scene_selected, - track_selected, is_editing, app: Tek { editor, .. }, .. - } = self; - - Tryptich::center(*scenes_height) - .left(*width_side, Map::new(||self.scenes_with_scene_colors(), - move|(index, scene, y1, y2, previous): SceneWithColor, _|{ - let same_track = true; - let height = (1 + y2 - y1) as u16; - let name = Some(scene.name.clone()); - Fill::x(map_south(y1 as u16, (1 + y2 - y1) as u16, Fixed::y(height, Phat { - width: 0, - height: 0, - content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⯈ ", name)))), - colors: Tek::colors( - &scene.color, - previous, - same_track && *scene_selected == Some(index), - same_track && index > 0 && *scene_selected == Some(index - 1), - *scene_last == index - ) - }))) - })) - .middle(*width_mid, per_track(*width_mid, ||self.tracks_with_sizes_scrolled(), - move|track_index, track|Map::new(||self.scenes_with_track_colors(), - move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor<'a>, _|{ - let (name, _fg, bg) = if let Some(clip) = &scene.clips[track_index] { - let clip = clip.read().unwrap(); - (Some(clip.name.clone()), clip.color.lightest.rgb, clip.color) - } else { - (None, Tui::g(96), ItemPalette::G[32]) - }; - let same_track = *track_selected == Some(track_index); - let height = (1 + y2 - y1) as u16; - map_south(y1 as u16, height, Bsp::b(Fixed::y(height, Phat { - width: 0, - height: 0, - content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name)))), - colors: Tek::colors( - &bg, - Some(bg), - same_track && *scene_selected == Some(scene_index), - same_track && scene_index > 0 && *scene_selected == Some(scene_index - 1), - *scene_last == scene_index - ) - }), When( - *is_editing && same_track && *scene_selected == Some(scene_index), - editor - ))) - }))) - } -}