~alcinnz/CatTrap

593bc796bb41157cb9a52bb8687e9f8cc1b6be9e — Adrian Cochrane 1 year, 8 months ago 6489290
Add missing child traversal to maxwidth computation & simplify API signature.
1 files changed, 8 insertions(+), 7 deletions(-)

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