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)
}
-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);
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
}
+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);
}
InsetMathGrid::draw(pi, xmath + 1, y);
- drawMarkers2(pi, x, y);
+ drawMarkers(pi, x, y);
if (numberedType()) {
Changer dummy = pi.base.changeFontSet("mathrm");
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_;
#include "MathSupport.h"
#include "BufferView.h"
+#include "ColorSet.h"
#include "CoordCache.h"
#include "MetricsInfo.h"
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);
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);