mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-21 18:49:04 +01:00
refactor: HasSize -> Measured
This commit is contained in:
parent
07a1206c2f
commit
45e122668c
2 changed files with 9 additions and 7 deletions
|
|
@ -204,8 +204,8 @@ impl Direction {
|
|||
}
|
||||
}
|
||||
|
||||
impl<E: Out, T: Has<Measure<E>>> HasSize<E> for T {
|
||||
fn size (&self) -> &Measure<E> {
|
||||
impl<E: Out, T: Has<Measure<E>>> Measured<E> for T {
|
||||
fn measure (&self) -> &Measure<E> {
|
||||
self.get()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ pub trait HasWH<N: Coord> {
|
|||
}
|
||||
|
||||
// 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> {
|
||||
fn x2 (&self) -> N { self.x().plus(self.w()) }
|
||||
fn y2 (&self) -> N { self.y().plus(self.h()) }
|
||||
|
|
@ -147,9 +149,9 @@ pub trait HasXYWH<N: Coord>: HasXY<N> + HasWH<N> {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO DOCUMENTME
|
||||
pub trait HasSize<O: Out> {
|
||||
fn size (&self) -> &Measure<O>;
|
||||
fn width (&self) -> O::Unit { self.size().w() }
|
||||
fn height (&self) -> O::Unit { self.size().h() }
|
||||
// Something that has a [Measure] of its rendered size.
|
||||
pub trait Measured<O: Out> {
|
||||
fn measure (&self) -> &Measure<O>;
|
||||
fn measure_width (&self) -> O::Unit { self.measure().w() }
|
||||
fn measure_height (&self) -> O::Unit { self.measure().h() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue