fix x/y/xy ops; remove button_2/3

This commit is contained in:
facile pop culture reference 2026-08-08 21:46:05 +03:00
parent 799e497622
commit de591addb3
7 changed files with 138 additions and 144 deletions

View file

@ -35,14 +35,23 @@ impl_draw!(<T: Screen, I: Draw<T>,>|self: Full<T, I>, to: T|{
def_layout_modifier!(
LayoutExact (exact_w exact_h exact_wh),
Exact { W H WH } kw_exact "exact" |self, to| {
let XYWH(x, y, w0, h0) = to.area();
let (item, w, h) = match self {
Self::W(item, w) => (item, (*w).into(), None),
Self::H(item, h) => (item, None, (*h).into()),
Self::WH(item, w, h) => (item, (*w).into(), (*h).into()),
_ => return Ok(None)
let XYWH(x0, y0, w0, h0) = to.area();
let (item, w1, h1) = match self {
Self::W(item, w1) => (item, (*w1).into(), None),
Self::H(item, h1) => (item, None, (*h1).into()),
Self::WH(item, w1, h1) => (item, (*w1).into(), (*h1).into()),
_ => unreachable!()
};
to.draw(XYWH(x, y, w.unwrap_or(w0), h.unwrap_or(h0)), item)
let w1 = w1.unwrap_or(w0);
let h1 = h1.unwrap_or(h0);
let area = XYWH(x0, y0, w1, h1);
let area = to.draw(area, item)?;
Ok(area.map(|XYWH(x2, y2, w2, h2)|match self {
Self::W(..) => XYWH(x0, y2, w1, h2),
Self::H(..) => XYWH(x2, y0, w2, h1),
Self::WH(..) => XYWH(x0, y0, w1, h1),
_ => unreachable!()
}))
}
);