From 006bc9e801c8bf0cde9518be29908d4c889e5686 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 30 Mar 2023 19:59:35 +1300 Subject: [PATCH] Integrate utility resolving conflicting dataflow. --- Graphics/Layout.hs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Graphics/Layout.hs b/Graphics/Layout.hs index 1a40d39..267ab6d 100644 --- a/Graphics/Layout.hs +++ b/Graphics/Layout.hs @@ -58,7 +58,7 @@ boxMinWidth :: (Zero y, CastDouble y) => Maybe Double -> LayoutItem y Length x -> (Double, LayoutItem y Length x) boxMinWidth parent (LayoutFlow val self childs) = (min', LayoutFlow val self' childs') where - self' = self {B.min = Size (Pixels min') (block $ B.min self) } + self' = self { B.min = mapSizeX (B.mapAuto min') (B.min self) } min' = flowMinWidth parent' self childs'' childs'' = map (mapX' $ lowerLength selfWidth) $ map layoutGetBox childs' childs' = map snd $ map (boxMinWidth $ Just selfWidth) childs @@ -87,11 +87,9 @@ boxMinWidth _ self@(LayoutInline _ font self' _) = (inlineMinWidth font self', s boxMinWidth _ self@(LayoutSpan _ f self') = (B.inline $ fragmentSize' f self', self) boxNatWidth :: (Zero y, CastDouble y) => Maybe Double -> LayoutItem y Length x -> (Double, LayoutItem y Length x) -boxNatWidth parent (LayoutFlow val self childs) = (size', LayoutFlow val self childs') - -- NOTE: Need to preserve auto/percentage in actual width calculation. - -- self' doesn't preserve this. CatTrap will need a decent refactor! +boxNatWidth parent (LayoutFlow val self childs) = (size', LayoutFlow val self' childs') where - self' = self {size = Size (Pixels size') (block $ size self) } + self' = self { size = mapSizeX (B.mapAuto size') (size self) } size' = flowNatWidth parent' self childs'' childs'' = map (mapX' $ lowerLength selfWidth) $ map layoutGetBox childs' childs' = map snd $ map (boxNatWidth $ Just selfWidth) childs @@ -176,13 +174,10 @@ boxWidth parent (LayoutSpan val font self') = boxNatHeight :: Double -> LayoutItem Length Double x -> (Double, LayoutItem Length Double x) boxNatHeight parent (LayoutFlow val self childs) = (size', LayoutFlow val self' childs') where - self' = self { - size = Size width (Pixels size') - } + self' = self { size = mapSizeY (mapAuto size') (size self) } size' = flowNatHeight parent self childs'' childs'' = map (mapY' (lowerLength parent)) $ map layoutGetBox childs' - childs' = map snd $ map (boxNatHeight width) childs - width = inline $ size self + childs' = map snd $ map (boxNatHeight $ inline $ size self) childs boxNatHeight parent (LayoutGrid val self childs) = (size', LayoutGrid val self' $ zip cells childs') where @@ -202,9 +197,7 @@ boxMinHeight :: Double -> LayoutItem Length Double x -> (Double, LayoutItem Leng boxMinHeight parent (LayoutFlow val self childs) = (min', LayoutFlow val self' childs') where childs' = map snd $ map (boxMinHeight $ inline $ size self) childs - self' = self { - B.min = Size (inline $ B.min self) (Pixels min') - } + self' = self { B.min = Size (inline $ B.min self) (Pixels min') } min' = flowMinHeight parent self boxMinHeight parent (LayoutGrid val self childs) = (min', LayoutGrid val self' childs') where @@ -231,9 +224,7 @@ boxMaxHeight :: PaddedBox Double Double -> LayoutItem Length Double x -> boxMaxHeight parent (LayoutFlow val self childs) = (max', LayoutFlow val self' childs') where childs' = map snd $ map (boxMaxHeight $ mapY' (lowerLength width) self') childs - self' = self { - B.max = Size (inline $ B.max self) (Pixels max') - } + self' = self { B.max = Size (inline $ B.max self) (Pixels max') } max' = flowMaxHeight (inline $ size parent) self width = inline $ size self boxMaxHeight parent (LayoutGrid val self childs) = (max', LayoutGrid val self' childs') -- 2.30.2