]> git.lyx.org Git - features.git/commitdiff
Aesthetics: off-by-one in line drawing
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 23 Jul 2018 15:07:48 +0000 (17:07 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 23 Jul 2018 15:16:03 +0000 (17:16 +0200)
It is a general problem when doing graphics to know where a line
begins and where it ends pixel-wise. At the instigation of Scott, and
with the use of the kmag magnifier, this commit corrects 3 areas:

* foreign marks were larger than the row element they were supposed to
  mark. This could lead to moving lines, depending on paint ordering.

* visible spaces were drawn outside of their box (select a single
  space to see this).

* the `L' blinking caret would leave a cursor dropping because the
  horizontal part was too wide.

src/RowPainter.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/insets/InsetSpace.cpp

index 16b144ebd42297c04e14d000aec1d2c914d1e4d0..efc4021c1b88f91da19f4d3241f336adc34a03ac 100644 (file)
@@ -159,7 +159,7 @@ void RowPainter::paintForeignMark(Row::Element const & e) const
        int const desc = e.inset ? e.dim.descent() : 0;
        int const y = yo_ + min(3 * pi_.base.solidLineOffset() / 2 + desc,
                                row_.descent() - 1);
-       pi_.pain.line(int(x_), y, int(x_ + e.full_width()), y, Color_language,
+       pi_.pain.line(int(x_), y, int(x_ + e.full_width() - 1), y, Color_language,
                      Painter::line_solid, pi_.base.solidLineThickness());
 }
 
index e6d993c2735ad8bd16eb43c394b7e91c51ee1c51..45c4469e61e13e7d0bce1872ddbdae53feddbbd9 100644 (file)
@@ -150,9 +150,9 @@ public:
                painter.setPen(color_);
                if (l_shape_) {
                        if (rtl_)
-                               painter.drawLine(x_, bot, x_ - l, bot);
+                               painter.drawLine(x_, bot, x_ - l + 1, bot);
                        else
-                               painter.drawLine(x_, bot, x_ + caret_width_ + r, bot);
+                               painter.drawLine(x_, bot, x_ + caret_width_ + r - 1, bot);
                }
 
                // draw completion triangle
index fd8c261d2e649c621c2bc3a043bbf55a7bd6d426..ddb85b71ea6b4ca69d69a50f06383fc7400a4599 100644 (file)
@@ -355,18 +355,18 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
        int const h = theFontMetrics(pi.base.font).xHeight();
        int xp[4], yp[4];
 
-       xp[0] = x;
+       xp[0] = x + 1;
        yp[0] = y - max(h / 4, 1);
        if (params_.kind == InsetSpaceParams::NORMAL ||
            params_.kind == InsetSpaceParams::PROTECTED ||
            params_.kind == InsetSpaceParams::VISIBLE) {
-               xp[1] = x;     yp[1] = y;
-               xp[2] = x + w; yp[2] = y;
+               xp[1] = x + 1;     yp[1] = y;
+               xp[2] = x + w - 2; yp[2] = y;
        } else {
-               xp[1] = x;     yp[1] = y + max(h / 4, 1);
-               xp[2] = x + w; yp[2] = y + max(h / 4, 1);
+               xp[1] = x + 1;     yp[1] = y + max(h / 4, 1);
+               xp[2] = x + w - 2; yp[2] = y + max(h / 4, 1);
        }
-       xp[3] = x + w;
+       xp[3] = x + w - 2;
        yp[3] = y - max(h / 4, 1);
 
        Color col = Color_special;