semblance of groovebox launches from edn layout!

This commit is contained in:
🪞👃🪞 2025-01-05 23:28:04 +01:00
parent a702170d16
commit 7b3de1e68d
7 changed files with 209 additions and 152 deletions

View file

@ -41,16 +41,29 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
fn content (&self) -> impl Render<E> {
use EdnItem::*;
match self {
Self::Ok(state, layout) => match layout {
Self::Ok(s, layout) => match layout {
Nil => ().boxed(),
Sym(t) => state.get_content(Sym(t.as_str())).boxed(),
Sym(t) => s.get_content(Sym(t.as_str())).boxed(),
Key(t) => panic!("todo: add error handling to content() chain. unexpected key {t}"),
Num(n) => panic!("todo: add error handling to content() chain. unexpected num {n}"),
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
let head = &head.to_ref();
match (head, tail) {
(Key("when"), [c, a]) => When(state.get_bool(c.to_ref()), state.get_content(a.to_ref())).boxed(),
(Key("bsp/s"), [a, b]) => Bsp::s(state.get_content(a.to_ref()), state.get_content(b.to_ref()),).boxed(),
(Key("align/e"), [a]) => Align::e(s.get_content(a.to_ref())).boxed(),
(Key("align/w"), [a]) => Align::w(s.get_content(a.to_ref())).boxed(),
(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/n"), [a, b]) => Bsp::n(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("bsp/e"), [a, b]) => Bsp::e(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
(Key("fill/x"), [a]) => Fill::x(s.get_content(a.to_ref())).boxed(),
(Key("fill/xy"), [a]) => Fill::xy(s.get_content(a.to_ref())).boxed(),
(Key("fixed/x"), [x, a]) => Fixed::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("fixed/y"), [y, a]) => Fixed::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("push/y"), [y, a]) => Push::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("max/y"), [y, a]) => Max::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
(Key("lay"), args) => Map(||args.iter(), |a, _|s.get_content(a.to_ref())).boxed(),
(Key("row"), args) => Map(||args.iter(), |a, _|s.get_content(a.to_ref())).boxed(),
(Key("when"), [c, a]) => When(s.get_bool(c.to_ref()), s.get_content(a.to_ref())).boxed(),
_ => todo!("{:?} {:?}", &head, &tail)
}
} else {