reenable most arranger components

This commit is contained in:
i do not exist 2026-08-08 23:37:25 +03:00
parent 4aefaf452c
commit 68236a7210
4 changed files with 152 additions and 125 deletions

View file

@ -1380,9 +1380,7 @@ mod draw {
/// Load custom view definition.
pub(crate) fn load_view (
views: &Views,
name: &impl AsRef<str>,
body: &impl Language,
views: &Views, name: &impl AsRef<str>, body: &impl Language,
) -> Usually<()> {
views.write().unwrap().insert(
name.as_ref().into(),
@ -1393,7 +1391,7 @@ mod draw {
impl Keywords<Tui, XYWH<u16>> for App {
fn keywords () -> impl Iterator<Item = fn(&Self, &mut Tui, &str) -> Perhaps<XYWH<u16>>> {
[kw_when, kw_either, kw_split, kw_align, kw_exact, kw_min, kw_max, kw_push,
[kw_when, kw_either, kw_split, kw_align, kw_exact, kw_min, kw_max, kw_push, kw_full,
kw_tui_text, kw_tui_fg, kw_tui_bg]
.into_iter()
}
@ -1467,11 +1465,26 @@ mod draw {
let mut frags = lang.src()?.unwrap().split("/");
match frags.next() {
//Some(":logo") => view_logo().draw(to),
Some(":meters") => draw_meter_section(to, frags),
Some(":tracks") => draw_tracks(to, frags, self),
Some(":scenes") => draw_scenes(to, frags),
Some(":meters") => match frags.next() {
Some("input") => bg(Rgb(30, 30, 30), "Input Meters".align_s().full_h()).draw(to),
Some("output") => bg(Rgb(30, 30, 30), "Output Meters".align_s().full_h()).draw(to),
_ => panic!()
},
Some(":tracks") => match frags.next() {
None => "TODO tracks".draw(to),
Some("names") => self.project.view_track_names(self.color.clone()).draw(to),//bg(Rgb(40, 40, 40), full_w(align_w("Track Names")))),
Some("inputs") => self.project.view_track_inputs(self.color.clone()).draw(to),//bg(Rgb(40, 40, 40), "Track Inputs".align_w().full_w()).draw(to),
Some("devices") => self.project.view_track_devices(self.color.clone()).draw(to),//bg(Rgb(40, 40, 40), "Track Devices".align_w().full_w()).draw(to),
Some("outputs") => self.project.view_track_outputs(self.color.clone(), 0).draw(to),
_ => panic!()
},
Some(":scenes") => match frags.next() {
None => "TODO Scenes".draw(to),
Some(":scenes/names") => "TODO Scene Names".draw(to),
_ => panic!()
},
Some(":dialog") => draw_dialog(to, frags, self, lang),
Some(":templates") => draw_templates(to, frags, self),
Some(":templates") => view_templates(frags, self).draw(to),
Some(":sessions") => view_sessions().draw(to),
Some(":browse/title") => view_browse_title(self).draw(to),
Some(":device") => view_device(self).draw(to),
@ -1486,7 +1499,7 @@ mod draw {
std::mem::drop(views);
self.interpret(to, &lang)
} else {
unimplemented!("{lang:?}");
fg(Color::Rgb(128, 32, 32), format!("undefined: {lang:?}")).draw(to)
}
},
_ => unreachable!()
@ -1504,34 +1517,7 @@ mod draw {
fn width_dec (&mut self);
}
pub fn draw_meter_section (to: &mut Tui, mut frags: std::str::Split<&str>) -> Drawn<u16> {
match frags.next() {
Some("input") => bg(Rgb(30, 30, 30), "Input Meters".align_s().full_h()).draw(to),
Some("output") => bg(Rgb(30, 30, 30), "Output Meters".align_s().full_h()).draw(to),
_ => panic!()
}
}
pub fn draw_tracks (to: &mut Tui, mut frags: std::str::Split<&str>, state: &App) -> Drawn<u16> {
match frags.next() {
None => "TODO tracks".draw(to),
Some("names") => state.project.view_track_names(state.color.clone()).draw(to),//bg(Rgb(40, 40, 40), full_w(align_w("Track Names")))),
Some("inputs") => bg(Rgb(40, 40, 40), "Track Inputs".align_w().full_w()).draw(to),
Some("devices") => bg(Rgb(40, 40, 40), "Track Devices".align_w().full_w()).draw(to),
Some("outputs") => bg(Rgb(40, 40, 40), "Track Outputs".align_w().full_w()).draw(to),
_ => panic!()
}
}
pub fn draw_scenes (to: &mut Tui, mut frags: std::str::Split<&str>) -> Drawn<u16> {
match frags.next() {
None => "TODO Scenes".draw(to),
Some(":scenes/names") => "TODO Scene Names".draw(to),
_ => panic!()
}
}
pub fn draw_templates (to: &mut Tui, _frags: std::str::Split<&str>, state: &App) -> Drawn<u16> {
pub fn view_templates (_frags: std::str::Split<&str>, state: &App) -> impl Draw<Tui> {
let height = (state.config.modes.len() * 2) as u16;
draw(move |to: &mut Tui|{
let mut index = 0;
@ -1549,29 +1535,29 @@ mod draw {
index += 1;
});
Ok(Some(to.area().into()))
}).min_w(30).exact_h(height).draw(to)
}).min_w(30).exact_h(height)
}
pub fn per_track <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
tracks: impl Fn() -> U + Send + Sync + 'a,
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
) -> impl Draw<Tui> + 'a {
per_track_top(tracks, move|index, track|callback(index, track).full_h().align_y())
}
//pub fn per_track <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
//tracks: impl Fn() -> U + Send + Sync + 'a,
//callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
//) -> impl Draw<Tui> + 'a {
//per_track_top(tracks, move|index, track|callback(index, track).full_h().align_y())
//}
pub fn per_track_top <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
tracks: impl Fn() -> U + Send + Sync + 'a,
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
) -> impl Draw<Tui> + 'a {
bg(Reset, iter_east(tracks,
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
fg_bg(
track.color.lightest.term,
track.color.base.term,
callback(index, track)
).exact_w((x2 - x1) as u16)
}).align_x())
}
//pub fn per_track_top <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
//tracks: impl Fn() -> U + Send + Sync + 'a,
//callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
//) -> impl Draw<Tui> + 'a {
//bg(Reset, iter_east(||tracks()
//.map(move|(index, track, x1, x2): (usize, &'a Track, usize, usize)|{
//fg_bg(
//track.color.lightest.term,
//track.color.base.term,
//callback(index, track)
//).exact_w((x2 - x1) as u16)
//})).align_x())
//}
pub fn field_h <T: Screen> (
_theme: ItemTheme, _head: impl Draw<T>, _body: impl Draw<T>
@ -1932,17 +1918,43 @@ mod draw {
track.map(move|track|view_ports_status(theme, "Audio outs:", &track.audio_outs()))
}
pub fn view_track_per <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
tracks: impl Fn() -> U + Send + Sync + 'a,
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
//pub fn view_track_per <'a, T: Draw<Tui> + 'a, U: TracksSizes<'a>> (
//tracks: impl Fn() -> U + Send + Sync + 'a,
//callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
//) -> impl Draw<Tui> {
//}
/// ```
/// let _ = tek::button_2("", "", true);
/// let _ = tek::button_2("", "", false);
/// ```
pub fn button_2 <'a> (key: impl Draw<Tui>, label: impl Draw<Tui>, hide: bool) -> impl Draw<Tui> {
let c1 = tui_orange();
let c2 = tui_g(0);
let c3 = tui_g(96);
let c4 = tui_g(255);
bold(true, fg_bg(c1, c2,
east!(fg(c2, "▐"), key, fg(c3, "▐"), when(!hide, fg_bg(c4, c3, label)))))
}
/// ```
/// let _ = tek::button_3("", "", "", true);
/// let _ = tek::button_3("", "", "", false);
/// ```
pub fn button_3 <'a> (
key: impl Draw<Tui>, label: impl Draw<Tui>, value: impl Draw<Tui>, editing: bool,
) -> impl Draw<Tui> {
iter_east(tracks, move|(index, track, x1, x2): (usize, &Track, usize, usize), _|{
fg_bg(
track.color.lightest.term,
track.color.base.term,
callback(index, track)
).exact_w((x2 - x1) as u16)
})
let c1 = tui_orange();
let c2 = tui_g(0);
let c3 = tui_g(96);
let c4 = tui_g(255);
let c5 = tui_g(128);
bold(true, east(
fg_bg(c1, c2,
east(fg(c2, "▐"), east(key, fg(if editing { c5 } else { c3 }, "▐")))),
east(
when(!editing, east(fg_bg(c4, c3, label), fg_bg(c5, c3, "▐"),)),
east(fg_bg(tui_g(224), c5, value), fg_bg(c5, Reset, "▌"), ))))
}
}