mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-10 21:56:42 +01:00
errors fixed, renders nothing :(
This commit is contained in:
parent
b3f0f60400
commit
4cca03352a
9 changed files with 47 additions and 44 deletions
|
|
@ -13,12 +13,11 @@ impl<'a, E: Engine> Render<E> for Collected<'a, E> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E: Engine> Layout<E> for &Collected<'a, E> {
|
||||
impl<'a, E: Engine> Layout<E> for Collected<'a, E> {
|
||||
fn layout (&self, area: E::Area) -> Perhaps<E::Area> {
|
||||
match *self {
|
||||
Collected::Box(inner) => (*inner).layout(area),
|
||||
Collected::Ref(inner) => (*inner).layout(area),
|
||||
match self {
|
||||
Self::Box(inner) => (*inner).layout(area),
|
||||
Self::Ref(inner) => (*inner).layout(area),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,21 @@ pub fn center_box (area: Rect, w: u16, h: u16) -> Rect {
|
|||
pub trait Layout<E: Engine>: Render<E> {
|
||||
fn layout (&self, area: E::Area) -> Perhaps<E::Area>;
|
||||
}
|
||||
|
||||
impl<E: Engine, T: Layout<E>> Layout<E> for &T {
|
||||
fn layout (&self, area: E::Area) -> Perhaps<E::Area> {
|
||||
(*self).layout(area)
|
||||
}
|
||||
}
|
||||
impl<E: Engine, T: Layout<E>> Layout<E> for Option<T> {
|
||||
fn layout (&self, area: E::Area) -> Perhaps<E::Area> {
|
||||
match self {
|
||||
Some(layout) => layout.layout(area),
|
||||
None => Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Enforce minimum size of drawing area
|
||||
pub enum Min<U: Number, L> { W(U, L), H(U, L), WH(U, U, L), }
|
||||
/// Enforce maximum size of drawing area
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ pub trait Render<E: Engine>: Send + Sync {
|
|||
fn render (&self, to: &mut E) -> Perhaps<E::Rendered>;
|
||||
}
|
||||
|
||||
impl<E: Engine> Render<E> for () {
|
||||
fn render (&self, to: &mut E) -> Perhaps<E::Rendered> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Options can be rendered optionally.
|
||||
impl<R, E: Engine> Render<E> for Option<R> where R: Render<E> {
|
||||
fn render (&self, to: &mut E) -> Perhaps<E::Rendered> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue