Fix LayoutBounds calculation

More work is needed for LayoutBoundsSpace
This commit is contained in:
Sasha Koshka 2024-09-19 08:07:39 -04:00
parent 5171cbac16
commit 56024caaf5

16
flow.go
View File

@ -33,10 +33,9 @@ func reflow (
size.X, xAlign, lineEnd == len(tokens))
// calculate extents
lastWordTok := tokens[lastWord]
lastTokenTok := tokens[lastToken]
lineMax := lastWordTok.position.X + lastWordTok.width
lineMaxSpace := lastTokenTok.position.X + lastTokenTok.width
lineMax, lineMaxSpace := calculateLineExtents (
tokens[lastWord],
tokens[lastToken])
if lineMax > minimumSize.X { minimumSize.X = lineMax }
if lineMaxSpace > extentsSpace.Max.X { extentsSpace.Max.X = lineMaxSpace }
}
@ -103,6 +102,15 @@ func reflow (
return
}
func calculateLineExtents (lastWord, lastToken token) (lineMax, lineMaxSpace fixed.Int26_6) {
if lastWord.kind == tokenKindWord {
// the line had a word in it
lineMax = lastWord.position.X + lastWord.width
}
lineMaxSpace = lastToken.position.X + lastToken.width
return lineMax, lineMaxSpace
}
func alignLinesVertically (tokens []token, height, contentHeight fixed.Int26_6, align Align) {
if len(tokens) == 0 { return }
if align == AlignStart { return }