mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
dsl, output, tui: add tests, examples, root dispatchers
This commit is contained in:
parent
8dfe20a58c
commit
ca862b9802
16 changed files with 637 additions and 377 deletions
|
|
@ -3,15 +3,9 @@
|
|||
#![feature(impl_trait_in_assoc_type)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
#![feature(type_changing_struct_update)]
|
||||
#![feature(anonymous_lifetime_in_impl_trait)]
|
||||
//#![feature(non_lifetime_binders)]
|
||||
|
||||
mod content; pub use self::content::*;
|
||||
mod draw; pub use self::draw::*;
|
||||
mod group; pub use self::group::*;
|
||||
mod layout; pub use self::layout::*;
|
||||
mod space; pub use self::space::*;
|
||||
mod thunk; pub use self::thunk::*;
|
||||
mod widget; pub use self::widget::*;
|
||||
pub(crate) use self::Direction::*;
|
||||
pub(crate) use std::fmt::{Debug, Display};
|
||||
pub(crate) use std::marker::PhantomData;
|
||||
|
|
@ -19,38 +13,49 @@ pub(crate) use std::ops::{Add, Sub, Mul, Div};
|
|||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}};
|
||||
pub(crate) use tengri_core::*;
|
||||
|
||||
/// Draw target.
|
||||
/// Drawing target.
|
||||
pub trait Out: Send + Sync + Sized {
|
||||
/// Unit of length
|
||||
type Unit: Coordinate;
|
||||
|
||||
/// Rectangle without offset
|
||||
type Size: Size<Self::Unit>;
|
||||
|
||||
/// Rectangle with offset
|
||||
type Area: Area<Self::Unit>;
|
||||
/// Current output area
|
||||
fn area (&self) -> Self::Area;
|
||||
/// Mutable pointer to area
|
||||
fn area_mut (&mut self) -> &mut Self::Area;
|
||||
/// Draw widget in area
|
||||
fn place_at <'t, T: Draw<Self> + ?Sized> (&mut self, area: Self::Area, content: &'t T);
|
||||
|
||||
fn place <'t, T: Draw<Self> + Layout<Self> + ?Sized> (&mut self, content: &'t T) {
|
||||
/// Render drawable in area specified by `T::layout(self.area())`
|
||||
#[inline] fn place <'t, T: Draw<Self> + Layout<Self> + ?Sized> (
|
||||
&mut self, content: &'t T
|
||||
) {
|
||||
self.place_at(content.layout(self.area()), content)
|
||||
}
|
||||
|
||||
/// Render drawable in area specified by `area`
|
||||
fn place_at <'t, T: Draw<Self> + ?Sized> (&mut self, area: Self::Area, content: &'t T);
|
||||
|
||||
/// Current output area
|
||||
fn area (&self) -> Self::Area;
|
||||
#[inline] fn x (&self) -> Self::Unit { self.area().x() }
|
||||
#[inline] fn y (&self) -> Self::Unit { self.area().y() }
|
||||
#[inline] fn w (&self) -> Self::Unit { self.area().w() }
|
||||
#[inline] fn h (&self) -> Self::Unit { self.area().h() }
|
||||
#[inline] fn wh (&self) -> Self::Size { self.area().wh().into() }
|
||||
|
||||
/// Mutable pointer to area.
|
||||
fn area_mut (&mut self) -> &mut Self::Area;
|
||||
}
|
||||
|
||||
#[cfg(test)] mod test;
|
||||
#[cfg(test)] mod output_test;
|
||||
#[cfg(test)] pub(crate) use proptest_derive::Arbitrary;
|
||||
|
||||
//impl<E: Out, C: Content<E> + Layout<E>> Draw<E> for C { // if only
|
||||
//fn draw (&self, to: &mut E) {
|
||||
//if let Some(content) = self.content() {
|
||||
//to.place_at(self.layout(to.area()), &content);
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
mod content; pub use self::content::*;
|
||||
mod draw; pub use self::draw::*;
|
||||
mod group; pub use self::group::*;
|
||||
mod layout; pub use self::layout::*;
|
||||
mod space; pub use self::space::*;
|
||||
mod thunk; pub use self::thunk::*;
|
||||
mod widget; pub use self::widget::*;
|
||||
|
||||
#[cfg(feature = "dsl")] mod view;
|
||||
#[cfg(feature = "dsl")] pub use self::view::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue