mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: big flat pt.5: implement transforms with macro
This commit is contained in:
parent
34e731f111
commit
18b2d8c48b
8 changed files with 387 additions and 558 deletions
|
|
@ -1,6 +1,16 @@
|
|||
use crate::*;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
|
||||
/// Rendering target
|
||||
pub trait Output<E: Engine> {
|
||||
/// Current output area
|
||||
fn area (&self) -> E::Area;
|
||||
/// Mutable pointer to area
|
||||
fn area_mut (&mut self) -> &mut E::Area;
|
||||
/// Render widget in area
|
||||
fn render_in (&mut self, area: E::Area, widget: &impl Render<E>) -> Usually<()>;
|
||||
}
|
||||
|
||||
/// Define custom content for a struct.
|
||||
#[macro_export] macro_rules! render {
|
||||
|
||||
|
|
@ -45,11 +55,37 @@ pub trait Render<E: Engine>: Send + Sync {
|
|||
}
|
||||
}
|
||||
|
||||
impl<E: Engine> Render<E> for &dyn Render<E> {}
|
||||
//impl<E: Engine> Render<E> for &mut dyn Render<E> {}
|
||||
//impl<E: Engine> Render<E> for Box<dyn Render<E>> {}
|
||||
impl<E: Engine, R: Render<E>> Render<E> for &R {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for &mut R {}
|
||||
impl<E: Engine, R: Render<E>> Render<E> for Option<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for Arc<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for Mutex<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for RwLock<R> {}
|
||||
|
||||
/// Something that can be represented by a renderable component.
|
||||
pub trait Content<E: Engine>: Send + Sync {
|
||||
fn content (&self) -> Option<impl Render<E>>;
|
||||
}
|
||||
|
||||
//impl<E: Engine> Content<E> for &dyn Render<E> {}
|
||||
//impl<E: Engine> Content<E> for &mut dyn Render<E> {}
|
||||
//impl<E: Engine> Content<E> for Box<dyn Render<E>> {}
|
||||
impl<E: Engine, C: Content<E>> Content<E> for &C {
|
||||
fn content (&self) -> Option<impl Render<E>> {
|
||||
(*self).content()
|
||||
}
|
||||
}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for &mut C {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Option<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Arc<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Mutex<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for RwLock<C> {}
|
||||
|
||||
//impl<E: Engine, C: Content<E>> Render<E> for C {}
|
||||
|
||||
//impl<E: Engine, C: Content<E>> Render<E> for C {
|
||||
///// Minimum size to use
|
||||
//fn min_size (&self, to: E::Size) -> Perhaps<E::Size> {
|
||||
|
|
@ -63,38 +99,6 @@ pub trait Content<E: Engine>: Send + Sync {
|
|||
//}
|
||||
//}
|
||||
|
||||
/// Rendering target
|
||||
pub trait Output<E: Engine> {
|
||||
/// Current output area
|
||||
fn area (&self) -> E::Area;
|
||||
/// Mutable pointer to area
|
||||
fn area_mut (&mut self) -> &mut E::Area;
|
||||
/// Render widget in area
|
||||
fn render_in (&mut self, area: E::Area, widget: &dyn Render<E>) -> Usually<()>;
|
||||
}
|
||||
|
||||
//impl<E: Engine> Render<E> for &dyn Render<E> {}
|
||||
//impl<E: Engine> Render<E> for &mut dyn Render<E> {}
|
||||
//impl<E: Engine> Render<E> for Box<dyn Render<E>> {}
|
||||
impl<E: Engine, R: Render<E>> Render<E> for &R {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for &mut R {}
|
||||
impl<E: Engine, R: Render<E>> Render<E> for Option<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for Arc<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for Mutex<R> {}
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for RwLock<R> {}
|
||||
|
||||
//impl<E: Engine> Content<E> for &dyn Render<E> {}
|
||||
//impl<E: Engine> Content<E> for &mut dyn Render<E> {}
|
||||
//impl<E: Engine> Content<E> for Box<dyn Render<E>> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for &C {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for &mut C {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Option<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Arc<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for Mutex<C> {}
|
||||
//impl<E: Engine, C: Content<E>> Content<E> for RwLock<C> {}
|
||||
|
||||
//impl<E: Engine, C: Content<E>> Render<E> for C {}
|
||||
|
||||
/****
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue