genericize layout rendering

This commit is contained in:
🪞👃🪞 2024-09-06 23:32:13 +03:00
parent 1d21071c86
commit 4855609a7d
8 changed files with 167 additions and 118 deletions

View file

@ -7,6 +7,28 @@ pub trait App<T: Engine> {
fn run (self, context: T) -> Usually<T>;
}
/// Platform backend.
pub trait Engine: Sized {
fn setup (&mut self) -> Usually<()> { Ok(()) }
fn exited (&self) -> bool;
fn teardown (&mut self) -> Usually<()> { Ok(()) }
/// Unit of distance.
type Unit: Number;
type Area: Rectangle<Self::Unit>;
type HandleInput;
type Handled;
type RenderInput;
type Rendered;
// FIXME
fn area (&self) -> Self::Area;
// FIXME
fn with_area (&mut self, x: Self::Unit, y: Self::Unit, w: Self::Unit, h: Self::Unit)
-> &mut Self;
}
pub trait Number: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
@ -19,25 +41,6 @@ impl<T> Number for T where
+ Ord + PartialEq + Eq
{}
/// Platform backend.
pub trait Engine: Sized {
fn setup (&mut self) -> Usually<()> { Ok(()) }
fn exited (&self) -> bool;
fn teardown (&mut self) -> Usually<()> { Ok(()) }
/// Unit of distance.
type Unit: Number;
type HandleInput;
type Handled;
type RenderInput;
type Rendered;
}
pub trait HandleContext {}
pub trait RenderContext {}
submod! {
collect
component