refactor(layout): prefix methods (13 errors)

This commit is contained in:
same mf who else 2026-02-15 06:18:09 +02:00
parent d5976cae8e
commit b7b1055fbc
3 changed files with 125 additions and 108 deletions

View file

@ -117,8 +117,8 @@ macro_rules! layout_op_xy (
macro_rules! push_pull(($T:ident: $method: ident)=>{
layout_op_xy!(1: $T);
impl<O: Out, T: Layout<O>> Layout<O> for $T<O::Unit, T> {
fn x (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().$method(self.dx()) }
fn y (&self, area: XYWH<O::Unit>) -> O::Unit { area.y().$method(self.dy()) }
fn layout_x (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().$method(self.dx()) }
fn layout_y (&self, area: XYWH<O::Unit>) -> O::Unit { area.y().$method(self.dy()) }
}
});

View file

@ -255,90 +255,89 @@ impl<O: Out> From<[O::Unit; 2]> for Measure<O> {
}
impl<O: Out> Layout<O> for () {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { a.x() }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { a.y() }
fn w (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn w_min (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn w_max (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn h (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn h_min (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn h_max (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { a.x() }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { a.y() }
fn layout_w (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_w_min (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_w_max (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_h (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_h_min (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_h_max (&self, _: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { XYWH(a.x(), a.y(), 0.into(), 0.into()) }
}
impl<O: Out, L: Layout<O>> Layout<O> for &L {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).x(a) }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).y(a) }
fn w (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).w(a) }
fn w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).w_min(a) }
fn w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).w_max(a) }
fn h (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).h(a) }
fn h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).h_min(a) }
fn h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).h_max(a) }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_x(a) }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_y(a) }
fn layout_w (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_w(a) }
fn layout_w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_w_min(a) }
fn layout_w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_w_max(a) }
fn layout_h (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_h(a) }
fn layout_h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_h_min(a) }
fn layout_h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (*self).layout_h_max(a) }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { (*self).layout(a) }
}
impl<O: Out, L: Layout<O>> Layout<O> for &mut L {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).x(a) }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).y(a) }
fn w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w(a) }
fn w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_min(a) }
fn w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_max(a) }
fn h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h(a) }
fn h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_min(a) }
fn h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_max(a) }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_x(a) }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_y(a) }
fn layout_w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w(a) }
fn layout_w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_min(a) }
fn layout_w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_max(a) }
fn layout_h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h(a) }
fn layout_h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_min(a) }
fn layout_h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_max(a) }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { (**self).layout(a) }
}
impl<O: Out, L: Layout<O>> Layout<O> for Arc<L> {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).x(a) }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).y(a) }
fn w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w(a) }
fn w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_min(a) }
fn w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_max(a) }
fn h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h(a) }
fn h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_min(a) }
fn h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_max(a) }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_x(a) }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_y(a) }
fn layout_w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w(a) }
fn layout_w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_min(a) }
fn layout_w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_max(a) }
fn layout_h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h(a) }
fn layout_h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_min(a) }
fn layout_h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_max(a) }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { (**self).layout(a) }
}
impl<O: Out> Layout<O> for Box<dyn Layout<O>> {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).x(a) }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).y(a) }
fn w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w(a) }
fn w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_min(a) }
fn w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).w_max(a) }
fn h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h(a) }
fn h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_min(a) }
fn h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).h_max(a) }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_x(a) }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_y(a) }
fn layout_w (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w(a) }
fn layout_w_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_min(a) }
fn layout_w_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_w_max(a) }
fn layout_h (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h(a) }
fn layout_h_min (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_min(a) }
fn layout_h_max (&self, a: XYWH<O::Unit>) -> O::Unit { (**self).layout_h_max(a) }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { (**self).layout(a) }
}
impl<O: Out, L: Layout<O>> Layout<O> for RwLock<L> {
fn x (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().x(a) }
fn y (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().y(a) }
fn w (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().w(a) }
fn w_min (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().w_min(a) }
fn w_max (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().w_max(a) }
fn h (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().h(a) }
fn h_min (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().h_min(a) }
fn h_max (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().h_max(a) }
fn layout_x (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_x(a) }
fn layout_y (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_y(a) }
fn layout_w (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_w(a) }
fn layout_w_min (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_w_min(a) }
fn layout_w_max (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_w_max(a) }
fn layout_h (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_h(a) }
fn layout_h_min (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_h_min(a) }
fn layout_h_max (&self, a: XYWH<O::Unit>) -> O::Unit { self.read().unwrap().layout_h_max(a) }
fn layout (&self, a: XYWH<O::Unit>) -> XYWH<O::Unit> { self.read().unwrap().layout(a) }
}
impl<O: Out, L: Layout<O>> Layout<O> for Option<L> {
fn x (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.x(to)).unwrap_or(to.x()) }
fn y (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.y(to)).unwrap_or(to.y()) }
fn w_min (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.w_min(to)).unwrap_or(0.into()) }
fn w_max (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.w_max(to)).unwrap_or(0.into()) }
fn w (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.w(to)).unwrap_or(0.into()) }
fn h_min (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.h_min(to)).unwrap_or(0.into()) }
fn h_max (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.h_max(to)).unwrap_or(0.into()) }
fn h (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.h(to)).unwrap_or(0.into()) }
fn layout_x (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_x(to)).unwrap_or(to.x()) }
fn layout_y (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_y(to)).unwrap_or(to.y()) }
fn layout_w_min (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_w_min(to)).unwrap_or(0.into()) }
fn layout_w_max (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_w_max(to)).unwrap_or(0.into()) }
fn layout_w (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_w(to)).unwrap_or(0.into()) }
fn layout_h_min (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_h_min(to)).unwrap_or(0.into()) }
fn layout_h_max (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_h_max(to)).unwrap_or(0.into()) }
fn layout_h (&self, to: XYWH<O::Unit>) -> O::Unit { self.as_ref().map(|c|c.layout_h(to)).unwrap_or(0.into()) }
fn layout (&self, to: XYWH<O::Unit>) -> XYWH<O::Unit> {
self.as_ref()
.map(|c|c.layout(XYWH(self.x(to), self.y(to), self.w(to), self.h(to)).into()))
.unwrap_or(XYWH(to.x(), to.y(), 0.into(), 0.into()))
let xywh = XYWH(self.layout_x(to), self.layout_y(to), self.layout_w(to), self.layout_h(to));
self.as_ref().map(|c|c.layout(xywh)).unwrap_or(XYWH(to.x(), to.y(), 0.into(), 0.into()))
}
}
@ -405,14 +404,14 @@ push_pull!(Pull: minus);
layout_op_xy!(0: Fill);
impl<O: Out, T: Layout<O>> Layout<O> for Fill<T> {
fn x (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.x() } else { self.inner().x(area) } }
fn y (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.y() } else { self.inner().y(area) } }
fn w (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().w(area) } }
fn w_min (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().w_min(area) } }
fn w_max (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().w_max(area) } }
fn h (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().h(area) } }
fn h_min (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().h_min(area) } }
fn h_max (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().h_max(area) } }
fn layout_x (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.x() } else { self.inner().layout_x(area) } }
fn layout_y (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.y() } else { self.inner().layout_y(area) } }
fn layout_w (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().layout_w(area) } }
fn layout_w_min (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().layout_w_min(area) } }
fn layout_w_max (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dx() { area.w() } else { self.inner().layout_w_max(area) } }
fn layout_h (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().layout_h(area) } }
fn layout_h_min (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().layout_h_min(area) } }
fn layout_h_max (&self, area: XYWH<O::Unit>) -> O::Unit { if self.dy() { area.h() } else { self.inner().layout_h_max(area) } }
}
impl<A> Fill<A> {
@ -423,12 +422,12 @@ impl<A> Fill<A> {
layout_op_xy!(1 opt: Fixed);
impl<O: Out, T: Layout<O>> Layout<O> for Fixed<O::Unit, T> {
fn w (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().w(area)) }
fn w_min (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().w_min(area)) }
fn w_max (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().w_max(area)) }
fn h (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().h(area)) }
fn h_min (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().h_min(area)) }
fn h_max (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().h_max(area)) }
fn layout_w (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().layout_w(area)) }
fn layout_w_min (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().layout_w_min(area)) }
fn layout_w_max (&self, area: XYWH<O::Unit>) -> O::Unit { self.dx().unwrap_or(self.inner().layout_w_max(area)) }
fn layout_h (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().layout_h(area)) }
fn layout_h_min (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().layout_h_min(area)) }
fn layout_h_max (&self, area: XYWH<O::Unit>) -> O::Unit { self.dy().unwrap_or(self.inner().layout_h_max(area)) }
}
layout_op_xy!(1 opt: Max);
@ -460,10 +459,10 @@ impl<E: Out, T: Layout<E>> Layout<E> for Min<E::Unit, T> {
layout_op_xy!(1 opt: Expand);
impl<O: Out, T: Layout<O>> Layout<O> for Expand<O::Unit, T> {
fn w (&self, to: XYWH<O::Unit>) -> O::Unit {
fn layout_w (&self, to: XYWH<O::Unit>) -> O::Unit {
self.inner().w(to).plus(self.dx().unwrap_or_default())
}
fn h (&self, to: XYWH<O::Unit>) -> O::Unit {
fn layout_h (&self, to: XYWH<O::Unit>) -> O::Unit {
self.inner().w(to).plus(self.dy().unwrap_or_default())
}
}
@ -500,19 +499,19 @@ impl<O: Out, T: Content<O>> Draw<O> for Align<T> {
}
impl<O: Out, T: Layout<O>> Layout<O> for Align<T> {
fn x (&self, to: XYWH<O::Unit>) -> O::Unit {
fn layout_x (&self, to: XYWH<O::Unit>) -> O::Unit {
match self.0 {
NW | W | SW => to.x(),
N | Center | S => to.x().plus(to.w() / 2.into()).minus(self.1.w(to) / 2.into()),
NE | E | SE => to.x().plus(to.w()).minus(self.1.w(to)),
N | Center | S => to.x().plus(to.w() / 2.into()).minus(self.1.layout_w(to) / 2.into()),
NE | E | SE => to.x().plus(to.w()).minus(self.1.layout_w(to)),
_ => todo!(),
}
}
fn y (&self, to: XYWH<O::Unit>) -> O::Unit {
fn layout_y (&self, to: XYWH<O::Unit>) -> O::Unit {
match self.0 {
NW | N | NE => to.y(),
W | Center | E => to.y().plus(to.h() / 2.into()).minus(self.1.h(to) / 2.into()),
SW | S | SE => to.y().plus(to.h()).minus(self.1.h(to)),
W | Center | E => to.y().plus(to.h() / 2.into()).minus(self.1.layout_h(to) / 2.into()),
SW | S | SE => to.y().plus(to.h()).minus(self.1.layout_h(to)),
_ => todo!(),
}
}
@ -541,10 +540,10 @@ impl<O: Out, T: Content<O>> Draw<O> for Pad<O::Unit, T> {
}
impl<O: Out, T: Layout<O>> Layout<O> for Pad<O::Unit, T> {
fn x (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().plus(self.dx()) }
fn y (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().plus(self.dx()) }
fn w (&self, area: XYWH<O::Unit>) -> O::Unit { area.w().minus(self.dx() * 2.into()) }
fn h (&self, area: XYWH<O::Unit>) -> O::Unit { area.h().minus(self.dy() * 2.into()) }
fn layout_x (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().plus(self.dx()) }
fn layout_y (&self, area: XYWH<O::Unit>) -> O::Unit { area.x().plus(self.dx()) }
fn layout_w (&self, area: XYWH<O::Unit>) -> O::Unit { area.w().minus(self.dx() * 2.into()) }
fn layout_h (&self, area: XYWH<O::Unit>) -> O::Unit { area.h().minus(self.dy() * 2.into()) }
}
impl<Head, Tail> Bsp<Head, Tail> {
@ -585,23 +584,41 @@ impl<O: Out, Head: Content<O>, Tail: Content<O>> Draw<O> for Bsp<Head, Tail> {
}
impl<O: Out, Head: Layout<O>, Tail: Layout<O>> Layout<O> for Bsp<Head, Tail> {
fn w (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | North | South => self.1.w(area).max(self.2.w(area)), East | West => self.1.w_min(area).plus(self.2.w(area)), }
fn layout_w (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | North | South => self.1.layout_w(area).max(self.2.layout_w(area)),
East | West => self.1.layout_w_min(area).plus(self.2.layout_w(area)),
}
fn w_min (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | North | South => self.1.w_min(area).max(self.2.w_min(area)), East | West => self.1.w_min(area).plus(self.2.w_min(area)), }
}
fn w_max (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | North | South => self.1.w_max(area).max(self.2.w_max(area)), East | West => self.1.w_max(area).plus(self.2.w_max(area)), }
fn layout_w_min (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | North | South => self.1.layout_w_min(area).max(self.2.layout_w_min(area)),
East | West => self.1.layout_w_min(area).plus(self.2.layout_w_min(area)),
}
fn h (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | East | West => self.1.h(area).max(self.2.h(area)), North | South => self.1.h(area).plus(self.2.h(area)), }
}
fn h_min (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | East | West => self.1.h_min(area).max(self.2.h_min(area)), North | South => self.1.h_min(area).plus(self.2.h_min(area)), }
fn layout_w_max (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | North | South => self.1.layout_w_max(area).max(self.2.layout_w_max(area)),
East | West => self.1.layout_w_max(area).plus(self.2.layout_w_max(area)),
}
}
fn layout_h (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | East | West => self.1.layout_h(area).max(self.2.layout_h(area)),
North | South => self.1.layout_h(area).plus(self.2.layout_h(area)),
}
}
fn layout_h_min (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | East | West => self.1.layout_h_min(area).max(self.2.layout_h_min(area)),
North | South => self.1.layout_h_min(area).plus(self.2.layout_h_min(area)),
}
}
fn layout_h_max (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 {
Above | Below | North | South => self.1.layout_h_max(area).max(self.2.layout_h_max(area)),
East | West => self.1.layout_h_max(area).plus(self.2.layout_h_max(area)),
}
fn h_max (&self, area: XYWH<O::Unit>) -> O::Unit {
match self.0 { Above | Below | North | South => self.1.h_max(area).max(self.2.h_max(area)), East | West => self.1.h_max(area).plus(self.2.h_max(area)), }
}
fn layout (&self, area: XYWH<O::Unit>) -> XYWH<O::Unit> {
bsp_areas(area, self.0, &self.1, &self.2)[2]

View file

@ -73,16 +73,16 @@ pub trait Lay<O: Out>: Sized {}
/// Drawable area of display.
pub trait Layout<O: Out> {
fn x (&self, to: XYWH<O::Unit>) -> O::Unit { to.x() }
fn y (&self, to: XYWH<O::Unit>) -> O::Unit { to.y() }
fn w_min (&self, _t: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn w_max (&self, to: XYWH<O::Unit>) -> O::Unit { to.w() }
fn w (&self, to: XYWH<O::Unit>) -> O::Unit { to.w().max(self.w_min(to)).min(self.w_max(to)) }
fn h_min (&self, _t: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn h_max (&self, to: XYWH<O::Unit>) -> O::Unit { to.h() }
fn h (&self, to: XYWH<O::Unit>) -> O::Unit { to.h().max(self.h_min(to)).min(self.h_max(to)) }
fn layout_x (&self, to: XYWH<O::Unit>) -> O::Unit { to.x() }
fn layout_y (&self, to: XYWH<O::Unit>) -> O::Unit { to.y() }
fn layout_w_min (&self, _t: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_w_max (&self, to: XYWH<O::Unit>) -> O::Unit { to.w() }
fn layout_w (&self, to: XYWH<O::Unit>) -> O::Unit { to.w().max(self.layout_w_min(to)).min(self.layout_w_max(to)) }
fn layout_h_min (&self, _t: XYWH<O::Unit>) -> O::Unit { 0.into() }
fn layout_h_max (&self, to: XYWH<O::Unit>) -> O::Unit { to.h() }
fn layout_h (&self, to: XYWH<O::Unit>) -> O::Unit { to.h().max(self.layout_h_min(to)).min(self.layout_h_max(to)) }
fn layout (&self, to: XYWH<O::Unit>) -> XYWH<O::Unit> {
XYWH(self.x(to), self.y(to), self.w(to), self.h(to))
XYWH(self.layout_x(to), self.layout_y(to), self.layout_w(to), self.layout_h(to))
}
}