mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
sweeeeping sweep
This commit is contained in:
parent
c9b09b7dea
commit
e677d1d7d4
38 changed files with 766 additions and 691 deletions
|
|
@ -50,3 +50,110 @@ impl Direction {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders multiple things on top of each other,
|
||||
#[macro_export] macro_rules! lay {
|
||||
($($expr:expr),* $(,)?) => {{
|
||||
let bsp = ();
|
||||
$(let bsp = Bsp::b(bsp, $expr);)*;
|
||||
bsp
|
||||
}}
|
||||
}
|
||||
|
||||
/// Stack southward.
|
||||
#[macro_export] macro_rules! col {
|
||||
($($expr:expr),* $(,)?) => {{
|
||||
let bsp = ();
|
||||
$(let bsp = Bsp::s(bsp, $expr);)*;
|
||||
bsp
|
||||
}};
|
||||
}
|
||||
|
||||
/// Stack northward.
|
||||
#[macro_export] macro_rules! col_up {
|
||||
($($expr:expr),* $(,)?) => {{
|
||||
let bsp = ();
|
||||
$(let bsp = Bsp::n(bsp, $expr);)*;
|
||||
bsp
|
||||
}}
|
||||
}
|
||||
|
||||
/// Stack eastward.
|
||||
#[macro_export] macro_rules! row {
|
||||
($($expr:expr),* $(,)?) => {{
|
||||
let bsp = ();
|
||||
$(let bsp = Bsp::e(bsp, $expr);)*;
|
||||
bsp
|
||||
}};
|
||||
}
|
||||
|
||||
pub enum Bsp<E: Engine, X: Content<E>, Y: Content<E>> {
|
||||
/// X is north of Y
|
||||
N(Option<f64>, Option<X>, Option<Y>),
|
||||
/// X is south of Y
|
||||
S(Option<f64>, Option<X>, Option<Y>),
|
||||
/// X is east of Y
|
||||
E(Option<f64>, Option<X>, Option<Y>),
|
||||
/// X is west of Y
|
||||
W(Option<f64>, Option<X>, Option<Y>),
|
||||
/// X is above Y
|
||||
A(Option<X>, Option<Y>),
|
||||
/// X is below Y
|
||||
B(Option<X>, Option<Y>),
|
||||
/// Should be avoided.
|
||||
Null(PhantomData<E>),
|
||||
}
|
||||
|
||||
impl<E: Engine, X: Content<E>, Y: Content<E>> Bsp<E, X, Y> {
|
||||
pub fn n (x: X, y: Y) -> Self { Self::N(None, Some(x), Some(y)) }
|
||||
pub fn s (x: X, y: Y) -> Self { Self::S(None, Some(x), Some(y)) }
|
||||
pub fn e (x: X, y: Y) -> Self { Self::E(None, Some(x), Some(y)) }
|
||||
pub fn w (x: X, y: Y) -> Self { Self::W(None, Some(x), Some(y)) }
|
||||
pub fn a (x: X, y: Y) -> Self { Self::A(Some(x), Some(y)) }
|
||||
pub fn b (x: X, y: Y) -> Self { Self::B(Some(x), Some(y)) }
|
||||
}
|
||||
|
||||
impl<E: Engine, X: Content<E>, Y: Content<E>> Default for Bsp<E, X, Y> {
|
||||
fn default () -> Self {
|
||||
Self::Null(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine, X: Content<E>, Y: Content<E>> Content<E> for Bsp<E, X, Y> {
|
||||
fn render (&self, to: &mut E::Output) {
|
||||
let n = E::Size::zero();
|
||||
let s = to.wh();
|
||||
match self {
|
||||
Self::Null(_) => {},
|
||||
//Self::S(p, a, b) => {
|
||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
||||
//let h = s_a.h().into();
|
||||
//to.render_in(to.area().clip_h(h).into(), a);
|
||||
//to.render_in(to.area().shrink_y(h).push_y(h).into(), b);
|
||||
//},
|
||||
//Self::E(p, a, b) => {
|
||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
||||
//let w = s_a.w().into();
|
||||
//to.render_in(to.area().clip_w(w).into(), a);
|
||||
//to.render_in(to.area().push_x(w).shrink_x(w).into(), b);
|
||||
//},
|
||||
//Self::W(p, a, b) => {
|
||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
||||
//let w = (to.area().w() - s_a.w()).into();
|
||||
//to.render_in(to.area().push_x(w).into(), a);
|
||||
//to.render_in(to.area().shrink_x(w).into(), b);
|
||||
//},
|
||||
//Self::N(p, a, b) => {
|
||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
||||
//let h = to.area().h() - s_a.h();
|
||||
//to.render_in(to.area().push_y(h).into(), a);
|
||||
//to.render_in(to.area().shrink_y(h).into(), b);
|
||||
//},
|
||||
_ => todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue