From 7a0459756e419dee035eed9f1efc98523688ce43 Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Sat, 25 Jul 2026 07:13:21 +0300 Subject: [PATCH] draw: try to fix splits --- src/draw/split.rs | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/draw/split.rs b/src/draw/split.rs index 1cee49c..2ee67b4 100644 --- a/src/draw/split.rs +++ b/src/draw/split.rs @@ -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); - 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))?; + 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::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 + }) }) } @@ -89,8 +106,8 @@ impl Split { Self::East => (E, W), Self::North => (N, S), Self::West => (W, E), - Self::Above => (C, C), - Self::Below => (C, C), + Self::Above => (C, C), + Self::Below => (C, C), } }