mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
output: more big refactors
This commit is contained in:
parent
194f2f9874
commit
5e6338fad8
68 changed files with 1604 additions and 1016 deletions
|
|
@ -1,7 +1,28 @@
|
|||
use crate::*;
|
||||
#![feature(step_trait)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
#![feature(type_changing_struct_update)]
|
||||
//#![feature(non_lifetime_binders)]
|
||||
|
||||
/// Render target.
|
||||
pub trait Output: Send + Sync + Sized {
|
||||
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;
|
||||
pub(crate) use std::ops::{Add, Sub, Mul, Div, Deref};
|
||||
pub(crate) use std::rc::Rc;
|
||||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}};
|
||||
pub(crate) use tengri_core::*;
|
||||
#[cfg(feature = "dsl")] pub(crate) use ::tengri_dsl::*;
|
||||
|
||||
/// Draw target.
|
||||
pub trait Out: Send + Sync + Sized {
|
||||
/// Unit of length
|
||||
type Unit: Coordinate;
|
||||
/// Rectangle without offset
|
||||
|
|
@ -12,11 +33,26 @@ pub trait Output: Send + Sync + Sized {
|
|||
fn area (&self) -> Self::Area;
|
||||
/// Mutable pointer to area
|
||||
fn area_mut (&mut self) -> &mut Self::Area;
|
||||
/// Render widget in area
|
||||
fn place <'t, T: Render<Self> + ?Sized> (&mut self, area: Self::Area, content: &'t T);
|
||||
/// 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) {
|
||||
self.place_at(content.layout(self.area()), content)
|
||||
}
|
||||
#[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() }
|
||||
}
|
||||
|
||||
#[cfg(test)] mod 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);
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue