mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-17 15:56:57 +02:00
wip: impl_draw, optional drawing
This commit is contained in:
parent
0b9e9c0696
commit
bf16288884
12 changed files with 213 additions and 229 deletions
121
src/layout.rs
121
src/layout.rs
|
|
@ -2,7 +2,6 @@ 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>> {
|
||||
|
|
@ -21,67 +20,65 @@ pub enum Layout<T: Screen, X: Into<Option<T::Unit>>, I: Draw<T>> {
|
|||
ClipWH(X, X, I),
|
||||
}
|
||||
|
||||
impl<
|
||||
impl_draw!(<
|
||||
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)
|
||||
},
|
||||
}
|
||||
I: Draw<T>,
|
||||
>|self: Layout<T, X, I>, to: T|{
|
||||
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)
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue