mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Painter: Add a line style to disable antialiasing
It is not possible to use opacity effects (such as drawing an antialiased line to strike diagonally through an inset), until the painter is fixed so that it does not redraw repeatedly over the same spot (otherwise, the usual aritfacs appear). For now, pixellated lines are OK.
This commit is contained in:
parent
4089ff1ec3
commit
28f6c312a9
@ -556,9 +556,9 @@ void Change::paintCue(PainterInfo & pi, double const x1, double const y,
|
||||
return;
|
||||
// Calculate 1/3 height of font
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
int const y_bar = int(deleted() ? y - fm.maxAscent() / 3
|
||||
: y + 2 * pi.base.solidLineOffset() + pi.base.solidLineThickness());
|
||||
pi.pain.line(int(x1), y_bar, int(x2), y_bar, color(),
|
||||
double const y_bar = deleted() ? y - fm.maxAscent() / 3
|
||||
: y + 2 * pi.base.solidLineOffset() + pi.base.solidLineThickness();
|
||||
pi.pain.line(int(x1), int(y_bar), int(x2), int(y_bar), color(),
|
||||
Painter::line_solid, pi.base.solidLineThickness());
|
||||
}
|
||||
|
||||
@ -586,8 +586,9 @@ void Change::paintCue(PainterInfo & pi, double const x1, double const y1,
|
||||
y = y1;
|
||||
break;
|
||||
}
|
||||
pi.pain.line(int(x1), int(y2), int(x2), int(y),
|
||||
color(), Painter::line_solid,
|
||||
// we cannot use antialias since we keep drawing on the same background
|
||||
pi.pain.line(int(x1), int(y2), int(x2), int(y),
|
||||
color(), Painter::line_solid_aliased,
|
||||
pi.base.solidLineThickness());
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
/// possible line styles
|
||||
enum line_style {
|
||||
line_solid, //< solid line
|
||||
line_solid_aliased, //< solid line, no anti-aliasing (used as a
|
||||
// workaround to painting issues)
|
||||
line_onoffdash //< dashes with spaces
|
||||
};
|
||||
|
||||
|
@ -82,8 +82,11 @@ void GuiPainter::setQPainterPen(QColor const & col,
|
||||
pen.setColor(col);
|
||||
|
||||
switch (ls) {
|
||||
case line_solid: pen.setStyle(Qt::SolidLine); break;
|
||||
case line_onoffdash: pen.setStyle(Qt::DotLine); break;
|
||||
case line_solid:
|
||||
case line_solid_aliased:
|
||||
pen.setStyle(Qt::SolidLine); break;
|
||||
case line_onoffdash:
|
||||
pen.setStyle(Qt::DotLine); break;
|
||||
}
|
||||
|
||||
pen.setWidth(lw);
|
||||
@ -188,7 +191,7 @@ void GuiPainter::line(int x1, int y1, int x2, int y2,
|
||||
|
||||
setQPainterPen(computeColor(col), ls, lw);
|
||||
bool const do_antialiasing = renderHints() & TextAntialiasing
|
||||
&& x1 != x2 && y1 != y2;
|
||||
&& x1 != x2 && y1 != y2 && ls != line_solid_aliased;
|
||||
setRenderHint(Antialiasing, do_antialiasing);
|
||||
drawLine(x1, y1, x2, y2);
|
||||
setRenderHint(Antialiasing, false);
|
||||
@ -210,7 +213,7 @@ void GuiPainter::lines(int const * xp, int const * yp, int np,
|
||||
if (np > points.size())
|
||||
points.resize(2 * np);
|
||||
|
||||
bool antialias = false;
|
||||
bool antialias = ls != line_solid_aliased;
|
||||
for (int i = 0; i < np; ++i) {
|
||||
points[i].setX(xp[i]);
|
||||
points[i].setY(yp[i]);
|
||||
@ -261,7 +264,7 @@ void GuiPainter::path(int const * xp, int const * yp,
|
||||
QColor const color = computeColor(col);
|
||||
setQPainterPen(color, ls, lw);
|
||||
bool const text_is_antialiased = renderHints() & TextAntialiasing;
|
||||
setRenderHint(Antialiasing, text_is_antialiased);
|
||||
setRenderHint(Antialiasing, text_is_antialiased && ls != line_solid_aliased);
|
||||
drawPath(bpath);
|
||||
if (fs != fill_none)
|
||||
fillPath(bpath, QBrush(color));
|
||||
|
Loading…
Reference in New Issue
Block a user