]> git.lyx.org Git - features.git/commitdiff
Code cleanup in RowPainter
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 16 Jul 2015 21:10:44 +0000 (23:10 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 16 Jul 2015 21:24:28 +0000 (23:24 +0200)
* move some code that handle selection to paintInset()

* change the arguments of paintSeparator()

src/RowPainter.cpp
src/RowPainter.h

index 70c32aa9b7d14725504f42e7001a8a06887e57c6..2545362356967e46830ff3f150ee9d3729c8ae0d 100644 (file)
@@ -116,6 +116,13 @@ int RowPainter::leftMargin() const
 
 void RowPainter::paintInset(Inset const * inset, pos_type const pos)
 {
+       // Handle selection
+       bool const pi_selected = pi_.selected;
+       Cursor const & cur = pi_.base.bv->cursor();
+       if (cur.selection() && cur.text() == &text_
+               && cur.normalAnchor().text() == &text_)
+               pi_.selected = row_.sel_beg <= pos && row_.sel_end > pos;
+
        Font const font = text_metrics_.displayFont(pit_, pos);
 
        LASSERT(inset, return);
@@ -150,6 +157,7 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
        pi_.full_repaint = pi_full_repaint;
        pi_.change_ = prev_change;
        pi_.do_spellcheck = pi_do_spellcheck;
+       pi_.selected = pi_selected;
 
 #ifdef DEBUG_METRICS
        int const x2 = x1 + dim.wid;
@@ -163,10 +171,9 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
 }
 
 
-void RowPainter::paintSeparator(double orig_x, double width,
-       FontInfo const & font)
+void RowPainter::paintSeparator(double width, Font const & font)
 {
-       pi_.pain.textDecoration(font, int(orig_x), yo_, int(width));
+       pi_.pain.textDecoration(font.fontInfo(), int(x_), yo_, int(width));
        x_ += width;
 }
 
@@ -845,21 +852,14 @@ void RowPainter::paintText()
                        double separator_width = width_pos;
                        if (pos >= body_pos)
                                separator_width += row_.separator;
-                       paintSeparator(orig_x, separator_width, orig_font.fontInfo());
+                       paintSeparator(separator_width, orig_font);
                        paintForeignMark(orig_x, orig_font.language());
                        ++vpos;
 
                } else if (inset) {
                        // If outer row has changed, nested insets are repaint completely.
                        pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_);
-
-                       bool const pi_selected = pi_.selected;
-                       Cursor const & cur = pi_.base.bv->cursor();
-                       if (cur.selection() && cur.text() == &text_
-                                 && cur.normalAnchor().text() == &text_)
-                               pi_.selected = row_.sel_beg <= pos && row_.sel_end > pos;
                        paintInset(inset, pos);
-                       pi_.selected = pi_selected;
                        ++vpos;
 
                } else {
index 95c64269e55a38edc4e3d33b1d3c1d4c370bacbd..f3dc1adff8f53b9f38db93238cd03fed324b1b4f 100644 (file)
@@ -70,11 +70,12 @@ public:
        void paintFirst() const;
        void paintLast();
        void paintText();
+       void paintText2();
        void paintOnlyInsets();
        void paintSelection() const;
 
 private:
-       void paintSeparator(double orig_x, double width, FontInfo const & font);
+       void paintSeparator(double width, Font const & font);
        void paintForeignMark(double orig_x, Language const * lang, int desc = 0) const;
        void paintStringAndSel(docstring const & str, Font const & font,
                          Change const & change,