diff --git a/src/widget/position/span.rs b/src/widget/position/span.rs index 0140469..ae7522f 100644 --- a/src/widget/position/span.rs +++ b/src/widget/position/span.rs @@ -28,16 +28,13 @@ impl Widget for Span { // given whatever else is in it and wherever this child sits among // them; what a drawn child is asked in is the room left from the // cursor, because a text has to wrap at the width actually there. - // This is the one ask a drawn fixed child gets: its slot is its - // answer, and the drawing is moved there once the shares are known. - // A hinted child is asked once, in its slot. let mut cursor = Len::rel_min(); let mut lens = Vec::with_capacity(self.children.len()); - let mut measured = Vec::with_capacity(self.children.len()); + let mut drawn_across = Vec::with_capacity(self.children.len()); for child in &self.children { - let size = match painter.size_hint(child, axis) { + let len = match painter.size_hint(child, axis) { Some(len) => { - measured.push(None); + drawn_across.push(None); len } None => { @@ -45,11 +42,10 @@ impl Widget for Span { let size = painter .widget_at(child, [None; 2], axis.pair(room, across)) .size(); - measured.push(Some(size)); + drawn_across.push(Some(size.axis(!axis))); size.axis(axis) } }; - let len = size; cursor.px += len.px + self.gap; cursor.rel += len.rel; lens.push(len); @@ -104,8 +100,7 @@ impl Widget for Span { let mut taken = Weight::ZERO; let mut start = Len::rel_min(); let mut ortho = LayoutLen::ZERO; - for ((child, len), measured) in self.children.iter().zip(&lens).zip(&measured) { - let len = *len; + for ((child, &len), &across_len) in self.children.iter().zip(&lens).zip(&drawn_across) { // A child asking for nothing but a part of what is left over, // when nothing is, is not drawn at all. One that also asked for // pixels or a fraction keeps those and overflows. @@ -135,10 +130,10 @@ impl Widget for Span { if len.leftover > Weight::ZERO && shares { narrow[axis as usize] = Some(slot.len()); } - let used = match (measured, narrow[axis as usize]) { - (Some(size), None) => { + let used = match (across_len, narrow[axis as usize]) { + (Some(across_len), None) => { painter.place_at(child, place); - size.axis(!axis) + across_len } _ => painter.widget_at(child, narrow, place).len(!axis), };