]> git.lyx.org Git - features.git/commitdiff
Do not draw inactive math corners when they have mathbg color
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 Dec 2017 21:32:32 +0000 (22:32 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 23 Dec 2017 18:53:58 +0000 (19:53 +0100)
By default, inactive math corners are invisible. In practice they are
annoying because they are visible when selecting text, and they can
also overwrite some parts of the equation.

The code in Inset::drawMarkers2, which is only used for maths, is
moved to InsetMathHull. Moreover, the inactive corners are not drawn
when they have the same color as the math background. A better way to
achieve this would be to set the color to transparent, but we do not
support this yet.

(cherry picked from commit 68614e9783382b6267fc9ce32ed45bc2477007dd)

src/insets/Inset.cpp
src/insets/Inset.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h
src/mathed/MathRow.cpp

index f2e2d4bcb88e5d197730d29f39f08cfdd5ea3fb2..0257ed0c45f1c56dad489b94ccbda9811dc89e2d 100644 (file)
@@ -553,22 +553,6 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
 }
 
 
-void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
-{
-       ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
-               Color_mathframe : Color_mathcorners;
-
-       drawMarkers(pi, x, y);
-       Dimension const dim = dimension(*pi.base.bv);
-       int const t = x + dim.width() - 1;
-       int const a = y - dim.ascent();
-       pi.pain.line(x, a + 3, x, a, pen_color);
-       pi.pain.line(t, a + 3, t, a, pen_color);
-       pi.pain.line(x, a, x + 3, a, pen_color);
-       pi.pain.line(t - 3, a, t, a, pen_color);
-}
-
-
 bool Inset::editing(BufferView const * bv) const
 {
        return bv->cursor().isInside(this);
index 94e9d1a6687a31ccc17266374719ed641887a402..5a7b32e8d65ea6b919c71abd1408e4f24ebc0923 100644 (file)
@@ -210,9 +210,7 @@ public:
        virtual bool showInsetDialog(BufferView *) const;
 
        /// draw two angular markers
-       void drawMarkers(PainterInfo & pi, int x, int y) const;
-       /// draw four angular markers
-       void drawMarkers2(PainterInfo & pi, int x, int y) const;
+       virtual void drawMarkers(PainterInfo & pi, int x, int y) const;
        /// add space for markers
        void metricsMarkers(Dimension & dim, int framesize = 1) const;
        /// add space for markers
index 78175f3f70d524f1145829c77afc17dbe2f07e05..4e29d4ce242e75466f8eb9067b6313cce92031c5 100644 (file)
@@ -599,6 +599,25 @@ ColorCode InsetMathHull::backgroundColor(PainterInfo const & pi) const
 }
 
 
+void InsetMathHull::drawMarkers(PainterInfo & pi, int x, int y) const
+{
+       ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
+               Color_mathframe : Color_mathcorners;
+       // If the corners have the same color as the background, do not paint them.
+       if (lcolor.getX11Name(Color_mathbg) == lcolor.getX11Name(pen_color))
+               return;
+
+       Inset::drawMarkers(pi, x, y);
+       Dimension const dim = dimension(*pi.base.bv);
+       int const t = x + dim.width() - 1;
+       int const a = y - dim.ascent();
+       pi.pain.line(x, a + 3, x, a, pen_color);
+       pi.pain.line(t, a + 3, t, a, pen_color);
+       pi.pain.line(x, a, x + 3, a, pen_color);
+       pi.pain.line(t - 3, a, t, a, pen_color);
+}
+
+
 void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
 {
        Dimension const dim = dimension(*pi.base.bv);
@@ -659,7 +678,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
        }
 
        InsetMathGrid::draw(pi, xmath + 1, y);
-       drawMarkers2(pi, x, y);
+       drawMarkers(pi, x, y);
 
        if (numberedType()) {
                Changer dummy = pi.base.changeFontSet("mathrm");
index 183b851ba515450114ae5c6396e1c148fce1c434..6f9f90873ceb8f435877d882a2dd10f807073010 100644 (file)
@@ -260,6 +260,8 @@ private:
        bool colChangeOK() const;
        /// are any of the equations numbered?
        bool haveNumbers() const;
+       /// draw four angular markers
+       virtual void drawMarkers(PainterInfo & pi, int x, int y) const;
 
        /// "none", "simple", "display", "eqnarray",...
        HullType type_;
index 71e7a5234aeb652b214f3cb6b0d3bac9d7101940..345962096f121aff04bd1e5748ebc992e4127e08 100644 (file)
@@ -18,6 +18,7 @@
 #include "MathSupport.h"
 
 #include "BufferView.h"
+#include "ColorSet.h"
 #include "CoordCache.h"
 #include "MetricsInfo.h"
 
@@ -97,11 +98,6 @@ void drawMarkers(PainterInfo const & pi, MathRow::Element const & e,
        if (e.marker == InsetMath::NO_MARKER)
                return;
 
-       // The color
-       bool const highlight = e.inset->mouseHovered(pi.base.bv)
-                              || e.inset->editing(pi.base.bv);
-       ColorCode const pen_color = highlight ? Color_mathframe : Color_mathcorners;
-
        CoordCache const & coords = pi.base.bv->coordCache();
        Dimension const dim = coords.getInsets().dim(e.inset);
 
@@ -122,6 +118,14 @@ void drawMarkers(PainterInfo const & pi, MathRow::Element const & e,
                pi.pain.text(l, y + dim.des - namedim.des - 1, e.inset->name(), font);
        }
 
+       // Color for corners
+       bool const highlight = e.inset->mouseHovered(pi.base.bv)
+                              || e.inset->editing(pi.base.bv);
+       ColorCode const pen_color = highlight ? Color_mathframe : Color_mathcorners;
+       // If the corners have the same color as the background, do not paint them.
+       if (lcolor.getX11Name(Color_mathbg) == lcolor.getX11Name(pen_color))
+               return;
+
        // Lower corners in all cases
        int const d = y + dim.descent();
        pi.pain.line(l, d - 3, l, d, pen_color);