implement align for all azimuths
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
facile pop culture reference 2026-07-15 14:28:19 +03:00
parent 482b624169
commit aa0dd37d88

View file

@ -290,24 +290,24 @@ pub struct Align<T>(Option<Azimuth>, T);
impl_draw!(<S: Screen, T: Draw<S>,>|self: Align<T>, to: S|{ impl_draw!(<S: Screen, T: Draw<S>,>|self: Align<T>, to: S|{
use Azimuth::*; use Azimuth::*;
let XYWH(x0, y0, w0, h0) = to.area(); 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 { to.clip(match self.0 {
Some(NW) => XYWH(x0, y0, w, h), Some(NW) => XYWH(x0, y0, w, h),
Some(N) => todo!(), Some(N) => XYWH(x0 + w0.sub(w) / 2.into(), y0, w, h),
Some(NE) => todo!(), Some(NE) => XYWH((x0 + w0).sub(w), y0, w, h),
Some(W) => todo!(), Some(W) => XYWH(x0, y0 + h0.sub(h) / 2.into(), w, h),
Some(C) => todo!(), Some(C) => XYWH(x0 + w0.sub(w) / 2.into(), y0 + h0.sub(h) / 2.into(), w, h),
Some(E) => todo!(), Some(E) => XYWH((x0 + w0).sub(w), y0 + h0.sub(h) / 2.into(), w, h),
Some(SW) => todo!(), 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(S) => XYWH(x0 + w0.sub(w) / 2.into(), (y0 + h0).sub(h), w, h),
Some(SE) => todo!(), Some(SE) => XYWH((x0 + w0).sub(w), (y0 + h0).sub(h), w, h),
Some(X) => todo!(), Some(X) => XYWH(x0 + w0.sub(w) / 2.into(), y, w, h),
Some(Y) => todo!(), Some(Y) => XYWH(x, y0 + h0.sub(h) / 2.into(), w, h),
None => to.area() None => to.area()
}, |to|self.1.draw(to))? }, |to|self.1.draw(to))
} else { } else {
None self.1.draw(to)
}) }
}); });
/// Where is [0, 0] located? /// Where is [0, 0] located?