]> git.lyx.org Git - features.git/commitdiff
Remove PainterInfo argument to checkCursorScrollOffset
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Oct 2015 16:04:12 +0000 (18:04 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Oct 2015 16:09:34 +0000 (18:09 +0200)
This will allow later to move its invokation to processUpdateFlags.

Also, remove wrong use of Update::SinglePar flag.

src/BufferView.cpp
src/BufferView.h
src/Text3.cpp

index d87109548120cee5a7d5d37a1b96f745b4ede233..097a465f7b2fdee50f67212ba9fb290574f9b3e0 100644 (file)
@@ -2970,7 +2970,7 @@ void BufferView::setCurrentRowSlice(CursorSlice const & rowSlice)
 }
 
 
-void BufferView::checkCursorScrollOffset(PainterInfo & pi)
+void BufferView::checkCursorScrollOffset()
 {
        CursorSlice rowSlice = d->cursor_.bottom();
        TextMetrics const & tm = textMetrics(rowSlice.text());
@@ -2981,8 +2981,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
                return;
        ParagraphMetrics const & pm = tm.parMetrics(rowSlice.pit());
        Row const & row = pm.getRow(rowSlice.pos(),
-                                   d->cursor_.boundary()
-                                   && rowSlice == d->cursor_.top());
+                                   d->cursor_.boundary() && rowSlice == d->cursor_.top());
        rowSlice.pos() = row.pos();
 
        // 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
        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) {
                // scroll right
                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.
        // Update the drawing strategy if needed.
-       checkCursorScrollOffset(pi);
+       checkCursorScrollOffset();
 
        switch (d->update_strategy_) {
 
index 91167100ce9e1a143a87486da0f105647951e10a..bfdb0bac429ac912613f1b08344534ef65a497f4 100644 (file)
@@ -349,7 +349,7 @@ private:
 
        // Check whether the row where the cursor lives needs to be scrolled.
        // Update the drawing strategy if needed.
-       void checkCursorScrollOffset(PainterInfo & pi);
+       void checkCursorScrollOffset();
 
        /// The minimal size of the document that is visible. Used
        /// when it is allowed to scroll below the document.
index 0e51bb0865278660d276c7d45e2ca9719335f4e8..8efec47202e509aca0936658f432f23d26a42aac 100644 (file)
@@ -1614,7 +1614,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                case mouse_button::button1:
                        // Set the cursor
                        if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
-                               cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
+                               cur.screenUpdateFlags(Update::FitCursor);
                        if (bvcur.wordSelection())
                                selectWord(bvcur, WHOLE_WORD);
                        break;
@@ -1639,7 +1639,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                return;
                        }
                        if (!bv->mouseSetCursor(cur, false))
-                               cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
+                               cur.screenUpdateFlags(Update::FitCursor);
                        break;
                }