]> git.lyx.org Git - lyx.git/commitdiff
Avoid bleeding of inset background outside of inset
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 24 Mar 2020 11:01:43 +0000 (12:01 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 3 Apr 2020 17:02:29 +0000 (19:02 +0200)
As a consequence of fix e64ea357 to ticket #10797, we draw a bit too
much of the inset background outside of the inset (visible for insets
with colored background). #10797 is a ticket that triggers when the
cursor has a width larger than 1.

This patch limits the problems in two respects

* nothing is done on the left, since the cursor width only expands on
  the right.

* on the right, the extra width is limited to cursor width.

Fixes bug #11786.

(cherry picked from commit eb92f74d1f7ae63112b9439058d746f7ff93e8f4)

src/TextMetrics.cpp
status.23x

index 070a880e62d7c60fe9aa4415004bd55e6be968e1..91a173a3a5c146277148aecf22c398a803142f71 100644 (file)
@@ -1919,15 +1919,15 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                        LYXERR(Debug::PAINTING, "Clear rect@("
                               << max(row_x, 0) << ", " << y - row.ascent() << ")="
                               << width() << " x " << row.height());
-                       // FIXME: this is a hack. We know that at least this
-                       // amount of pixels can be cleared on right and left.
-                       // Doing so gets rid of caret ghosts when the cursor is at
-                       // the begining/end of row. However, it will not work if
-                       // the caret has a ridiculous width like 6. (see ticket
-                       // #10797)
-                       pi.pain.fillRectangle(max(row_x, 0) - Inset::TEXT_TO_INSET_OFFSET,
-                                             y - row.ascent(),
-                                             width() + 2 * Inset::TEXT_TO_INSET_OFFSET,
+                       // FIXME: this is a hack. We clear an amount equal to
+                       // cursor width. This will not work if the caret has a
+                       // ridiculous width like 6. (see ticket #10797)
+                       // This is the same formula as in GuiWorkArea.
+                       int const caret_width = lyxrc.cursor_width
+                               ? lyxrc.cursor_width
+                               : 1 + int((lyxrc.currentZoom + 50) / 200.0);
+                       pi.pain.fillRectangle(max(row_x, 0), y - row.ascent(),
+                                             width() + caret_width,
                                              row.height(), pi.background_color);
                }
 
index 8a695f8b121ab538be51cf0270c80c03a22eac33..050d93bdc16b1b9db85f8e83ee1957f5220259d8 100644 (file)
@@ -86,6 +86,8 @@ What's new
 
 - Add copy, paste, etc, to math context menu (but 11799).
 
+- Avoid bleeding of inset background outside of inset (bug 11786).
+
 
 * INTERNALS