This commit is contained in:
i do not exist 2026-04-17 04:18:25 +03:00
parent 5ffa9472e1
commit 89df3cf191
7 changed files with 164 additions and 95 deletions

View file

@ -426,11 +426,11 @@ pub fn button_play_pause (playing: bool) -> impl Draw<Tui> {
let compact = true;//self.is_editing();
bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
either(compact,
Thunk::new(move|to: &mut Tui|to.place(&w_exact(9, either(playing,
thunk(move|to: &mut Tui|to.place(&w_exact(9, either(playing,
fg(Rgb(0, 255, 0), " PLAYING "),
fg(Rgb(255, 128, 0), " STOPPED ")))
)),
Thunk::new(move|to: &mut Tui|to.place(&w_exact(5, either(playing,
thunk(move|to: &mut Tui|to.place(&w_exact(5, either(playing,
fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
))
@ -466,19 +466,19 @@ pub fn view_wrap (bg: Color, fg: Color, content: impl Draw<Tui>) -> impl Draw<Tu
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Draw<Tui> + 'a {
south!(
field_h(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
wh_exact(if value >= 0.0 { 13 }
else if value >= -1.0 { 12 }
else if value >= -2.0 { 11 }
else if value >= -3.0 { 10 }
else if value >= -4.0 { 9 }
else if value >= -6.0 { 8 }
else if value >= -9.0 { 7 }
else if value >= -12.0 { 6 }
else if value >= -15.0 { 5 }
else if value >= -20.0 { 4 }
else if value >= -25.0 { 3 }
else if value >= -30.0 { 2 }
else if value >= -40.0 { 1 }
wh_exact(if value >= 0.0 { &"13" }
else if value >= -1.0 { &"12" }
else if value >= -2.0 { &"11" }
else if value >= -3.0 { &"10" }
else if value >= -4.0 { &"9" }
else if value >= -6.0 { &"8" }
else if value >= -9.0 { &"7" }
else if value >= -12.0 { &"6" }
else if value >= -15.0 { &"5" }
else if value >= -20.0 { &"4" }
else if value >= -25.0 { &"3" }
else if value >= -30.0 { &"2" }
else if value >= -40.0 { &"1" }
else { 0 }, 1, bg(if value >= 0.0 { Red }
else if value >= -3.0 { Yellow }
else { Green }, ())))
@ -491,7 +491,7 @@ pub fn view_meters (values: &[f32;2]) -> impl Draw<Tui> + use<'_> {
}
pub fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_> {
when(sample.is_some(), Thunk::new(move|to: &mut Tui|{
when(sample.is_some(), thunk(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&east!(
@ -506,7 +506,7 @@ pub fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<
}
pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_> {
either(sample.is_some(), Thunk::new(move|to: &mut Tui|{
either(sample.is_some(), thunk(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&w_exact(20, south!(
@ -517,7 +517,7 @@ pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + us
w_full(origin_w(field_h(theme, "Trans ", "0"))),
w_full(origin_w(field_h(theme, "Gain ", format!("{}", sample.gain)))),
)))
}), Thunk::new(|to: &mut Tui|to.place(&fg(Red, south!(
}), thunk(|to: &mut Tui|to.place(&fg(Red, south!(
bold(true, "× No sample."),
"[r] record",
"[Shift-F9] import",
@ -543,9 +543,9 @@ pub fn view_ports_status <'a, T: JackPort> (theme: ItemTheme, title: &'a str, po
let ins = ports.len() as u16;
let frame = Outer(true, Style::default().fg(g(96)));
let iter = move||ports.iter();
let names = iter_south(1, iter, move|port, index|h_full(origin_w(format!(" {index} {}", port.port_name()))));
let names = iter_south(iter, move|port, index|h_full(origin_w(format!(" {index} {}", port.port_name()))));
let field = field_v(theme, title, names);
wh_exact(20, 1 + ins, frame.enclose(wh_exact(20, 1 + ins, field)))
wh_exact(Some(20), Some(1 + ins), frame.enclose(wh_exact(Some(20), Some(1 + ins), field)))
}
pub fn io_ports <'a, T: PortsSizes<'a>> (
@ -554,11 +554,22 @@ pub fn io_ports <'a, T: PortsSizes<'a>> (
iter(items, move|(
_index, name, connections, y, y2
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
iter_south(y as u16, (y2-y) as u16, south(
h_full(bold(true, fg_bg(fg, bg, origin_w(east(&" 󰣲 ", name))))),
iter(||connections.iter(), move|connect: &'a Connect, index|iter_south(index as u16, 1,
h_full(origin_w(bold(false, fg_bg(fg, bg,
&connect.info)))))))))
iter_south(
y as u16,
(y2-y) as u16,
south(
h_full(bold(true, fg_bg(fg, bg, origin_w(east(" 󰣲 ", name))))),
iter(
||connections.iter(),
move|connect: &'a Connect, index|iter_south(
index as u16,
1,
h_full(origin_w(bold(false, fg_bg(fg, bg, &connect.info))))
)
)
)
)
)
}
/// CLI banner.
@ -758,7 +769,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some("menu") => to.place(&if let Dialog::Menu(selected, items) = &state.dialog {
let items = items.clone();
let selected = selected;
Some(wh_full(Thunk::new(move|to: &mut Tui|{
Some(wh_full(thunk(move|to: &mut Tui|{
for (index, MenuItem(item, _)) in items.0.iter().enumerate() {
to.place(&y_push((2 * index) as u16,
fg_bg(
@ -776,7 +787,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some(":templates") => to.place(&{
let modes = state.config.modes.clone();
let height = (modes.read().unwrap().len() * 2) as u16;
h_exact(height, w_min(30, Thunk::new(move |to: &mut Tui|{
h_exact(height, w_min(30, thunk(move |to: &mut Tui|{
for (index, (id, profile)) in modes.read().unwrap().iter().enumerate() {
let bg = if index == 0 { Rgb(70,70,70) } else { Rgb(50,50,50) };
let name = profile.name.get(0).map(|x|x.as_ref()).unwrap_or("<no name>");
@ -792,7 +803,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
}
})))
}),
Some(":sessions") => to.place(&h_exact(6, w_min(30, Thunk::new(|to: &mut Tui|{
Some(":sessions") => to.place(&h_exact(6, w_min(30, thunk(|to: &mut Tui|{
let fg = Rgb(224, 192, 128);
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
let bg = if index == 0 { Rgb(50,50,50) } else { Rgb(40,40,40) };
@ -811,7 +822,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
}, w_shrink(3, h_exact(1, fg(g(96), x_repeat("🭻")))))))),
Some(":device") => {
let selected = state.dialog.device_kind().unwrap();
to.place(&south(bold(true, "Add device"), iter_south(1,
to.place(&south(bold(true, "Add device"), iter_south(
move||device_kinds().iter(),
move|_label: &&'static str, i|{
let bg = if i == selected { Rgb(64,128,32) } else { Rgb(0,0,0) };
@ -957,7 +968,7 @@ impl App {
impl Draw<Tui> for App {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
if let Some(e) = self.error.read().unwrap().as_ref() {
to.place_at(to.area(), e);
to.place_at(to.area().into(), e.as_ref());
}
for (index, dsl) in self.mode.view.iter().enumerate() {
if let Err(e) = self.understand(to, dsl) {
@ -974,3 +985,9 @@ primitive!(u8: try_to_u8);
primitive!(u16: try_to_u16);
primitive!(usize: try_to_usize);
primitive!(isize: try_to_isize);
fn field_h <T> (theme: ItemTheme, head: impl Draw<T>, body: impl Draw<T>) -> impl Draw<T> {
}
fn field_v <T> (theme: ItemTheme, head: impl Draw<T>, body: impl Draw<T>) -> impl Draw<T> {
}