]> git.lyx.org Git - features.git/commit
Fix up a4d9315b: handle metrics of not visible paragraphs
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 17 May 2024 13:42:08 +0000 (15:42 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 17 May 2024 15:57:33 +0000 (17:57 +0200)
commit5c5410c39cd7f3dfe4e187eedb7a4222e07c4b83
tree9da05f00423a33deff8ba05469a3cc0be2ba68af
parentbe4e5dd43bf1563db832599b9e23c8800889db52
Fix up a4d9315b: handle metrics of not visible paragraphs

The code is not ready for situations where some paragraphs that are
not visible have metrics available. This has been made visible by
a4d9315b, which removes a couple of full metrics updates: the screen
was not correctly scrolled after a scrollToCursor() call.

In PararagraphMetrics, some methods are added to be able to handle the
fact that paragraphs have or do not have a position.

In TextMetrics, a new method returns the first visible paragraph.

Finally, in BufferView::updateMetrics, the paragraphs' positions are
reset (in the case where everything is not cleared) and some care is
taken to skip the ones that are not relevant.

The assumption outside of this method is that all the paragraphs that
are in the TextMetrics are visible (we are talking about top-level
TextMetrics here). This could be changed (in order to avoid
recomputing paragraph metrics), but the cost is high in terms of
complexity and it is not clear that the gain in terms of performance
would be important.

(cherry picked from commit 145af7c2ac1eb2c5ec5102a7a11cb740be7b3c43)
src/BufferView.cpp
src/ParagraphMetrics.cpp
src/ParagraphMetrics.h
src/TextMetrics.cpp
src/TextMetrics.h