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|{ thunk(move|to: &mut S|{
let (area_a, area_b) = to.xywh().split_half(self); let (area_a, area_b) = to.xywh().split_half(self);
let (origin_a, origin_b) = self.origins(); let (origin_a, origin_b) = self.origins();
let a = a.align(origin_a); let (a, b) = match self {
let b = b.align(origin_b); Self::Below => (
match self { to.show(area(area_b, b.align(origin_b)))?,
Self::Below => { to.show(area(area_b, a.align(origin_a)))?,
to.show(area(area_b, b))?; ),
to.show(area(area_b, a))?; _ => (
}, to.show(area(area_a, a.align(origin_a)))?,
_ => { to.show(area(area_b, b.align(origin_b)))?,
to.show(area(area_a, a))?; )
to.show(area(area_b, b))?; };
Ok(if let (Some(XYWH(xa, ya, wa, ha)), Some(XYWH(xb, yb, wb, hb))) = (a, b) {
match self {
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))),
} }
} } else if let Some(a) = a {
Ok(Some(to.xywh())) // FIXME: compute and return actually used area Some(a)
} else if let Some(b) = b {
Some(b)
} else {
None
})
}) })
} }
@ -89,8 +106,8 @@ impl Split {
Self::East => (E, W), Self::East => (E, W),
Self::North => (N, S), Self::North => (N, S),
Self::West => (W, E), Self::West => (W, E),
Self::Above => (C, C), Self::Above => (C, C),
Self::Below => (C, C), Self::Below => (C, C),
} }
} }