diff --git a/src/layout/iter.rs b/src/layout/iter.rs index e1cb3d9..bd80aae 100644 --- a/src/layout/iter.rs +++ b/src/layout/iter.rs @@ -43,10 +43,23 @@ pub fn iter_east_fixed <'a, S: Screen, D: 'a, I: Iterator, U: Draw> draw(move|_to: &mut S|{ todo!() }) } -pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator, U: Draw> ( - _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U, +pub fn iter_south <'a, S: Screen, D: Draw, I: Iterator> ( + iter: impl Fn()->I ) -> impl Draw { - 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, U: Draw> (