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

16
layout/src/either.rs Normal file
View file

@ -0,0 +1,16 @@
use crate::*;
/// Show one item if a condition is true and another if the condition is false
pub struct Either<A, B>(pub bool, pub A, pub B);
impl<E: Output, A: Render<E>, B: Render<E>> Content<E> for Either<A, B> {
fn layout (&self, to: E::Area) -> E::Area {
let Self(cond, a, b) = self;
if *cond { a.layout(to) } else { b.layout(to) }
}
fn render (&self, to: &mut E) {
let Self(cond, a, b) = self;
if *cond { a.render(to) } else { b.render(to) }
}
}