wip: generic layout!

This commit is contained in:
🪞👃🪞 2024-09-06 21:52:23 +03:00
parent 0bbf74e915
commit 93ba611e33
11 changed files with 267 additions and 82 deletions

View file

@ -1,22 +1,36 @@
use crate::*;
use std::ops::{Add, Sub};
use std::cmp::{Ord, Eq, PartialEq};
/// Entry point for main loop
pub trait App<T: Engine> {
fn run (self, context: T) -> Usually<T>;
}
pub trait Number: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ Ord + PartialEq + Eq {}
impl<T> Number for T where
T: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ 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(()) }
type HandleInput;
fn handle (&self, _: &mut impl Handle<Self>) -> Usually<()> where Self: Sized;
type Handled;
/// Unit of distance.
type Unit: Number;
type HandleInput;
type Handled;
type RenderInput;
fn render (&mut self, _: &impl Render<Self>) -> Usually<()> where Self: Sized;
type Rendered;
}
@ -25,9 +39,14 @@ pub trait HandleContext {}
pub trait RenderContext {}
submod! {
collect
component
exit
focus
handle
keymap
layered
layout
render
split
}