~alcinnz/CatTrap

1073c5644ed17986619278da3664cb1d93b03d7e — Adrian Cochrane 1 year, 2 months ago ddee4bc
Simplify final width computation.
1 files changed, 7 insertions(+), 8 deletions(-)

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