mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-09-18 13:26:42 +02:00
This commit is contained in:
parent
cf67185ffd
commit
799e497622
10 changed files with 456 additions and 460 deletions
|
|
@ -47,18 +47,21 @@ pub fn iter_south <'a, S: Screen, D: Draw<S>, I: Iterator<Item = D>> (
|
|||
iter: impl Fn()->I
|
||||
) -> impl Draw<S> {
|
||||
draw(move|to: &mut S|{
|
||||
let XYWH(x, mut y, w, mut h) = to.area();
|
||||
let h0 = h;
|
||||
let XYWH(x, y, w, h) = to.area();
|
||||
let mut y_next = y;
|
||||
let mut h_used = S::Unit::zero();
|
||||
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() {
|
||||
let area = XYWH(x, y_next, w, h.minus(h_used));
|
||||
if let Some(used) = to.draw(area, item)? {
|
||||
let used_h = used.h();
|
||||
y_next = y_next.plus(used_h);
|
||||
h_used = h_used.plus(used_h);
|
||||
if h_used >= h {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(XYWH(x, y, w, h)))
|
||||
Ok(Some(XYWH(x, y, w, h_used)))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue