mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: once and for all arranger rendering architecture
one wishes
This commit is contained in:
parent
b6d1978a55
commit
b5326b578c
3 changed files with 32 additions and 14 deletions
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -67,17 +67,17 @@ pub trait HasTracks: Has<Vec<Track>> + Send + Sync {
|
|||
const TRACK_SPACING: usize = 0;
|
||||
}
|
||||
|
||||
pub trait HasTracksScrolled: HasTracks {
|
||||
fn tracks_scroll (&self) -> usize;
|
||||
pub trait HasTrackScroll: HasTracks {
|
||||
fn track_scroll (&self) -> usize;
|
||||
}
|
||||
impl HasTracksScrolled for Arrangement {
|
||||
fn tracks_scroll (&self) -> usize { self.tracks_scroll }
|
||||
impl HasTrackScroll for Arrangement {
|
||||
fn track_scroll (&self) -> usize { self.track_scroll }
|
||||
}
|
||||
impl<'a> HasTracksScrolled for ArrangerView<'a> {
|
||||
fn tracks_scroll (&self) -> usize { self.arrangement.tracks_scroll() }
|
||||
impl<'a> HasTrackScroll for ArrangerView<'a> {
|
||||
fn track_scroll (&self) -> usize { self.arrangement.track_scroll() }
|
||||
}
|
||||
|
||||
impl<T: HasTracksScrolled + HasSelection> TracksView for T {}
|
||||
impl<T: HasTrackScroll + HasSelection> TracksView for T {}
|
||||
|
||||
pub trait TracksView: HasTracks + HasSelection {
|
||||
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> + use<'_> {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ pub struct ArrangerView<'a> {
|
|||
/// Height available to display track headers.
|
||||
pub tracks_height: u16,
|
||||
}
|
||||
impl<'a> Has<Vec<Scene>> for ArrangerView<'a> {
|
||||
fn get (&self) -> &Vec<Scene> {
|
||||
&self.arrangement.scenes
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Vec<Scene> {
|
||||
&mut self.arrangement.scenes
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ArrangerView<'a> {
|
||||
pub fn new (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue