]> 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>
Tue, 19 Dec 2017 22:32:47 +0000 (23:32 +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.

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 06368ac4906c9c0976210ec3233ec516d0be0e53..b3d2e77ab8dbacf6d64ea40120cd71e5fd814c36 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 7f1b916702e033d42900dd1c37f5cc182a9aa3d5..2863b727fb76f9adba47d7c129516bc10bdd9267 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);