Set vertical margins in redoParagraph, not setRowHeight

It is actually easier to set the 20 pixels margin in redoParagraph, since it is not necessary to take newlines in account when deciding what is the real last row of the paragraph.

Moreover this solves the following bug (present in 2.1.x too): when the document ends with a newling, the bottom margin disappears.

Update PAINTING_ANALYSIS with new tasks.
This commit is contained in:
Jean-Marc Lasgouttes 2016-04-08 16:34:46 +02:00
parent 598f7e4a45
commit 656b7f5ab7
2 changed files with 34 additions and 14 deletions

View File

@ -100,7 +100,25 @@ version.
==> more versions, no optional parameters.
** make Inset::display() more useful
** DONE When a document ends with a newline, add the bottom margin anyway
The code that tests for a newline was added at 6bb98d07 in 2007.
** When a paragraph ends with a newline, compute correctly the height of the extra row.
** Rewrite TextMetrics::completionPosAndDim using row information
Currently it uses setRowHeight in a very weird way. In particular the
topBottomSpace parameter should be removed after that.
** Rewrite TextMetrics::editXY, checkInsetHit using row information (getPosNearX)?
The helper version should return a Row::Element instead of an InsetTable.
** TODO make Inset::display() more useful
[This has been started in the features/betterbreak branch. Time will
tell whether it really helps. The question in particular is the
handling of separator insets]
Extending the DisplayType enum would allow to remove special cases
from the code.

View File

@ -471,6 +471,21 @@ bool TextMetrics::redoParagraph(pit_type const pit)
pm.dim().des += row.height();
} while (first < par.size() || need_new_row);
// FIXME: It might be better to move this in another method
// specially tailored for the main text.
// Top and bottom margin of the document (only at top-level)
if (text_->isMainText()) {
if (pit == 0) {
pm.rows().front().dimension().asc += 20;
pm.dim().des += 20;
}
ParagraphList const & pars = text_->paragraphs();
if (pit + 1 == pit_type(pars.size())) {
pm.rows().back().dimension().des += 20;
pm.dim().des += 20;
}
}
if (row_index < pm.rows().size())
pm.rows().resize(row_index);
@ -1044,19 +1059,6 @@ void TextMetrics::setRowHeight(Row & row, pit_type const pit,
maxasc += int(layoutasc * 2 / (2 + pars[pit].getDepth()));
maxdes += int(layoutdesc * 2 / (2 + pars[pit].getDepth()));
// FIXME: the correct way is to do the following is to move the
// following code in another method specially tailored for the
// main Text. The following test is thus bogus.
// Top and bottom margin of the document (only at top-level)
if (text_->isMainText() && topBottomSpace) {
if (pit == 0 && row.pos() == 0)
maxasc += 20;
if (pit + 1 == pit_type(pars.size()) &&
row.endpos() == par.size() &&
!(row.endpos() > 0 && par.isNewline(row.endpos() - 1)))
maxdes += 20;
}
row.dimension().asc = maxasc + labeladdon;
row.dimension().des = maxdes;
}