~alcinnz/CatTrap

006bc9e801c8bf0cde9518be29908d4c889e5686 — Adrian Cochrane 1 year, 8 months ago 1090e6c
Integrate utility resolving conflicting dataflow.
1 files changed, 7 insertions(+), 16 deletions(-)

M Graphics/Layout.hs
M Graphics/Layout.hs => Graphics/Layout.hs +7 -16
@@ 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')