mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 15:16:41 +01:00
semblance of groovebox launches from edn layout!
This commit is contained in:
parent
a702170d16
commit
7b3de1e68d
7 changed files with 209 additions and 152 deletions
23
layout/src/when.rs
Normal file
23
layout/src/when.rs
Normal 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) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue