Code cleanup in RowPainter

* move some code that handle selection to paintInset()

* change the arguments of paintSeparator()
This commit is contained in:
Jean-Marc Lasgouttes 2015-07-16 23:10:44 +02:00
parent 0cbcc8a166
commit 1de0d2a19b
2 changed files with 13 additions and 12 deletions

View File

@ -116,6 +116,13 @@ int RowPainter::leftMargin() const
void RowPainter::paintInset(Inset const * inset, pos_type const pos) 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); Font const font = text_metrics_.displayFont(pit_, pos);
LASSERT(inset, return); LASSERT(inset, return);
@ -150,6 +157,7 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
pi_.full_repaint = pi_full_repaint; pi_.full_repaint = pi_full_repaint;
pi_.change_ = prev_change; pi_.change_ = prev_change;
pi_.do_spellcheck = pi_do_spellcheck; pi_.do_spellcheck = pi_do_spellcheck;
pi_.selected = pi_selected;
#ifdef DEBUG_METRICS #ifdef DEBUG_METRICS
int const x2 = x1 + dim.wid; 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, void RowPainter::paintSeparator(double width, Font const & font)
FontInfo const & font)
{ {
pi_.pain.textDecoration(font, int(orig_x), yo_, int(width)); pi_.pain.textDecoration(font.fontInfo(), int(x_), yo_, int(width));
x_ += width; x_ += width;
} }
@ -845,21 +852,14 @@ void RowPainter::paintText()
double separator_width = width_pos; double separator_width = width_pos;
if (pos >= body_pos) if (pos >= body_pos)
separator_width += row_.separator; separator_width += row_.separator;
paintSeparator(orig_x, separator_width, orig_font.fontInfo()); paintSeparator(separator_width, orig_font);
paintForeignMark(orig_x, orig_font.language()); paintForeignMark(orig_x, orig_font.language());
++vpos; ++vpos;
} else if (inset) { } else if (inset) {
// If outer row has changed, nested insets are repaint completely. // If outer row has changed, nested insets are repaint completely.
pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_); 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); paintInset(inset, pos);
pi_.selected = pi_selected;
++vpos; ++vpos;
} else { } else {

View File

@ -70,11 +70,12 @@ public:
void paintFirst() const; void paintFirst() const;
void paintLast(); void paintLast();
void paintText(); void paintText();
void paintText2();
void paintOnlyInsets(); void paintOnlyInsets();
void paintSelection() const; void paintSelection() const;
private: 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 paintForeignMark(double orig_x, Language const * lang, int desc = 0) const;
void paintStringAndSel(docstring const & str, Font const & font, void paintStringAndSel(docstring const & str, Font const & font,
Change const & change, Change const & change,