Am 30.11.2010 um 17:33 schrieb Pavel Sanda:

> Liviu Andronic wrote:
>> I would suspect that a wavy line might be more desirable (as in MS
>> Word, gtkspell, OOo, etc.), and if I remember this was the original
>> implementation (although then the wavy line was too big :) ).
> 
> so we are at circles, since the wavy line was killed not so long ago :)
> not that i have opinion about this issue.

To break the circle I propose to adjust the line thickness to zoom factor.
The attached patch does this. I think it's better now.
The problem is the somewhat obfuscated rowpainter code. 
This makes the patch hard to read, sorry.

Perhaps some kind soul is able to apply and test it?

Stephan

Index: src/rowpainter.cpp
===================================================================
--- src/rowpainter.cpp  (Revision 36657)
+++ src/rowpainter.cpp  (Arbeitskopie)
@@ -63,6 +63,15 @@
          xo_(x), yo_(y), width_(text_metrics_.width())
 {
        bidi_.computeTables(par_, pi_.base.bv->buffer(), row_);
+       // derive the line thickness from zoom factor
+       // the zoom is given in percent
+       scale_ = lyxrc.zoom / 100.0;
+       // (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);
+
+       // adjust left margin to zoom too
+       // xo_ += 4 * scale;
        x_ = row_.x + xo_;
 
        //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ 
<< endl;
@@ -349,20 +358,19 @@
        if (lang == pi_.base.bv->buffer().params().language)
                return;
 
-       int const y = yo_ + 1 + desc;
-       pi_.pain.line(int(orig_x), y, int(x_), y, Color_language);
+       int const y = yo_ + 1 + desc + int(line_thickness_/2);
+       pi_.pain.line(int(orig_x), y, int(x_), y, Color_language,
+               Painter::line_solid, line_thickness_);
 }
 
 
-void RowPainter::paintMisspelledMark(double orig_x, int desc, bool changed)
+void RowPainter::paintMisspelledMark(double orig_x, bool changed)
 {
-       // derive the offset from zoom factor specified by user in percent
        // if changed the misspelled marker gets placed slightly lower than 
normal
        // to avoid drawing at the same vertical offset
-       int const offset = int(1.5 * lyxrc.zoom / 100.0); // [percent]
-       int const y = yo_ + desc + (changed ? offset : 0) + 1;
+       int const y = yo_ + (changed ? line_thickness_ + 1 : 0) + line_offset_;
        pi_.pain.line(int(orig_x), y, int(x_), y, Color_misspelled,
-               Painter::line_onoffdash, 2.0);
+               Painter::line_onoffdash, line_thickness_);
 }
 
 
@@ -399,7 +407,7 @@
        paintForeignMark(orig_x, orig_font.language());
 
        if (lyxrc.spellcheck_continuously && misspelled_) {
-               paintMisspelledMark(orig_x, 2, changed);
+               paintMisspelledMark(orig_x, changed);
        }
 }
 
@@ -854,9 +862,9 @@
                        FontMetrics const & fm
                                = 
theFontMetrics(pi_.base.bv->buffer().params().getFont());
                        int const y_bar = change_running.deleted() ?
-                               yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() 
/ 6;
+                               yo_ - fm.maxAscent() / 3 : yo_ + line_offset_;
                        pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
-                               change_running.color(), Painter::line_solid, 
0.5);
+                               change_running.color(), Painter::line_solid, 
line_thickness_);
 
                        // Change might continue with a different author or type
                        if (change.changed() && !highly_editable_inset) {
@@ -914,9 +922,9 @@
                FontMetrics const & fm
                        = 
theFontMetrics(pi_.base.bv->buffer().params().getFont());
                int const y_bar = change_running.deleted() ?
-                               yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() 
/ 6;
+                               yo_ - fm.maxAscent() / 3 : yo_ + line_offset_;
                pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
-                       change_running.color(), Painter::line_solid, 0.5);
+                       change_running.color(), Painter::line_solid, 
line_thickness_);
                change_running.setUnchanged();
        }
 }
Index: src/rowpainter.h
===================================================================
--- src/rowpainter.h    (Revision 36657)
+++ src/rowpainter.h    (Arbeitskopie)
@@ -59,7 +59,7 @@
 
 private:
        void paintForeignMark(double orig_x, Language const * lang, int desc = 
0);
-       void paintMisspelledMark(double orig_x, int desc, bool changed);
+       void paintMisspelledMark(double orig_x, bool changed);
        void paintHebrewComposeChar(pos_type & vpos, FontInfo const & font);
        void paintArabicComposeChar(pos_type & vpos, FontInfo const & font);
        void paintChars(pos_type & vpos, FontInfo const & font,
@@ -68,7 +68,7 @@
        void paintFromPos(pos_type & vpos, bool changed);
        void paintInset(Inset const * inset, pos_type const pos);
        void paintInlineCompletion(Font const & font);
-       
+
        /// return left margin
        int leftMargin() const;
 
@@ -104,6 +104,9 @@
        int const yo_;    // current baseline
        double x_;
        int width_;
+       double scale_;
+       int line_thickness_;
+       int line_offset_;
 };
 
 } // namespace lyx

Reply via email to