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

23
layout/src/when.rs Normal file
View file

@ -0,0 +1,23 @@
use crate::*;
/// Show an item only when a condition is true.
pub struct When<A>(pub bool, pub A);
impl<E: Output, A: Render<E>> Content<E> for When<A> {
fn layout (&self, to: E::Area) -> E::Area {
let Self(cond, item) = self;
let mut area = E::Area::zero();
if *cond {
let item_area = item.layout(to);
area[0] = item_area.x();
area[1] = item_area.y();
area[2] = item_area.w();
area[3] = item_area.h();
}
area.into()
}
fn render (&self, to: &mut E) {
let Self(cond, item) = self;
if *cond { item.render(to) }
}
}