wip: final simplify

This commit is contained in:
facile pop culture reference 2026-07-05 18:46:22 +03:00
parent 90ebae0f26
commit 0b9e9c0696
21 changed files with 607 additions and 544 deletions

87
src/layout.rs Normal file
View file

@ -0,0 +1,87 @@
use crate::*;
mod align; pub use self::align::*;
mod area; pub use self::area::*;
mod origin; pub use self::origin::*;
mod split; pub use self::split::*;
pub enum Layout<T: Screen, X: Into<Option<T::Unit>>, I: Draw<T>> {
__(PhantomData<T>),
MinW(X, I),
MinH(X, I),
MinWH(X, X, I),
MaxW(X, I),
MaxH(X, I),
MaxWH(X, X, I),
ExactW(X, I),
ExactH(X, I),
ExactWH(X, X, I),
ClipW(X, I),
ClipH(X, I),
ClipWH(X, X, I),
}
impl<
T: Screen,
X: Into<Option<T::Unit>>,
I: Draw<T>
> Draw<T> for Layout<T, X, I> {
fn draw (self, to: &mut T) -> Usually<XYWH<T::Unit>> {
use Layout::*;
match self {
__(_) => unreachable!(),
MinW(x, it) => {
let x = x.into();
it.draw(to)
},
MinH(y, it) => {
let y = y.into();
it.draw(to)
},
MinWH(x, y, it) => {
let x = x.into();
let y = y.into();
it.draw(to)
},
MaxW(x, it) => {
let x = x.into();
it.draw(to)
},
MaxH(y, it) => {
let y = y.into();
it.draw(to)
},
MaxWH(x, y, it) => {
let x = x.into();
let y = y.into();
it.draw(to)
},
ExactW(x, it) => {
let x = x.into();
it.draw(to)
},
ExactH(y, it) => {
let y = y.into();
it.draw(to)
},
ExactWH(x, y, it) => {
let x = x.into();
let y = y.into();
it.draw(to)
},
ClipW(x, it) => {
let x = x.into();
it.draw(to)
},
ClipH(y, it) => {
let y = y.into();
it.draw(to)
},
ClipWH(x, y, it) => {
let x = x.into();
let y = y.into();
it.draw(to)
},
}
}
}