mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
starting to look good... wait what
This commit is contained in:
parent
9aeb792f7d
commit
fca1e85611
6 changed files with 38 additions and 23 deletions
|
|
@ -22,7 +22,8 @@ pub trait ArrangerSceneRows: Send + Sync {
|
|||
fn width_side (&self) -> u16;
|
||||
fn width_mid (&self) -> u16;
|
||||
fn scenes_names (&self) -> impl Content<TuiOut> {
|
||||
Map::new(move||self.scenes_with_prev_color(),
|
||||
let h = self.scenes_with_prev_color().last().map(|(_,_,_,h,_)|h as u16).unwrap_or(0);
|
||||
Fixed::y(h, Map::new(move||self.scenes_with_prev_color(),
|
||||
move|(s, scene, y1, y2, previous): SceneWith<'_, Option<ItemTheme>>, _|{
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let name = Some(scene.name.clone());
|
||||
|
|
@ -46,16 +47,25 @@ pub trait ArrangerSceneRows: Send + Sync {
|
|||
Fill::x(map_south(y1 as u16, height, Fixed::y(height, Phat {
|
||||
width: 0, height: 0, content, colors: [fg, bg, hi, lo]
|
||||
})))
|
||||
})
|
||||
}))
|
||||
}
|
||||
fn scenes_with_prev_color (&self) -> impl Iterator<Item=SceneWith<Option<ItemTheme>>> + Send + Sync {
|
||||
self.scenes_iter().map(|(s, scene, y1, y2)|(s, scene, y1, y2,
|
||||
(s>0).then_some(self.arrangement().scenes()[s-1].color)))
|
||||
(s>0).then(||self.arrangement().scenes()[s-1].color)))
|
||||
}
|
||||
fn per_track <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
||||
tracks: impl Fn() -> U + Send + Sync + 'a,
|
||||
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Map::new(tracks, move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
|
||||
Tui::fg_bg(track.color.lightest.rgb, track.color.darker.rgb,
|
||||
map_east(x1 as u16, (x2 - x1) as u16, callback(index, track))) })
|
||||
}
|
||||
fn scenes_clips <'a> (&'a self, editor: &'a Option<MidiEditor>)
|
||||
-> impl Content<TuiOut> + 'a
|
||||
{
|
||||
per_track(||self.tracks_with_sizes_scrolled(),
|
||||
let h = self.scenes_with_prev_color().last().map(|(_,_,_,h,_)|h as u16).unwrap_or(0);
|
||||
Fixed::y(h, Self::per_track(||self.tracks_with_sizes_scrolled(),
|
||||
move|track_index, track|Map::new(move||self.scenes_with_clip(track_index),
|
||||
move|(s, scene, y1, y2, previous): SceneWith<'_, Option<ItemTheme>>, _|{
|
||||
let (name, theme) = if let Some(clip) = &scene.clips[track_index] {
|
||||
|
|
@ -64,7 +74,6 @@ pub trait ArrangerSceneRows: Send + Sync {
|
|||
} else {
|
||||
(None, ItemTheme::G[32])
|
||||
};
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let content = Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name))));
|
||||
let same_track = self.track_selected() == Some(track_index);
|
||||
let selected = same_track && self.scene_selected() == Some(s);
|
||||
|
|
@ -73,11 +82,7 @@ pub trait ArrangerSceneRows: Send + Sync {
|
|||
let fg = theme.lightest.rgb;
|
||||
let bg = if selected { theme.light } else { theme.base }.rgb;
|
||||
let hi = if let Some(previous) = previous {
|
||||
if neighbor {
|
||||
previous.light.rgb
|
||||
} else {
|
||||
previous.base.rgb
|
||||
}
|
||||
if neighbor { previous.light.rgb } else { previous.base.rgb }
|
||||
} else {
|
||||
Reset
|
||||
};
|
||||
|
|
@ -88,17 +93,18 @@ pub trait ArrangerSceneRows: Send + Sync {
|
|||
} else {
|
||||
theme.base.rgb
|
||||
};
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
map_south(y1 as u16, height, Bsp::b(Fixed::y(height, Phat {
|
||||
width: 0, height: 0, content, colors: [fg, bg, hi, lo]
|
||||
}), When(
|
||||
self.is_editing() && same_track && self.scene_selected() == Some(s),
|
||||
editor
|
||||
)))
|
||||
}))
|
||||
})))
|
||||
}
|
||||
fn scenes_with_clip (&self, track_index: usize) -> impl Iterator<Item=SceneWith<'_, Option<ItemTheme>>> + Send + Sync {
|
||||
self.scenes_iter().map(move|(s, scene, y1, y2)|(s, scene, y1, y2,
|
||||
(s>0).then_some(self.arrangement().scenes()[s-1].clips[track_index].as_ref()
|
||||
(s>0).then(||self.arrangement().scenes()[s-1].clips[track_index].as_ref()
|
||||
.map(|c|c.read().unwrap().color)
|
||||
.unwrap_or(ItemTheme::G[32]))))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl MidiViewer for MidiEditor {
|
|||
pub trait HasEditor {
|
||||
fn editor (&self) -> Option<&MidiEditor>;
|
||||
fn editor_mut (&mut self) -> Option<&mut MidiEditor>;
|
||||
fn is_editing (&self) -> bool { true }
|
||||
fn is_editing (&self) -> bool { self.editor().is_some() }
|
||||
fn editor_w (&self) -> usize { 0 }
|
||||
fn editor_h (&self) -> usize { 0 }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue