use crate::*; /// Show an item only when a condition is true. pub struct When(pub bool, pub A); impl> Content for When { 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) } } }