starting to look good... wait what

This commit is contained in:
🪞👃🪞 2025-05-16 00:16:56 +03:00
parent 9aeb792f7d
commit fca1e85611
6 changed files with 38 additions and 23 deletions

View file

@ -195,6 +195,9 @@ impl App {
fn focus_editor (&self) -> bool {
self.is_editing()
}
fn is_editing (&self) -> bool {
HasEditor::is_editing(self)
}
fn focus_message (&self) -> bool {
matches!(self.dialog, Some(Dialog::Message(..)))
}

View file

@ -107,6 +107,12 @@ impl App {
pub fn view_arranger_scenes (&self) -> impl Content<TuiOut> + use<'_> {
self.scenes_view(&self.editor)
}
pub fn view_arranger_scenes_names (&self) -> impl Content<TuiOut> + use<'_> {
self.scenes_names()
}
pub fn view_arranger_scenes_clips (&self) -> impl Content<TuiOut> + use<'_> {
self.scenes_clips(&self.editor)
}
pub fn view_arranger_scene_names <'a> (&'a self) -> impl Content<TuiOut> + use<'a> {
let h = self.project.scenes.len() as u16 * 2;
let bg = self.color.darker.rgb;
@ -357,16 +363,16 @@ impl App {
impl ArrangerSceneRows for App {
fn arrangement (&self) -> &Arrangement {
self.project
&self.project
}
fn scenes_height (&self) -> u16 {
self.project.scenes_height
(self.height() as u16).saturating_sub(20)
}
fn width_side (&self) -> u16 {
fn width_side (&self) -> u16 {
20
}
fn width_mid (&self) -> u16 {
self.width().saturating_sub(self.width_side() * 2)
fn width_mid (&self) -> u16 {
(self.width() as u16).saturating_sub(self.width_side())
}
fn scene_selected (&self) -> Option<usize> {
self.project.selection.scene()
@ -378,7 +384,7 @@ impl ArrangerSceneRows for App {
self.project.selection.track()
}
fn is_editing (&self) -> bool {
self.is_editing
self.editor.is_some()
}
}

View file

@ -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]))))
}

View file

@ -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 }
}