From 1073c5644ed17986619278da3664cb1d93b03d7e Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Wed, 5 Apr 2023 20:36:24 +1200 Subject: [PATCH] Simplify final width computation. --- Graphics/Layout.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Graphics/Layout.hs b/Graphics/Layout.hs index 4b47ca4..ca076f8 100644 --- a/Graphics/Layout.hs +++ b/Graphics/Layout.hs @@ -130,21 +130,21 @@ boxMaxWidth parent (LayoutGrid val self childs) = LayoutGrid val self' childs boxMaxWidth parent self@(LayoutInline _ _ _ _) = self boxMaxWidth parent self@(LayoutSpan _ f self') = self boxWidth :: (Zero y, CastDouble y) => PaddedBox b Double -> LayoutItem y Length x -> - (Double, LayoutItem y Double x) -boxWidth parent (LayoutFlow val self childs) = (size', LayoutFlow val self' childs') + LayoutItem y Double x +boxWidth parent (LayoutFlow val self childs) = LayoutFlow val self' childs' where - childs' = map (snd . boxWidth self') childs + childs' = map (boxWidth self') childs self' = (mapX' (lowerLength $ inline $ size parent) self) { size = Size size' $ block $ B.max self } size' = flowWidth parent self -boxWidth parent (LayoutGrid val self childs) = (size', LayoutGrid val self' childs') +boxWidth parent (LayoutGrid val self childs) = LayoutGrid val self' childs' where childs' = map recurse childs recurse (cell, child) = (cell', child') where cell' = cell { gridItemBox = layoutGetBox child' } - (_, child') = boxWidth parent' child + child' = boxWidth parent' child parent' = zero { B.min = containerMin self', B.size = containerSize self', @@ -165,10 +165,9 @@ boxWidth parent (LayoutGrid val self childs) = (size', LayoutGrid val self' chil outerwidth = inline $ size parent (size', widths) = gridWidths parent self $ colBounds self boxWidth parent (LayoutInline val font (Paragraph a b c d) vals) = - (width, LayoutInline val font (Paragraph a b c d { paragraphMaxWidth = round width }) vals) + LayoutInline val font (Paragraph a b c d { paragraphMaxWidth = round width }) vals where width = B.inline $ B.size parent -boxWidth parent (LayoutSpan val font self') = - (B.inline $ fragmentSize' font self', LayoutSpan val font self') +boxWidth parent (LayoutSpan val font self') = LayoutSpan val font self' boxNatHeight :: Double -> LayoutItem Length Double x -> LayoutItem Length Double x boxNatHeight parent (LayoutFlow val self childs) = LayoutFlow val self' childs' -- 2.30.2