]> git.lyx.org Git - lyx.git/commitdiff
#7120 the painter expects a float as line_thickness_, simplify initial computation...
authorStephan Witt <switt@lyx.org>
Wed, 15 Dec 2010 07:12:42 +0000 (07:12 +0000)
committerStephan Witt <switt@lyx.org>
Wed, 15 Dec 2010 07:12:42 +0000 (07:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36890 a592a061-630c-0410-9148-cb99ea01b6c8

src/rowpainter.cpp
src/rowpainter.h

index 27ea7b1b6bb06fda25f2c69a16213672eaaba46b..c11dc3b0d90d6963aba792df609ab20472cc6a46 100644 (file)
@@ -60,16 +60,19 @@ RowPainter::RowPainter(PainterInfo & pi,
          row_(row), pit_(pit), par_(text.paragraphs()[pit]),
          pm_(text_metrics_.parMetrics(pit)),
          bidi_(bidi), change_(pi_.change_),
-         xo_(x), yo_(y), width_(text_metrics_.width())
+         xo_(x), yo_(y), width_(text_metrics_.width()),
+         line_thickness_(1.0), line_offset_(2)
 {
-       // derive the line thickness from zoom factor
-       // the zoom is given in percent
-       double const scale_ = lyxrc.zoom / 100.0;
-
        bidi_.computeTables(par_, pi_.base.bv->buffer(), row_);
-       // (increase thickness at 150%, 250% etc.)
-       line_thickness_ = scale_ < 1.0 ? 1.0 : int(scale_ + 0.5);
-       line_offset_ = int(1.5 * line_thickness_) + (scale_ < 1.0 ? 1 : 2);
+
+       if (lyxrc.zoom >= 100) {
+               // derive the line thickness from zoom factor
+               // the zoom is given in percent
+               // (increase thickness at 150%, 250% etc.)
+               line_thickness_ = (float)(int((lyxrc.zoom + 50) / 100.0));
+               // adjust line_offset_ too
+               line_offset_ = int(2 * line_thickness_) + 1;
+       }
 
        x_ = row_.x + xo_;
 
@@ -367,7 +370,7 @@ void RowPainter::paintMisspelledMark(double orig_x, bool changed)
 {
        // if changed the misspelled marker gets placed slightly lower than normal
        // to avoid drawing at the same vertical offset
-       int const y = yo_ + (changed ? line_thickness_ + 1 : 0) + line_offset_;
+       int const y = yo_ + (changed ? int(line_thickness_ + 1.0) : 0) + line_offset_;
        pi_.pain.line(int(orig_x), y, int(x_), y, Color_error,
                Painter::line_onoffdash, line_thickness_);
 }
index a1af41a106d2020e5a0b8c07426ac07fed722d2a..1ea10d48496da610023e3977524179de73ce642a 100644 (file)
@@ -104,7 +104,7 @@ private:
        int const yo_;    // current baseline
        double x_;
        int width_;
-       int line_thickness_;
+       float line_thickness_;
        int line_offset_;
 };