draw: try to fix splits

This commit is contained in:
facile pop culture reference 2026-07-25 07:13:21 +03:00
parent e398541b7e
commit 7a0459756e

View file

@ -50,19 +50,36 @@ impl Split {
thunk(move|to: &mut S|{
let (area_a, area_b) = to.xywh().split_half(self);
let (origin_a, origin_b) = self.origins();
let a = a.align(origin_a);
let b = b.align(origin_b);
let (a, b) = match self {
Self::Below => (
to.show(area(area_b, b.align(origin_b)))?,
to.show(area(area_b, a.align(origin_a)))?,
),
_ => (
to.show(area(area_a, a.align(origin_a)))?,
to.show(area(area_b, b.align(origin_b)))?,
)
};
Ok(if let (Some(XYWH(xa, ya, wa, ha)), Some(XYWH(xb, yb, wb, hb))) = (a, b) {
match self {
Self::Below => {
to.show(area(area_b, b))?;
to.show(area(area_b, a))?;
},
_ => {
to.show(area(area_a, a))?;
to.show(area(area_b, b))?;
Self::South =>
Some(XYWH(xa.min(xb), ya, wa.max(wb), ha + hb)),
Self::East =>
Some(XYWH(xa, ya.min(yb), wa + wb, ha.max(hb))),
Self::North =>
Some(XYWH(xa.min(xb), yb, wa.max(wb), ha + hb)),
Self::West =>
Some(XYWH(xb, ya.min(yb), wa + wb, ha.max(hb))),
Self::Above | Self::Below =>
Some(XYWH(xa.min(xb), ya.min(yb), wa.max(wb), ha.max(hb))),
}
}
Ok(Some(to.xywh())) // FIXME: compute and return actually used area
} else if let Some(a) = a {
Some(a)
} else if let Some(b) = b {
Some(b)
} else {
None
})
})
}