refactor: HasSize -> Measured

This commit is contained in:
same mf who else 2026-02-15 06:03:08 +02:00
parent 07a1206c2f
commit 45e122668c
2 changed files with 9 additions and 7 deletions

View file

@ -204,8 +204,8 @@ impl Direction {
} }
} }
impl<E: Out, T: Has<Measure<E>>> HasSize<E> for T { impl<E: Out, T: Has<Measure<E>>> Measured<E> for T {
fn size (&self) -> &Measure<E> { fn measure (&self) -> &Measure<E> {
self.get() self.get()
} }
} }

View file

@ -134,6 +134,8 @@ pub trait HasWH<N: Coord> {
} }
// Something that has a 2D bounding box (X, Y, W, H). // Something that has a 2D bounding box (X, Y, W, H).
//
// FIXME: The other way around?
pub trait HasXYWH<N: Coord>: HasXY<N> + HasWH<N> { pub trait HasXYWH<N: Coord>: HasXY<N> + HasWH<N> {
fn x2 (&self) -> N { self.x().plus(self.w()) } fn x2 (&self) -> N { self.x().plus(self.w()) }
fn y2 (&self) -> N { self.y().plus(self.h()) } fn y2 (&self) -> N { self.y().plus(self.h()) }
@ -147,9 +149,9 @@ pub trait HasXYWH<N: Coord>: HasXY<N> + HasWH<N> {
} }
} }
// TODO DOCUMENTME // Something that has a [Measure] of its rendered size.
pub trait HasSize<O: Out> { pub trait Measured<O: Out> {
fn size (&self) -> &Measure<O>; fn measure (&self) -> &Measure<O>;
fn width (&self) -> O::Unit { self.size().w() } fn measure_width (&self) -> O::Unit { self.measure().w() }
fn height (&self) -> O::Unit { self.size().h() } fn measure_height (&self) -> O::Unit { self.measure().h() }
} }