wip: once and for all arranger rendering architecture

one wishes
This commit is contained in:
🪞👃🪞 2025-05-17 07:55:16 +03:00
parent b6d1978a55
commit b5326b578c
3 changed files with 32 additions and 14 deletions

View file

@ -35,9 +35,19 @@ pub trait HasScenes: Has<Vec<Scene>> + Send + Sync {
}
}
pub trait HasSceneScroll: HasScenes {
fn scene_scroll (&self) -> usize;
}
impl HasSceneScroll for Arrangement {
fn scene_scroll (&self) -> usize { self.scene_scroll }
}
impl<'a> HasSceneScroll for ArrangerView<'a> {
fn scene_scroll (&self) -> usize { self.arrangement.scene_scroll() }
}
pub type SceneWith<'a, T: Send + Sync> = (usize, &'a Scene, usize, usize, T);
pub trait ScenesView: Send + Sync {
pub trait ScenesView: HasSceneScroll + Send + Sync {
/// Default scene height.
const H_SCENE: usize = 2;
/// Default editor height.
@ -88,7 +98,7 @@ pub trait ScenesView: Send + Sync {
let h = self.scenes().len() as u16 * 2;
let bg = theme.darker.rgb;
Fixed::y(h, Tui::bg(bg, Align::w(Fill::x(Map::new(
||self.scenes().iter().skip(self.project.scene_scroll),
||self.scenes().iter().skip(self.scene_scroll()),
move|scene: &Scene, index|
Push::y(index as u16 * 2u16, Fixed::xy(20, 2,
Tui::bg(scene.color.dark.rgb, Align::nw(Bsp::e(
@ -149,16 +159,16 @@ pub trait ScenesView: Send + Sync {
)))
})))
}
fn scenes_clips_2 <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + use<'a> {
fn scenes_clips_2 (&self, theme: ItemTheme) -> impl Content<TuiOut> {
let h = self.scenes().len() as u16 * 2;
let bg = theme.darker.rgb;
Fixed::y(h, Tui::bg(bg, Align::w(Fill::x(Map::new(
||self.scenes().iter().skip(self.project.scene_scroll),
move|scene: &'a Scene, index1|
||self.scenes().iter().skip(self.scene_scroll()),
move|scene: &Scene, index1|
Push::y(index1 as u16 * 2u16, Fixed::xy(20, 2,
Map::new(
move||scene.clips.iter().skip(self.project.track_scroll),
move|clip: &'a Option<Arc<RwLock<MidiClip>>>, index2|{
move||scene.clips.iter().skip(self.track_scroll()),
move|clip: &Option<Arc<RwLock<MidiClip>>>, index2|{
let (theme, text) = if let Some(clip) = clip {
let clip = clip.read().unwrap();
(clip.color, clip.name.clone())