From b09719993af0b9150b8b79c3ec08601795c5cd4e Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Thu, 6 Aug 2026 08:32:48 +0300 Subject: [PATCH] implement iter_south with single iterator --- src/layout/iter.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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> (