use crate::*; pub enum Expand { X(U, A), Y(U, A), XY(U, U, A), } impl Expand { #[inline] pub const fn x (x: U, item: A) -> Self { Self::X(x, item) } #[inline] pub const fn y (y: U, item: A) -> Self { Self::Y(y, item) } #[inline] pub const fn xy (x: U, y: U, item: A) -> Self { Self::XY(x, y, item) } } impl + Layout> Content for Expand { fn content (&self) -> impl Draw + Layout + '_ { use Expand::*; match self { X(_, c) => c, Y(_, c) => c, XY(_, _, c) => c, } } } impl + Layout> Draw for Expand { fn draw (&self, to: &mut O) { to.place_at(self.layout(to.area()), &self.content()) } } impl Expand { #[inline] pub fn dx (&self) -> U { use Expand::*; match self { X(x, _) => *x, Y(_, _) => 0.into(), XY(x, _, _) => *x, } } #[inline] pub fn dy (&self) -> U { use Expand::*; match self { X(_, _) => 0.into(), Y(y, _) => *y, XY(_, y, _) => *y, } } } impl> Layout for Expand { fn layout (&self, to: O::Area) -> O::Area { [to.x(), to.y(), to.w().plus(self.dx()), to.h().plus(self.dy())].into() } }