mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Do not draw inactive math corners when they have mathbg color
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.
This commit is contained in:
parent
634f69ee23
commit
68614e9783
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
@ -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_;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user