]> git.lyx.org Git - features.git/commitdiff
A more radical approach to inset background painting
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Aug 2016 09:21:38 +0000 (11:21 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Aug 2016 10:05:00 +0000 (12:05 +0200)
Now by default all insets paint their own background when needed. This
means that 63cf3297 and part of 9940acc5 can be reverted.

To avoid extra painting, background drawing is disabled for
InsetCommand and InsetCollapsable. These insets draw background as
part of their normal drawing activity.

This will avoid drawing artifacts with InsetNewpage, InsetVSpace and
probably some others.

src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetCollapsable.h
src/insets/InsetCommand.h
src/insets/InsetQuotes.cpp
src/insets/InsetQuotes.h
src/insets/InsetSpecialChar.cpp
src/insets/InsetSpecialChar.h
src/mathed/MathMacroTemplate.cpp
src/mathed/MathMacroTemplate.h

index c7d3f9654fe4bb81e96f746b71b50ea4479732e3..6e2e4a0ae23558b8ab9ca21b4dad0a5ec014cfbe 100644 (file)
@@ -520,6 +520,16 @@ void Inset::metricsMarkers2(Dimension & dim, int framesize) const
 }
 
 
+void Inset::drawBackground(PainterInfo & pi, int x, int y) const
+{
+       if (pi.full_repaint && backgroundColor(pi) == Color_none)
+               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 Inset::drawMarkers(PainterInfo & pi, int x, int y) const
 {
        ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
index bb6323a45447a999fc0e2a0b43ffd829cb4df1e0..48ad7be9a5529bcee3271ebebf29ecc1af3bafc6 100644 (file)
@@ -190,7 +190,7 @@ public:
        virtual void drawSelection(PainterInfo &, int, int) const {}
        /// draw inset background if the inset has an own background and a
        /// selection is drawn by drawSelection.
-       virtual void drawBackground(PainterInfo &, int, int) const {}
+       virtual void drawBackground(PainterInfo &, int, int) const;
        ///
        virtual bool editing(BufferView const * bv) const;
        ///
index 35f6e8b530e21b077b9aa28ae6770dbc86618e70..c7b6d65c3a4f193454ba8bc1dcd73d3a9d4ae19c 100644 (file)
@@ -54,6 +54,8 @@ public:
        void metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       virtual void drawBackground(PainterInfo &, int, int) const {}
 
        /// return x,y of given position relative to the inset's baseline
        void cursorPos(BufferView const & bv, CursorSlice const & sl,
index 39b1cbbef36ae745633b307033de70cd3d192e85..8260ab3ed6aca08c25166807712b13c2b5ad168f 100644 (file)
@@ -78,6 +78,8 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
+       virtual void drawBackground(PainterInfo &, int, int) const {}
+       ///
        void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstringstream & ods, OutputParams const & op,
index c4affc15158fff5c96d5352b8dcc978c1e96db03..1a6c925bf7cd9fcd478f5844553ae27ebc9a0fce 100644 (file)
@@ -211,16 +211,6 @@ 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;
index ba3ed994ddfa79fb97e24aaa649ee231bfaeeddd..fec7fbca2349c600c1bf1360c8e5b739646a01d3 100644 (file)
@@ -70,8 +70,6 @@ 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;
index 6554cce16e552078a3ad0d01bde208333c01a01f..3d32f406ea1bc812ac8553c303e8eeb6000c22af 100644 (file)
@@ -134,16 +134,6 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
-void InsetSpecialChar::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));
-}
-
-
 namespace {
 
 // helper function: draw text and update x.
index c37e49880b9ab7eae4f2e69779d5de771cc6c5fa..ebdfb1a6e4f42754be5c731d5d19114d3744d41e 100644 (file)
@@ -61,8 +61,6 @@ 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;
index 5b2a016c63ad2f62bcb411aae3dfc7417a765253..31250e29df547156c91d650e72659e832fe95ad9 100644 (file)
@@ -583,17 +583,6 @@ 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.
index dbcce5d410c57252309e8b6eb3dba51e4879ea6c..b0c301897761a0caeb9124c91270386b960875a9 100644 (file)
@@ -92,8 +92,6 @@ 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; }