From d10107684d619ce64b86e4e981b0895f4b34f493 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sun, 24 Aug 2025 03:22:06 +0300 Subject: [PATCH] init stub arranger --- crates/app/app_data.rs | 3 ++- crates/app/app_view.rs | 35 ++++++++++++++++++++--------------- crates/config/config.rs | 8 ++++---- deps/tengri | 2 +- tek.edn | 16 ++++++++++------ 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/crates/app/app_data.rs b/crates/app/app_data.rs index cfb8feb3..2b27fbb8 100644 --- a/crates/app/app_data.rs +++ b/crates/app/app_data.rs @@ -10,7 +10,8 @@ impl<'t> DslNs<'t, Arc> for App { impl<'t> DslNs<'t, bool> for App { dsl_words!(|app| -> bool { - ":focused/editor" => app.project.editor.is_some(), + ":mode/editor" => app.project.editor.is_some(), + ":focused/dialog" => !matches!(app.dialog, Dialog::None), ":focused/message" => matches!(app.dialog, Dialog::Message(..)), ":focused/add_device" => matches!(app.dialog, Dialog::Device(..)), diff --git a/crates/app/app_view.rs b/crates/app/app_view.rs index ff11b2fb..ebf1db9b 100644 --- a/crates/app/app_view.rs +++ b/crates/app/app_view.rs @@ -49,6 +49,9 @@ impl<'t> DslNs<'t, Box>> for App { "bg" (color: Color, x: Box>) => Box::new(Tui::bg(color, x)), "fg/bg" (fg: Color, bg: Color, x: Box>) => Box::new(Tui::fg_bg(fg, bg, x)), + "either" (cond: bool, a: Box>, b: Box>) => + Box::new(Either(cond, a, b)), + "bsp/n" (a: Box>, b: Box>) => Box::new(Bsp::n(a, b)), "bsp/s" (a: Box>, b: Box>) => Box::new(Bsp::s(a, b)), "bsp/e" (a: Box>, b: Box>) => Box::new(Bsp::e(a, b)), @@ -83,6 +86,23 @@ impl<'t> DslNs<'t, Box>> for App { "max/xy" (x: u16, y: u16, c: Box>) => Box::new(Max::xy(x, y, c)), }); dsl_words!(|app| -> Box> { + ":logo" => Box::new(Fixed::xy(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), Stack::south(|add|{ + add(&Fixed::y(1, "")); + add(&Fixed::y(1, "")); + add(&Fixed::y(1, "~~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~~~~~~~~~")); + add(&Fixed::y(1, Bsp::e("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", Bsp::e(Tui::fg(Rgb(230,100,40), "v0.3.0"), " ~~")))); + add(&Fixed::y(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~")); + }))))), + ":meters/input" => Box::new("Input Meters"), + ":meters/output" => Box::new("Output Meters"), + ":status" => Box::new("Status Bar"), + ":tracks/names" => Box::new("Track Names"), + ":tracks/inputs" => Box::new("Track Inputs"), + ":tracks/devices" => Box::new("Track Devices"), + ":tracks/outputs" => Box::new("Track Outputs"), + ":scenes/names" => Box::new("Scene Names"), + ":editor" => Box::new("Editor"), + ":scenes" => Box::new("Editor"), ":dialog/menu" => Box::new(if let Dialog::Menu(selected, items) = &app.dialog { let items = items.clone(); let selected = *selected; @@ -98,13 +118,6 @@ impl<'t> DslNs<'t, Box>> for App { } else { None }), - ":logo" => Box::new(Fixed::xy(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), Stack::south(|add|{ - add(&Fixed::y(1, "")); - add(&Fixed::y(1, "")); - add(&Fixed::y(1, "~~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~~~~~~~~~")); - add(&Fixed::y(1, Bsp::e("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", Bsp::e(Tui::fg(Rgb(230,100,40), "v0.3.0"), " ~~")))); - add(&Fixed::y(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~")); - }))))), ":templates" => Box::new({ let modes = app.config.modes.clone(); let height = (modes.read().unwrap().len() * 2) as u16; @@ -225,14 +238,6 @@ pub fn view_nil (_: &App) -> Box> { ////.enclose(Fill::xy(browser))) //}, // - //pub fn view_meters_input (&self) -> impl Content + use<'_> { - //self.project.sampler().map(|s| - //s.view_meters_input()) - //} - //pub fn view_meters_output (&self) -> impl Content + use<'_> { - //self.project.sampler().map(|s| - //s.view_meters_output()) - //} //pub fn view_history (&self) -> impl Content { //Fixed::y(1, Fill::x(Align::w(FieldH(self.color, //format!("History ({})", self.history.len()), diff --git a/crates/config/config.rs b/crates/config/config.rs index d48482bb..3b23f99d 100644 --- a/crates/config/config.rs +++ b/crates/config/config.rs @@ -125,10 +125,10 @@ impl Mode> { Ok(()) } pub fn load_one (&mut self, dsl: impl Dsl) -> Usually<()> { - Ok(if let Ok(Some(expr)) = dsl.expr() && let Ok(Some(key)) = expr.head() { - println!("Mode::load_one: {key} {:?}", expr.tail()?); + Ok(if let Ok(Some(expr)) = dsl.expr() && let Ok(Some(head)) = expr.head() { + println!("Mode::load_one: {head} {:?}", expr.tail()); let tail = expr.tail()?.map(|x|x.trim()).unwrap_or(""); - match key { + match head { "name" => self.name.push(tail.into()), "info" => self.info.push(tail.into()), "view" => self.view.push(tail.into()), @@ -139,7 +139,7 @@ impl Mode> { return Err(format!("Mode::load_one: self: incomplete: {expr:?}").into()); }, _ => { - return Err(format!("Mode::load_one: unexpected expr: {key:?} {tail:?}").into()) + return Err(format!("Mode::load_one: unexpected expr: {head:?} {tail:?}").into()) }, }; } else if let Ok(Some(word)) = dsl.word() { diff --git a/deps/tengri b/deps/tengri index 446ec7a7..d9081087 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit 446ec7a71477e1b9ca117b7a23759d6318eb2cf0 +Subproject commit d9081087ecc41ad8514c17614daab4f34d3e876d diff --git a/tek.edn b/tek.edn index e943d2d6..63466c6f 100644 --- a/tek.edn +++ b/tek.edn @@ -14,7 +14,7 @@ (view :menu (bg (g 40) (bsp/s :ports/out (bsp/n :ports/in (bg (g 30) (bsp/s (fixed/y 7 :logo) (fill/xy :dialog/menu))))))) (view :ports/out (fill/x (fixed/y 3 (bsp/a (fill/x (align/w (text L-AUDIO-OUT))) - (bsp/a (text MIDI-OUT) (fill/x (align/e (text AUDIO-OUT R)))))))) + (bsp/a (text MIDI-OUT) (fill/x (align/e (text AUDIO-OUT-R)))))))) (view :ports/in (fill/x (fixed/y 3 (bsp/a (fill/x (align/w (text L-AUDIO-IN))) (bsp/a (text MIDI-IN) (fill/x (align/e (text AUDIO-IN-R)))))))) (view :browse (bsp/s (padding/xy 3 1 :browse-title) (enclose (fg (g 96)) browser))) @@ -55,12 +55,16 @@ (mode :scene (keys :scene)) (mode :mix (keys :mix)) (keys :clock :arranger :global) - (view :arranger)) + :arranger) -(view :arranger (bsp/w :meters/output (bsp/e :meters/input (stack/n - (fixed/y 2 :status/h2) :tracks/inputs (stack/s - :tracks/devices :tracks/outputs :tracks/names - (fill/xy (either :mode/editor (bsp/e :scenes/names :editor) :scenes))))))) +(view :arranger (bsp/w :meters/output (bsp/e :meters/input + (bsp/n (fixed/y 2 :status) (bsp/n :tracks/inputs + (bsp/s :tracks/devices (bsp/s :tracks/outputs (bsp/s :tracks/names + (fill/xy (either :mode/editor (bsp/e :scenes/names :editor) :scenes)))))))))) +(view :arranger (bsp/w :meters/output (bsp/e :meters/input + (bsp/n (fixed/y 2 :status) (bsp/n :tracks/inputs + (bsp/s :tracks/devices (bsp/s :tracks/outputs (bsp/s :tracks/names + (fill/xy (either :mode/editor (bsp/e :scenes/names :editor) :scenes)))))))))) (keys :arranger (see :color :launch :scenes :tracks) (@tab project/edit) (@enter project/edit)