diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-22 12:42:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-22 12:42:02 +0100 |
| commit | 2bf32c51bceb2f3a8b7ebea3d7c7d6d96757591b (patch) | |
| tree | 3524388a7394dd35ccef10b89a7a034e6ae1ab60 /src/library/columns.rs | |
| parent | c7e52f20483971a39f54c56700b31980f744a410 (diff) | |
Remove layout cache
Diffstat (limited to 'src/library/columns.rs')
| -rw-r--r-- | src/library/columns.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/library/columns.rs b/src/library/columns.rs index 049fa8b9..bae23dd3 100644 --- a/src/library/columns.rs +++ b/src/library/columns.rs @@ -32,23 +32,23 @@ impl Layout for ColumnsNode { vm: &mut Vm, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Constrained<Arc<Frame>>>> { + ) -> TypResult<Vec<Arc<Frame>>> { // Separating the infinite space into infinite columns does not make // much sense. - if regions.current.x.is_infinite() { + if regions.first.x.is_infinite() { return self.child.layout(vm, regions, styles); } // Determine the width of the gutter and each column. let columns = self.columns.get(); let gutter = styles.get(Self::GUTTER).resolve(regions.base.x); - let width = (regions.current.x - gutter * (columns - 1) as f64) / columns as f64; + let width = (regions.first.x - gutter * (columns - 1) as f64) / columns as f64; // Create the pod regions. let pod = Regions { - current: Size::new(width, regions.current.y), + first: Size::new(width, regions.first.y), base: Size::new(width, regions.base.y), - backlog: std::iter::once(®ions.current.y) + backlog: std::iter::once(®ions.first.y) .chain(regions.backlog.as_slice()) .flat_map(|&height| std::iter::repeat(height).take(columns)) .skip(1) @@ -66,18 +66,18 @@ impl Layout for ColumnsNode { let mut finished = vec![]; // Stitch together the columns for each region. - for (current, base) in regions.iter().take(total_regions) { + for region in regions.iter().take(total_regions) { // The height should be the parent height if the node shall expand. // Otherwise its the maximum column height for the frame. In that // case, the frame is first created with zero height and then // resized. - let height = if regions.expand.y { current.y } else { Length::zero() }; - let mut output = Frame::new(Size::new(regions.current.x, height)); + let height = if regions.expand.y { region.y } else { Length::zero() }; + let mut output = Frame::new(Size::new(regions.first.x, height)); let mut cursor = Length::zero(); for _ in 0 .. columns { let frame = match frames.next() { - Some(frame) => frame.item, + Some(frame) => frame, None => break, }; @@ -89,17 +89,14 @@ impl Layout for ColumnsNode { let x = if dir.is_positive() { cursor } else { - regions.current.x - cursor - width + regions.first.x - cursor - width }; output.push_frame(Point::with_x(x), frame); cursor += width + gutter; } - let mut cts = Constraints::new(regions.expand); - cts.base = base.map(Some); - cts.exact = current.map(Some); - finished.push(output.constrain(cts)); + finished.push(Arc::new(output)); } Ok(finished) |
