Remove PainterInfo argument to checkCursorScrollOffset

This will allow later to move its invokation to processUpdateFlags.

Also, remove wrong use of Update::SinglePar flag.
This commit is contained in:
Jean-Marc Lasgouttes 2015-10-05 18:04:12 +02:00
parent d377e765a2
commit f6c6416f28
3 changed files with 8 additions and 8 deletions

View File

@ -2970,7 +2970,7 @@ void BufferView::setCurrentRowSlice(CursorSlice const & rowSlice)
} }
void BufferView::checkCursorScrollOffset(PainterInfo & pi) void BufferView::checkCursorScrollOffset()
{ {
CursorSlice rowSlice = d->cursor_.bottom(); CursorSlice rowSlice = d->cursor_.bottom();
TextMetrics const & tm = textMetrics(rowSlice.text()); TextMetrics const & tm = textMetrics(rowSlice.text());
@ -2981,8 +2981,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
return; return;
ParagraphMetrics const & pm = tm.parMetrics(rowSlice.pit()); ParagraphMetrics const & pm = tm.parMetrics(rowSlice.pit());
Row const & row = pm.getRow(rowSlice.pos(), Row const & row = pm.getRow(rowSlice.pos(),
d->cursor_.boundary() d->cursor_.boundary() && rowSlice == d->cursor_.top());
&& rowSlice == d->cursor_.top());
rowSlice.pos() = row.pos(); rowSlice.pos() = row.pos();
// Set the row on which the cursor lives. // Set the row on which the cursor lives.
@ -2993,7 +2992,8 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
// Horizontal scroll offset of the cursor row in pixels // Horizontal scroll offset of the cursor row in pixels
int offset = d->horiz_scroll_offset_; int offset = d->horiz_scroll_offset_;
int const MARGIN = Length(2, Length::EM).inPixels(pi.base); int const MARGIN = 2 * theFontMetrics(d->cursor_.real_current_font).em();
//lyxerr << "cur_x=" << cur_x << ", offset=" << offset << ", margin=" << MARGIN << endl;
if (cur_x < offset + MARGIN) { if (cur_x < offset + MARGIN) {
// scroll right // scroll right
offset = cur_x - MARGIN; offset = cur_x - MARGIN;
@ -3034,7 +3034,7 @@ void BufferView::draw(frontend::Painter & pain)
// Check whether the row where the cursor lives needs to be scrolled. // Check whether the row where the cursor lives needs to be scrolled.
// Update the drawing strategy if needed. // Update the drawing strategy if needed.
checkCursorScrollOffset(pi); checkCursorScrollOffset();
switch (d->update_strategy_) { switch (d->update_strategy_) {

View File

@ -349,7 +349,7 @@ private:
// Check whether the row where the cursor lives needs to be scrolled. // Check whether the row where the cursor lives needs to be scrolled.
// Update the drawing strategy if needed. // Update the drawing strategy if needed.
void checkCursorScrollOffset(PainterInfo & pi); void checkCursorScrollOffset();
/// The minimal size of the document that is visible. Used /// The minimal size of the document that is visible. Used
/// when it is allowed to scroll below the document. /// when it is allowed to scroll below the document.

View File

@ -1614,7 +1614,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case mouse_button::button1: case mouse_button::button1:
// Set the cursor // Set the cursor
if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select")) if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor); cur.screenUpdateFlags(Update::FitCursor);
if (bvcur.wordSelection()) if (bvcur.wordSelection())
selectWord(bvcur, WHOLE_WORD); selectWord(bvcur, WHOLE_WORD);
break; break;
@ -1639,7 +1639,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
return; return;
} }
if (!bv->mouseSetCursor(cur, false)) if (!bv->mouseSetCursor(cur, false))
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor); cur.screenUpdateFlags(Update::FitCursor);
break; break;
} }