use crate::*; /// Use whole drawing area along one or both axes. /// /// ``` /// # fn doctest_layout_full () -> Result<(), Box> { /// use tengri::{Layout, Draw, XYWH}; /// let area = XYWH(0u16, 0, 80, 25); /// assert_eq!("1".layout(area)?, Some(XYWH(0u16, 0, 1, 1))); /// assert_eq!("1".full_w().layout(area)?, Some(XYWH(0u16, 0, 80, 1))); /// assert_eq!("1".full_h().layout(area)?, Some(XYWH(0u16, 0, 1, 25))); /// assert_eq!("1".full_wh().layout(area)?, Some(XYWH(0u16, 0, 80, 25))); /// # Ok(()) } /// ``` pub enum Full> { __(PhantomData), W(I), H(I), WH(I), } impl_draw!(,>|self: Full, to: T|{ let XYWH(x0, y0, w0, h0) = to.area(); match self { Self::W(item) => if let Some(XYWH(_, y, _, h)) = item.layout(to.area())? { to.clip(XYWH(x0, y, w0, h), |to|item.draw(to)) } else { Ok(None) }, Self::H(item) => if let Some(XYWH(x, _, w, _)) = item.layout(to.area())? { to.clip(XYWH(x, y0, w, h0), |to|item.draw(to)) } else { Ok(None) }, Self::WH(item) => if let Some(XYWH(..)) = item.layout(to.area())? { to.clip(XYWH(x0, y0, w0, h0), |to|item.draw(to)) } else { Ok(None) }, _ => unreachable!(), } });