From aa0dd37d88166052eef706eae6be5b649dbcca4b Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Wed, 15 Jul 2026 14:28:19 +0300 Subject: [PATCH] implement align for all azimuths --- src/draw/layout.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/draw/layout.rs b/src/draw/layout.rs index e70a449..0c892aa 100644 --- a/src/draw/layout.rs +++ b/src/draw/layout.rs @@ -290,24 +290,24 @@ pub struct Align(Option, T); impl_draw!(,>|self: Align, to: S|{ use Azimuth::*; let XYWH(x0, y0, w0, h0) = to.area(); - Ok(if let Some(XYWH(x, y, w, h)) = self.1.layout(to.area())? { + if let Some(XYWH(x, y, w, h)) = self.1.layout(to.area())? { to.clip(match self.0 { - Some(NW) => XYWH(x0, y0, w, h), - Some(N) => todo!(), - Some(NE) => todo!(), - Some(W) => todo!(), - Some(C) => todo!(), - Some(E) => todo!(), - Some(SW) => todo!(), - Some(S) => XYWH(x0 + w0.sub(w) / 2.into(), (y0 + h0).sub(h), w, h), - Some(SE) => todo!(), - Some(X) => todo!(), - Some(Y) => todo!(), - None => to.area() - }, |to|self.1.draw(to))? + Some(NW) => XYWH(x0, y0, w, h), + Some(N) => XYWH(x0 + w0.sub(w) / 2.into(), y0, w, h), + Some(NE) => XYWH((x0 + w0).sub(w), y0, w, h), + Some(W) => XYWH(x0, y0 + h0.sub(h) / 2.into(), w, h), + Some(C) => XYWH(x0 + w0.sub(w) / 2.into(), y0 + h0.sub(h) / 2.into(), w, h), + Some(E) => XYWH((x0 + w0).sub(w), y0 + h0.sub(h) / 2.into(), w, h), + Some(SW) => XYWH(x0, (y0 + h0).sub(h), w, h), + Some(S) => XYWH(x0 + w0.sub(w) / 2.into(), (y0 + h0).sub(h), w, h), + Some(SE) => XYWH((x0 + w0).sub(w), (y0 + h0).sub(h), w, h), + Some(X) => XYWH(x0 + w0.sub(w) / 2.into(), y, w, h), + Some(Y) => XYWH(x, y0 + h0.sub(h) / 2.into(), w, h), + None => to.area() + }, |to|self.1.draw(to)) } else { - None - }) + self.1.draw(to) + } }); /// Where is [0, 0] located?