add Screen::area and ::clip to implement Align

This commit is contained in:
facile pop culture reference 2026-07-15 12:57:53 +03:00
parent ddc53b23c2
commit 482b624169
7 changed files with 85 additions and 37 deletions

View file

@ -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].