mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
genericize layout rendering
This commit is contained in:
parent
1d21071c86
commit
4855609a7d
8 changed files with 167 additions and 118 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue