mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
implement iter_south with single iterator
This commit is contained in:
parent
ac9fd7dfba
commit
b09719993a
1 changed files with 16 additions and 3 deletions
|
|
@ -43,10 +43,23 @@ pub fn iter_east_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>>
|
||||||
draw(move|_to: &mut S|{ todo!() })
|
draw(move|_to: &mut S|{ todo!() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
pub fn iter_south <'a, S: Screen, D: Draw<S>, I: Iterator<Item = D>> (
|
||||||
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
|
iter: impl Fn()->I
|
||||||
) -> impl Draw<S> {
|
) -> impl Draw<S> {
|
||||||
draw(move|_to: &mut S|{ todo!() })
|
draw(move|to: &mut S|{
|
||||||
|
let XYWH(x, mut y, w, mut h) = to.area();
|
||||||
|
let h0 = h;
|
||||||
|
for item in iter() {
|
||||||
|
if let Some(used) = to.draw(Some(XYWH(x, y, w, h)), item)? {
|
||||||
|
y = y.add(used.y());
|
||||||
|
h = h.minus(used.y());
|
||||||
|
if h == S::Unit::zero() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Some(XYWH(x, y, w, h)))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_south_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
pub fn iter_south_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue