From 64af9accffd7216d2755ce5a72b66762770c70d4 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 3 Dec 2010 10:23:51 +0000 Subject: [PATCH] branch: Fix bug #4889: Painting problem with some insets. -RowPainter::paintOnlyInsets is only meant to paint nested Insets, so I guess only the InsetText? based insets. -Fix the painting of the labels of InsetCaption? insets. see r36630, r36639 and r36640. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@36679 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCaption.cpp | 13 ++++++++++++- src/insets/InsetCaption.h | 2 ++ src/rowpainter.cpp | 2 +- status.16x | 5 ++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 39c2cccbe0..9b4c08703c 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -31,6 +31,7 @@ #include "Paragraph.h" #include "paragraph_funcs.h" #include "TextClass.h" +#include "TextMetrics.h" #include "TocBackend.h" #include "frontends/FontMetrics.h" @@ -139,6 +140,15 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const } +void InsetCaption::drawBackground(PainterInfo & pi, int x, int y) const +{ + TextMetrics & tm = pi.base.bv->textMetrics(&text()); + int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET; + int const yy = y - TEXT_TO_INSET_OFFSET - tm.ascent(); + pi.pain.fillRectangle(x, yy, labelwidth_, h, pi.backgroundColor(this)); +} + + void InsetCaption::draw(PainterInfo & pi, int x, int y) const { // We must draw the label, we should get the label string @@ -151,7 +161,8 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const FontInfo tmpfont = pi.base.font; pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo(); - pi.pain.text(x, y, full_label_, pi.base.font); + int const xx = x + TEXT_TO_INSET_OFFSET; + pi.pain.text(xx, y, full_label_, pi.base.font); InsetText::draw(pi, x + labelwidth_, y); pi.base.font = tmpfont; } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index a03323572c..3ac3aa084a 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -50,6 +50,8 @@ private: bool descendable(BufferView const &) const { return true; } /// void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void drawBackground(PainterInfo & pi, int x, int y) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index 7daf79fad3..8cf2f8d221 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -686,7 +686,7 @@ void RowPainter::paintOnlyInsets() for (pos_type pos = row_.pos(); pos != end; ++pos) { // If outer row has changed, nested insets are repaint completely. Inset const * inset = par_.getInset(pos); - if (!inset) + if (!inset || !inset->asInsetText()) continue; if (x_ > pi_.base.bv->workWidth() || !cache.getInsets().has(inset)) diff --git a/status.16x b/status.16x index b40b351287..caaaf63054 100644 --- a/status.16x +++ b/status.16x @@ -90,8 +90,11 @@ What's new - Update the status of the button in the Text Style dialog when the cursor is moved (bug 6952). -- Correctly toggle the numbering of an equation when issuing the +- Correctly toggle the numbering of an equation when issuing the "Insert->Numbered equation" on a displayed equation (bug 6709). + +- Fix the painting of non-InsetText insets with a transparent + background as well as the description of an InsetCaption (bug 4889). * DOCUMENTATION AND LOCALIZATION