@@ 82,20 82,19 @@ boxMinWidth parent (LayoutGrid val self childs) = LayoutGrid val self' $ zip cel
(GridItem {..}, _) <- childs]) parent
zeroBox :: PaddedBox Double Double
zeroBox = zero
-boxMinWidth _ self@(LayoutInline _ font self' _) = self
-boxMinWidth _ self@(LayoutSpan _ f self') = self
+boxMinWidth _ self@(LayoutInline _ _ _ _) = self
+boxMinWidth _ self@(LayoutSpan _ _ _) = 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')
+ Maybe Double -> LayoutItem y Length x -> LayoutItem y Length x
+boxNatWidth parent (LayoutFlow val self childs) = LayoutFlow val self' childs'
where
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
+ childs' = map (boxNatWidth $ Just selfWidth) childs
selfWidth = width $ mapX' (lowerLength parent') self
parent' = fromMaybe 0 parent
-boxNatWidth parent (LayoutGrid val self childs) =
- (size', LayoutGrid val self' $ zip cells' childs')
+boxNatWidth parent (LayoutGrid val self childs) = LayoutGrid val self' $ zip cells' childs'
where
self' = self {
containerSize = Size (Pixels size') (block $ containerSize self),
@@ 108,15 107,15 @@ boxNatWidth parent (LayoutGrid val self childs) =
cells' = map setCellBox $ zip childs' $ map fst childs
setCellBox (child, cell) = cell { gridItemBox = layoutGetBox child }
childs'' = map (mapX' $ lowerLength selfWidth) $ map layoutGetBox childs'
- childs' = map snd $ map (boxNatWidth $ Just selfWidth) $ map snd childs
+ childs' = map (boxNatWidth $ Just selfWidth) $ map snd childs
selfWidth = lowerLength parent' $ inline $ containerSize self
parent' = fromMaybe (gridEstWidth self [
GridItem startRow endRow startCol endCol alignment zeroBox |
(GridItem {..}, _) <- childs]) parent
zeroBox :: PaddedBox Double Double
zeroBox = zero
-boxNatWidth _ self@(LayoutInline _ font self' _) = (inlineNatWidth font self', self)
-boxNatWidth _ self@(LayoutSpan _ f self') = (B.inline $ fragmentSize' f self', self)
+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)
where
@@ 338,7 337,7 @@ boxLayout :: PaddedBox Double Double -> LayoutItem Length Length x -> Bool ->
boxLayout parent self paginate = self8
where
self0 = boxMinWidth Nothing self
- (_, self1) = boxNatWidth Nothing self0
+ self1 = boxNatWidth Nothing self0
(_, self2) = boxMaxWidth parent self1
(_, self3) = boxWidth parent self2
(natsize, self4) = boxNatHeight (inline $ size parent) self3
@@ 49,5 49,6 @@ finalizeParagraph (ParagraphBuilder txt ops) font' = Just $ Paragraph txt' 0 ops
pOps = ParagraphOptions {
paragraphFont = hbFont font',
paragraphLineHeight = Absolute $ round (lineheight font' * hbScale font'),
- paragraphMaxWidth = 0 -- This is what we're computing!
+ -- This is what we're computing! Configure to give natural width.
+ paragraphMaxWidth = maxBound -- i.e. has all the space it needs...
}