phocking wip (weep)

This commit is contained in:
i do not exist 2026-06-16 14:23:29 +03:00
parent 89df3cf191
commit 790e33b40c
3 changed files with 92 additions and 86 deletions

View file

@ -426,14 +426,14 @@ 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(move|to: &mut Tui|to.place(&w_exact(9, either(playing,
thunk(move|to: &mut Tui|w_exact(9, either(playing,
fg(Rgb(0, 255, 0), " PLAYING "),
fg(Rgb(255, 128, 0), " STOPPED ")))
)),
thunk(move|to: &mut Tui|to.place(&w_exact(5, either(playing,
fg(Rgb(255, 128, 0), " STOPPED "))
).draw(to)),
thunk(move|to: &mut Tui|w_exact(5, either(playing,
fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
))
fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",)))
).draw(to)),
)
)
}
@ -494,34 +494,36 @@ pub fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<
when(sample.is_some(), thunk(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&east!(
east!(
field_h(theme, "Name", format!("{:<10}", sample.name.clone())),
field_h(theme, "Length", format!("{:<8}", sample.channels[0].len())),
field_h(theme, "Start", format!("{:<8}", sample.start)),
field_h(theme, "End", format!("{:<8}", sample.end)),
field_h(theme, "Trans", "0"),
field_h(theme, "Gain", format!("{}", sample.gain)),
))
).draw(to)
}))
}
pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_> {
either(sample.is_some(), thunk(move|to: &mut Tui|{
let a = thunk(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&w_exact(20, south!(
w_exact(20, south!(
w_full(origin_w(field_h(theme, "Name ", format!("{:<10}", sample.name.clone())))),
w_full(origin_w(field_h(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
w_full(origin_w(field_h(theme, "Start ", format!("{:<8}", sample.start)))),
w_full(origin_w(field_h(theme, "End ", format!("{:<8}", sample.end)))),
w_full(origin_w(field_h(theme, "Trans ", "0"))),
w_full(origin_w(field_h(theme, "Gain ", format!("{}", sample.gain)))),
)))
}), thunk(|to: &mut Tui|to.place(&fg(Red, south!(
)).draw(to)
});
let b = thunk(|to: &mut Tui|fg(Red, south!(
bold(true, "× No sample."),
"[r] record",
"[Shift-F9] import",
)))))
)));
either(sample.is_some(), a, b)
}
pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
@ -726,47 +728,47 @@ impl<'a> Namespace<'a, AppCommand> for App {
"cancel" => AppCommand::Cancel,
});
}
impl Understand<Tui, ()> for App {
fn understand_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_understand_expr(self, to, lang)
impl Interpret<Tui, ()> for App {
fn interpret_expr <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_interpret_expr(self, to, lang)
}
fn understand_word <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_understand_word(self, to, lang)
fn interpret_word <'a> (&'a self, to: &mut Tui, lang: &'a impl Expression) -> Usually<()> {
app_interpret_word(self, to, lang)
}
}
fn app_understand_expr (state: &App, to: &mut Tui, lang: &impl Expression) -> Usually<()> {
fn app_interpret_expr (state: &App, to: &mut Tui, lang: &impl Expression) -> Usually<()> {
if eval_view(state, to, lang)? || eval_view_tui(state, to, lang)? {
Ok(())
} else {
Err(format!("App::understand_expr: unexpected: {lang:?}").into())
Err(format!("App::interpret_expr: unexpected: {lang:?}").into())
}
}
fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usually<()> {
fn app_interpret_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usually<()> {
let mut frags = dsl.src()?.unwrap().split("/");
match frags.next() {
Some(":logo") => to.place(&view_logo()),
Some(":status") => to.place(&h_exact(1, "TODO: Status Bar")),
Some(":logo") => view_logo().draw(to),
Some(":status") => h_exact(1, "TODO: Status Bar").draw(to),
Some(":meters") => match frags.next() {
Some("input") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters")))),
Some("output") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters")))),
Some("input") => bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters"))).draw(to),
Some("output") => bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters"))).draw(to),
_ => panic!()
},
Some(":tracks") => match frags.next() {
None => to.place(&"TODO tracks"),
Some("names") => to.place(&state.project.view_track_names(state.color.clone())),//bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs")))),
Some("devices") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices")))),
Some("outputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs")))),
None => "TODO tracks".draw(to),
Some("names") => state.project.view_track_names(state.color.clone()).draw(to),//bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs"))).draw(to),
Some("devices") => bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices"))).draw(to),
Some("outputs") => bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs"))).draw(to),
_ => panic!()
},
Some(":scenes") => match frags.next() {
None => to.place(&"TODO scenes"),
Some(":scenes/names") => to.place(&"TODO Scene Names"),
None => "TODO scenes".draw(to),
Some(":scenes/names") => "TODO Scene Names".draw(to),
_ => panic!()
},
Some(":editor") => to.place(&"TODO Editor"),
Some(":editor") => "TODO Editor".draw(to),
Some(":dialog") => match frags.next() {
Some("menu") => to.place(&if let Dialog::Menu(selected, items) = &state.dialog {
Some("menu") => if let Dialog::Menu(selected, items) = &state.dialog {
let items = items.clone();
let selected = selected;
Some(wh_full(thunk(move|to: &mut Tui|{
@ -781,10 +783,10 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
})))
} else {
None
}),
_ => unimplemented!("App::understand_word: {dsl:?} ({frags:?})"),
}.draw(to),
_ => unimplemented!("App::interpret_word: {dsl:?} ({frags:?})"),
},
Some(":templates") => to.place(&{
Some(":templates") => {
let modes = state.config.modes.clone();
let height = (modes.read().unwrap().len() * 2) as u16;
h_exact(height, w_min(30, thunk(move |to: &mut Tui|{
@ -797,21 +799,21 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
let field_name = w_full(origin_w(fg(fg1, name)));
let field_id = w_full(origin_e(fg(fg2, id)));
let field_info = w_full(origin_w(info));
to.place(&y_push((2 * index) as u16,
y_push((2 * index) as u16,
h_exact(2, w_full(bg(bg, south(
above(field_name, field_id), field_info))))));
above(field_name, field_id), field_info))))).draw(to);
}
})))
}),
Some(":sessions") => to.place(&h_exact(6, w_min(30, thunk(|to: &mut Tui|{
}.draw(to),
Some(":sessions") => 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) };
to.place(&y_push((2 * index) as u16,
&h_exact(2, w_full(bg(bg, origin_w(fg(fg, name)))))));
y_push((2 * index) as u16,
&h_exact(2, w_full(bg(bg, origin_w(fg(fg, name)))))).draw(to);
}
})))),
Some(":browse/title") => to.place(&w_full(origin_w(field_v(ItemColor::default(),
}))).draw(to),
Some(":browse/title") => w_full(origin_w(field_v(ItemColor::default(),
match state.dialog.browser_target().unwrap() {
BrowseTarget::SaveProject => "Save project:",
BrowseTarget::LoadProject => "Load project:",
@ -819,24 +821,24 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
BrowseTarget::ExportSample(_) => "Export sample:",
BrowseTarget::ImportClip(_) => "Import clip:",
BrowseTarget::ExportClip(_) => "Export clip:",
}, w_shrink(3, h_exact(1, fg(g(96), x_repeat("🭻")))))))),
}, w_shrink(3, h_exact(1, fg(g(96), x_repeat("🭻"))))))).draw(to),
Some(":device") => {
let selected = state.dialog.device_kind().unwrap();
to.place(&south(bold(true, "Add device"), iter_south(
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) };
let lb = if i == selected { "[ " } else { " " };
let rb = if i == selected { " ]" } else { " " };
w_full(bg(bg, east(lb, west(rb, "FIXME device name")))) })))
w_full(bg(bg, east(lb, west(rb, "FIXME device name")))) })).draw(to)
},
Some(":debug") => to.place(&h_exact(1, format!("[{:?}]", to.area()))),
Some(":debug") => h_exact(1, format!("[{:?}]", to.area())).draw(to),
Some(_) => {
let views = state.config.views.read().unwrap();
if let Some(dsl) = views.get(dsl.src()?.unwrap()) {
let dsl = dsl.clone();
std::mem::drop(views);
state.understand(to, &dsl)?
state.interpret(to, &dsl)?
} else {
unimplemented!("{dsl:?}");
}
@ -968,10 +970,10 @@ 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().into(), e.as_ref());
to.show(to.area().into(), e.as_ref());
}
for (index, dsl) in self.mode.view.iter().enumerate() {
if let Err(e) = self.understand(to, dsl) {
if let Err(e) = self.interpret(to, dsl) {
*self.error.write().unwrap() = Some(format!("view #{index}: {e}").into());
break;
}
@ -986,8 +988,8 @@ 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_h <T: Screen> (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> {
fn field_v <T: Screen> (theme: ItemTheme, head: impl Draw<T>, body: impl Draw<T>) -> impl Draw<T> {
}