]> git.lyx.org Git - lyx.git/commit
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>
Wed, 10 Jul 2024 15:18:47 +0000 (17:18 +0200)
commit10b8861d103490e4598582608ac60407d6b0b711
treef109593ef04018c767b3bb616d37dbcff2b25882
parentf64349db8d544bbce835d958371a39acf67adf41
Handle metrics of not visible paragraphs

The code is not ready for situations where some paragraphs that are
not visible have metrics available.

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.

NOTE: contrary to the code in master which returns npos = -10000, this
code still returns -1 when the position of a paragraph is unknown.

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