mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-01-31 10:56:41 +01:00
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use crate::*;
|
|
|
|
/// Drawing target.
|
|
pub trait Out: Send + Sync + Sized {
|
|
/// Unit of length
|
|
type Unit: Coordinate;
|
|
|
|
/// Rectangle without offset
|
|
type Size: Size<Self::Unit>;
|
|
|
|
/// Rectangle with offset
|
|
type Area: Area<Self::Unit>;
|
|
|
|
/// Render drawable in area specified by `T::layout(self.area())`
|
|
#[inline] fn place <'t, T: Content<Self> + ?Sized> (
|
|
&mut self, content: &'t T
|
|
) {
|
|
self.place_at(content.layout(self.area()), content)
|
|
}
|
|
|
|
/// Render drawable in area specified by `area`
|
|
fn place_at <'t, T: Draw<Self> + ?Sized> (&mut self, area: Self::Area, content: &'t T);
|
|
|
|
/// Current output area
|
|
fn area (&self) -> Self::Area;
|
|
#[inline] fn x (&self) -> Self::Unit { self.area().x() }
|
|
#[inline] fn y (&self) -> Self::Unit { self.area().y() }
|
|
#[inline] fn w (&self) -> Self::Unit { self.area().w() }
|
|
#[inline] fn h (&self) -> Self::Unit { self.area().h() }
|
|
#[inline] fn wh (&self) -> Self::Size { self.area().wh().into() }
|
|
|
|
/// Mutable pointer to area.
|
|
fn area_mut (&mut self) -> &mut Self::Area;
|
|
}
|