reenable full/xy mod
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
facile pop culture reference 2026-08-08 23:37:06 +03:00
parent de591addb3
commit 8a6eb19e27
3 changed files with 88 additions and 70 deletions

View file

@ -1,28 +1,23 @@
use crate::*;
/// Use whole drawing area along one or both axes.
pub enum Full<T: Screen, I: Draw<T>> {
__(PhantomData<T>),
W(I),
H(I),
WH(I),
}
impl_draw!(<T: Screen, I: Draw<T>,>|self: Full<T, I>, to: T|{
let XYWH(x0, y0, w0, h0) = to.area();
let item = match self {
Self::W(i) => i, Self::H(i) => i, Self::WH(i) => i, _ => unreachable!()
};
let (x1, y1, w1, h1) = match self {
Self::W(..) => (Some(x0), None, Some(w0), None),
Self::H(..) => (None, Some(y0), None, Some(h0)),
Self::WH(..) => (Some(x0), Some(y0), Some(w0), Some(h0)),
_ => unreachable!()
};
Ok(to.draw(to.area(), item)?.map(|XYWH(x2, y2, w2, h2)|XYWH(
x1.unwrap_or(x2), y1.unwrap_or(y2), w1.unwrap_or(w2), h1.unwrap_or(h2),
)))
});
def_layout_modifier_flat!(
LayoutFull (full_w full_h full_wh),
Full { W H WH } kw_full "full" |self, to| {
let XYWH(x0, y0, w0, h0) = to.area();
let item = match self {
Self::W(i) => i, Self::H(i) => i, Self::WH(i) => i, _ => unreachable!()
};
let (x1, y1, w1, h1) = match self {
Self::W(..) => (Some(x0), None, Some(w0), None),
Self::H(..) => (None, Some(y0), None, Some(h0)),
Self::WH(..) => (Some(x0), Some(y0), Some(w0), Some(h0)),
_ => unreachable!()
};
Ok(to.draw(to.area(), item)?.map(|XYWH(x2, y2, w2, h2)|XYWH(
x1.unwrap_or(x2), y1.unwrap_or(y2), w1.unwrap_or(w2), h1.unwrap_or(h2),
)))
}
);
#[cfg(test)] #[test] fn test_layout_full () -> Usually<()> {
assert_eq!(check_layout("1")?, Some(XYWH(1u16, 1, 1, 1)));