commit 9940acc5063d17f18f50c690085c7d97f25d909d
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Wed Jul 20 00:12:21 2016 +0200

    Try to fix #4889 in the right way
    
    For reference, the bug was that quote insets grew bolder because, when
    painted over themselves, anti-aliasing made them darker.
    
    It turned out that the fix there created others than were
    painstakingly fixed: #7164, #7165, #7174, #7193... More recently, it
    created other problems:
    http://article.gmane.org/gmane.editors.lyx.devel/163471
    
    We use the right fix here:
    * draw background of quote inset when not doing full repaint
    * draw background of math macro template when not doing full repaint
    * remove hack that grew from #4889 fix.
---
 src/RowPainter.cpp               |    9 +--------
 src/insets/InsetQuotes.cpp       |   10 ++++++++++
 src/insets/InsetQuotes.h         |    2 ++
 src/mathed/MathMacroTemplate.cpp |   11 +++++++++++
 src/mathed/MathMacroTemplate.h   |    2 ++
 5 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 1c48b5b..08ac66d 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -550,15 +550,8 @@ void RowPainter::paintOnlyInsets()
        Row::const_iterator const & end = row_.end();
        for ( ; cit != end ; ++cit) {
                Row::Element const & e = *cit;
-               if (e.type == Row::INSET) {
-                       // If outer row has changed, nested insets are 
repainted completely.
-                       // FIXME: check what this really does. The test is 
weird.
-                       bool const nested_inset =
-                               (e.inset->asInsetMath() && 
!e.inset->asInsetMath()->asMacroTemplate())
-                               || e.inset->asInsetText() || 
e.inset->asInsetTabular();
-                       if (nested_inset)
+               if (e.type == Row::INSET)
                                paintInset(e);
-               }
                x_ += e.full_width();
        }
 }
diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp
index 1a6c925..c4affc1 100644
--- a/src/insets/InsetQuotes.cpp
+++ b/src/insets/InsetQuotes.cpp
@@ -211,6 +211,16 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & 
dim) const
 }
 
 
+void InsetQuotes::drawBackground(PainterInfo & pi, int x, int y) const
+{
+       if (pi.full_repaint)
+               return;
+       Dimension const dim = dimension(*pi.base.bv);
+       pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
+                             pi.backgroundColor(this));
+}
+
+
 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
 {
        FontInfo font = pi.base.font;
diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h
index fec7fbc..ba3ed99 100644
--- a/src/insets/InsetQuotes.h
+++ b/src/insets/InsetQuotes.h
@@ -70,6 +70,8 @@ public:
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
+       void drawBackground(PainterInfo & pi, int x, int y) const;
+       ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
        void write(std::ostream &) const;
diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp
index 31250e2..5b2a016 100644
--- a/src/mathed/MathMacroTemplate.cpp
+++ b/src/mathed/MathMacroTemplate.cpp
@@ -583,6 +583,17 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, 
Dimension & dim) const
 }
 
 
+void MathMacroTemplate::drawBackground(PainterInfo & pi, int x, int y) const
+{
+       if (pi.full_repaint)
+               return;
+       Dimension const dim = dimension(*pi.base.bv);
+       pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
+                             pi.backgroundColor(this));
+}
+
+
+
 void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const
 {
        // FIXME: Calling Changer on the same object repeatedly is inefficient.
diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h
index b0c3018..dbcce5d 100644
--- a/src/mathed/MathMacroTemplate.h
+++ b/src/mathed/MathMacroTemplate.h
@@ -92,6 +92,8 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
+       void drawBackground(PainterInfo & pi, int x, int y) const;
+       ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        /// identifies macro templates
        MathMacroTemplate * asMacroTemplate() { return this; }

Reply via email to