mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-10-08 20:26:42 +02:00
Shrink, Expand
This commit is contained in:
parent
21d6674ffb
commit
1e8b18134d
1 changed files with 36 additions and 0 deletions
|
|
@ -8,6 +8,14 @@ pub enum Exact<'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>>> {
|
|||
__(PhantomData<&'a S>), W(I, X), H(I, X), WH(I, X, X),
|
||||
}
|
||||
|
||||
pub enum Shrink<'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>>> {
|
||||
__(PhantomData<&'a S>), W(I, X), H(I, X), WH(I, X, X),
|
||||
}
|
||||
|
||||
pub enum Expand<'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>>> {
|
||||
__(PhantomData<&'a S>), W(I, X), H(I, X), WH(I, X, X),
|
||||
}
|
||||
|
||||
pub enum Push<'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>>> {
|
||||
__(PhantomData<&'a S>), X(I, X), Y(I, X), XY(I, X, X),
|
||||
}
|
||||
|
|
@ -375,6 +383,34 @@ impl <'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>> + Copy> Draw<S> for Ma
|
|||
}
|
||||
}
|
||||
|
||||
impl <'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>> + Copy> Draw<S> for Expand<'a, S, I, X> {
|
||||
fn draw (&self, to: &mut S) -> Drawn<S::Unit> {
|
||||
#[cfg(feature = "prof")] profiling::scope!("expand_draw");
|
||||
let XYWH(x, y, w0, h0) = to.area();
|
||||
let (item, w, h) = match self {
|
||||
Self::W(item, w) => (item, (*w).into(), None),
|
||||
Self::H(item, h) => (item, None, (*h).into()),
|
||||
Self::WH(item, w, h) => (item, (*w).into(), (*h).into()),
|
||||
_ => return Ok(None)
|
||||
};
|
||||
to.draw(XYWH(x, y, w0 + w.unwrap_or_default(), h0 + h.unwrap_or_default()), item)
|
||||
}
|
||||
}
|
||||
|
||||
impl <'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>> + Copy> Draw<S> for Shrink<'a, S, I, X> {
|
||||
fn draw (&self, to: &mut S) -> Drawn<S::Unit> {
|
||||
#[cfg(feature = "prof")] profiling::scope!("shrink_draw");
|
||||
let XYWH(x, y, w0, h0) = to.area();
|
||||
let (item, w, h) = match self {
|
||||
Self::W(item, w) => (item, (*w).into(), None),
|
||||
Self::H(item, h) => (item, None, (*h).into()),
|
||||
Self::WH(item, w, h) => (item, (*w).into(), (*h).into()),
|
||||
_ => return Ok(None)
|
||||
};
|
||||
to.draw(XYWH(x, y, w0.minus(w.unwrap_or_default()), h0.minus(h.unwrap_or_default())), item)
|
||||
}
|
||||
}
|
||||
|
||||
impl <'a, S: Screen, I: Draw<S>, X: Into<Option<S::Unit>> + Copy> Draw<S> for Push<'a, S, I, X> {
|
||||
fn draw (&self, to: &mut S) -> Drawn<S::Unit> {
|
||||
#[cfg(feature = "prof")] profiling::scope!("push_draw");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue