use crate::*; /// Only draw content if area is above a certain size. /// /// ``` /// # fn doctest_layout_min () -> Result<(), Box> { /// use tengri::{Layout, Draw, XYWH}; /// let area = XYWH(1u16, 1, 80, 25); /// assert_eq!("1".min_w(5).layout(area)?, Some(XYWH(1u16, 1, 5, 1))); /// assert_eq!("1".min_h(5).layout(area)?, Some(XYWH(1u16, 1, 1, 5))); /// assert_eq!("1".min_wh(5, 5).layout(area)?, Some(XYWH(1u16, 1, 5, 5))); /// assert_eq!("123456".min_w(5).layout(area)?, Some(XYWH(1u16, 1, 6, 1))); /// # Ok(()) } /// ``` pub enum Min, X: Into>> { __(PhantomData), W(I, X), H(I, X), WH(I, X, X), } impl_draw!(, X: Into>,>|self: Min, to: T|{ match self { Self::__(_) => unreachable!(), Self::W(item, w1) if let Some(XYWH(x, y, w, h)) = item.layout(to.area())? => { let w = w1.into().map(|w1|w.max(w1)).unwrap_or(w); to.clip(XYWH(x, y, w, h), item) }, Self::H(item, h1) if let Some(XYWH(x, y, w, h)) = item.layout(to.area())? => { let h = h1.into().map(|h1|h.max(h1)).unwrap_or(h); to.clip(XYWH(x, y, w, h), item) }, Self::WH(item, w1, h1) if let Some(XYWH(x, y, w, h)) = item.layout(to.area())? => { let w = w1.into().map(|w1|w.max(w1)).unwrap_or(w); let h = h1.into().map(|h1|h.max(h1)).unwrap_or(h); to.clip(XYWH(x, y, w, h), item) }, _ => Ok(None) } });