mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: and sweeps right through the codebase
This commit is contained in:
parent
d37bd3e0c5
commit
c9b09b7dea
16 changed files with 370 additions and 625 deletions
|
|
@ -8,36 +8,51 @@ pub trait Output<E: Engine> {
|
|||
/// 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<()>;
|
||||
fn place (&mut self, area: E::Area, content: &impl Content<E>);
|
||||
|
||||
#[inline] fn x (&self) -> E::Unit { self.area().x() }
|
||||
#[inline] fn y (&self) -> E::Unit { self.area().y() }
|
||||
#[inline] fn w (&self) -> E::Unit { self.area().w() }
|
||||
#[inline] fn h (&self) -> E::Unit { self.area().h() }
|
||||
#[inline] fn wh (&self) -> E::Size { self.area().wh().into() }
|
||||
}
|
||||
|
||||
pub trait Layout<E: Engine>: Send + Sync {
|
||||
fn layout (&self) -> Option<impl Render<E>> {
|
||||
pub trait Content<E: Engine>: Send + Sync {
|
||||
fn content (&self) -> Option<impl Content<E>> {
|
||||
None::<()>
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine> Layout<E> for () {}
|
||||
|
||||
impl<E: Engine, L: Layout<E>> Layout<E> for &L {}
|
||||
|
||||
pub trait Render<E: Engine>: Send + Sync {
|
||||
fn render (&self, _: &mut E::Output);
|
||||
}
|
||||
|
||||
impl<E: Engine, L: Layout<E>> Render<E> for L {
|
||||
fn render (&self, to: &mut E::Output) {
|
||||
if let Some(content) = self.layout() {
|
||||
content.render(to)
|
||||
fn area (&self, area: E::Area) -> E::Area {
|
||||
if let Some(content) = self.content() {
|
||||
content.area(area)
|
||||
} else {
|
||||
[0.into(), 0.into(), 0.into(), 0.into()].into()
|
||||
}
|
||||
}
|
||||
fn render (&self, output: &mut E::Output) {
|
||||
if let Some(content) = self.content() {
|
||||
output.place(self.area(output.area()), &content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine> Content<E> for () {}
|
||||
|
||||
impl<E: Engine, T: Content<E>> Content<E> for &T {}
|
||||
|
||||
//impl<E: Engine, R: Render<E>> Render<E> for &R {}
|
||||
|
||||
//pub trait Render<E: Engine>: Send + Sync {
|
||||
//fn render (&self, _: &mut E::Output);
|
||||
//}
|
||||
|
||||
//impl<E: Engine, L: Layout<E>> Render<E> for L {
|
||||
//fn render (&self, to: &mut E::Output) {
|
||||
//if let Some(content) = self.layout() {
|
||||
//content.render(to)
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
//impl<E: Engine, L: Layout<E>> Layout<E> for &L {}
|
||||
|
||||
///// Something that can be represented by a renderable component.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue