mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-17 15:56:57 +02:00
add Screen::area and ::clip to implement Align
This commit is contained in:
parent
ddc53b23c2
commit
482b624169
7 changed files with 85 additions and 37 deletions
10
src/draw.rs
10
src/draw.rs
|
|
@ -24,7 +24,15 @@ use crate::*;
|
|||
pub trait Screen: Xy<Self::Unit> + Wh<Self::Unit> + Send + Sync + Sized {
|
||||
type Unit: Coord;
|
||||
/// Render drawable in subarea specified by `area`
|
||||
fn show <T: Draw<Self>> (&mut self, content: T) -> Perhaps<XYWH<Self::Unit>>;
|
||||
fn show (&mut self, content: impl Draw<Self>) -> Perhaps<XYWH<Self::Unit>>;
|
||||
/// Get current clipping area
|
||||
fn area (&self) -> XYWH<Self::Unit>;
|
||||
/// Set clipping area
|
||||
fn clip <T> (
|
||||
&mut self,
|
||||
area: impl Into<Option<XYWH<Self::Unit>>>,
|
||||
draw: impl FnOnce(&mut Self)->T
|
||||
) -> T;
|
||||
}
|
||||
|
||||
/// Implement the [Draw] trait for a particular drawable and [Screen].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue