moar flat

This commit is contained in:
facile pop culture reference 2026-08-01 17:52:37 +03:00
parent fc01fd6ad3
commit a27dacff93
29 changed files with 649 additions and 582 deletions

86
src/layout/iter.rs Normal file
View file

@ -0,0 +1,86 @@
use super::*;
/// Iterate over a collection of the same kind of [Draw]able:
pub fn iter <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
/// Iterate over a collection of the same kind of [Draw]able:
pub fn iter_once <'a, S: Screen, D: 'a, U: Draw<S>> (
_iter: impl Iterator<Item = D>, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
/// Iterate over a collection of various [Draw]ables:
pub fn iter_dyn <
S: Screen, // Target screen
D, // Input doesn't need to be [Draw]able, output does
V: Fn()->I, // Function that returns the iterator
I: Iterator<Item = D>, // Type of the iterator
F: Fn(&D, usize)->dyn Draw<S>, // Function that returns [Draw]able from iterator item
> (_items: V, _cb: F) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_north <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_east <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_east_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_height: S::Unit, _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_south_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_height: S::Unit, _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_west <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
}
pub fn row_south <S: Screen> (south: S::Unit, height: S::Unit, content: impl Draw<S>)
-> impl Draw<S>
{
content.exact_h(height).push_y(south)
}
pub fn row_north <S: Screen> (north: S::Unit, height: S::Unit, content: impl Draw<S>)
-> impl Draw<S>
{
content.exact_h(height).pull_y(north)
}
pub fn col_east <S: Screen> (east: S::Unit, width: S::Unit, content: impl Draw<S>)
-> impl Draw<S>
{
content.exact_w(width).push_x(east)
}
pub fn col_west <S: Screen> (west: S::Unit, width: S::Unit, content: impl Draw<S>)
-> impl Draw<S>
{
content.exact_w(width).pull_x(west)
}