From ad76c66e338dfe4f9aae09429a30b205fe00e257 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Wed, 15 Dec 2010 07:12:42 +0000 Subject: [PATCH] #7120 the painter expects a float as line_thickness_, simplify initial computation of line_thickness_ and line_offset_ git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36890 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/rowpainter.cpp | 21 ++++++++++++--------- src/rowpainter.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index 27ea7b1b6b..c11dc3b0d9 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -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_); } diff --git a/src/rowpainter.h b/src/rowpainter.h index a1af41a106..1ea10d4849 100644 --- a/src/rowpainter.h +++ b/src/rowpainter.h @@ -104,7 +104,7 @@ private: int const yo_; // current baseline double x_; int width_; - int line_thickness_; + float line_thickness_; int line_offset_; }; -- 2.39.5