From 593bc796bb41157cb9a52bb8687e9f8cc1b6be9e Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 30 Mar 2023 20:39:19 +1300 Subject: [PATCH] Add missing child traversal to maxwidth computation & simplify API signature. --- Graphics/Layout.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Graphics/Layout.hs b/Graphics/Layout.hs index 636dc40..65f660a 100644 --- a/Graphics/Layout.hs +++ b/Graphics/Layout.hs @@ -116,18 +116,19 @@ boxNatWidth parent (LayoutGrid val self childs) = LayoutGrid val self' $ zip cel zeroBox = zero boxNatWidth _ self@(LayoutInline _ _ _ _) = self boxNatWidth _ self@(LayoutSpan _ _ _) = self -boxMaxWidth :: PaddedBox a Double -> LayoutItem y Length x -> (Double, LayoutItem y Length x) -boxMaxWidth parent (LayoutFlow val self childs) = (max', LayoutFlow val self' childs) +boxMaxWidth :: PaddedBox a Double -> LayoutItem y Length x -> LayoutItem y Length x +boxMaxWidth parent (LayoutFlow val self childs) = LayoutFlow val self' childs' where + childs' = map (boxMaxWidth self'') childs + self'' = mapX (lowerLength $ inline $ B.size parent) self' self' = self { B.max = Size (Pixels max') (block $ B.max self) } max' = flowMaxWidth parent self -boxMaxWidth parent (LayoutGrid val self childs) = - (max', LayoutGrid val self' childs) +boxMaxWidth parent (LayoutGrid val self childs) = LayoutGrid val self' childs where self' = self { containerMax = Size (Pixels max') (block $ containerMax self) } (max', _) = gridMaxWidths parent self $ colBounds self -boxMaxWidth parent self@(LayoutInline _ _ _ _) = (B.inline $ B.max parent, self) -boxMaxWidth parent self@(LayoutSpan _ f self') = (B.inline $ fragmentSize' f self', self) +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') @@ -338,7 +339,7 @@ boxLayout parent self paginate = self8 where self0 = boxMinWidth Nothing self self1 = boxNatWidth Nothing self0 - (_, self2) = boxMaxWidth parent self1 + self2 = boxMaxWidth parent self1 (_, self3) = boxWidth parent self2 (natsize, self4) = boxNatHeight (inline $ size parent) self3 (_, self5) = boxMinHeight natsize self4 -- 2.30.2