mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
52 lines
960 B
Rust
52 lines
960 B
Rust
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(()) }
|
|
|
|
/// Unit of distance.
|
|
type Unit: Number;
|
|
|
|
type HandleInput;
|
|
type Handled;
|
|
type RenderInput;
|
|
type Rendered;
|
|
}
|
|
|
|
pub trait HandleContext {}
|
|
|
|
pub trait RenderContext {}
|
|
|
|
submod! {
|
|
collect
|
|
component
|
|
exit
|
|
focus
|
|
handle
|
|
keymap
|
|
layered
|
|
layout
|
|
render
|
|
split
|
|
}
|