From 7f593196fc20fc8fef14e11b5b240b8a2b0aad39 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 14 Jun 2010 21:48:23 +0000 Subject: [PATCH] Add an update parameter to BufferView::scrollToCursor and BufferView::scrollDocView. This parameter indicates whether a repaint is requested git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34658 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 19 ++++++++++--------- src/BufferView.h | 5 +++-- src/frontends/qt4/GuiWorkArea.cpp | 2 +- src/insets/InsetTabular.cpp | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 7415238288..5a00d72de3 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -568,7 +568,7 @@ docstring BufferView::contextMenu(int x, int y) const } -void BufferView::scrollDocView(int value) +void BufferView::scrollDocView(int value, bool update) { int const offset = value - d->scrollbarParameters_.position; @@ -587,7 +587,7 @@ void BufferView::scrollDocView(int value) // cut off at the top if (value <= d->scrollbarParameters_.min) { DocIterator dit = doc_iterator_begin(&buffer_); - showCursor(dit, false); + showCursor(dit, false, update); LYXERR(Debug::SCROLLING, "scroll to top"); return; } @@ -596,7 +596,7 @@ void BufferView::scrollDocView(int value) if (value >= d->scrollbarParameters_.max) { DocIterator dit = doc_iterator_end(&buffer_); dit.backwardPos(); - showCursor(dit, false); + showCursor(dit, false, update); LYXERR(Debug::SCROLLING, "scroll to bottom"); return; } @@ -614,14 +614,14 @@ void BufferView::scrollDocView(int value) // It seems we didn't find the correct pit so stay on the safe side and // scroll to bottom. LYXERR0("scrolling position not found!"); - scrollDocView(d->scrollbarParameters_.max); + scrollDocView(d->scrollbarParameters_.max, update); return; } DocIterator dit = doc_iterator_begin(&buffer_); dit.pit() = i; LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i); - showCursor(dit, false); + showCursor(dit, false, update); } @@ -806,19 +806,20 @@ int BufferView::workWidth() const void BufferView::recenter() { - showCursor(d->cursor_, true); + showCursor(d->cursor_, true, true); } void BufferView::showCursor() { - showCursor(d->cursor_, false); + showCursor(d->cursor_, false, true); } -void BufferView::showCursor(DocIterator const & dit, bool recenter) +void BufferView::showCursor(DocIterator const & dit, + bool recenter, bool update) { - if (scrollToCursor(dit, recenter)) { + if (scrollToCursor(dit, recenter) && update) { buffer_.changed(true); updateHoveredInset(); } diff --git a/src/BufferView.h b/src/BufferView.h index 8d48301007..1880a58369 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -159,7 +159,8 @@ public: /// This method will automatically scroll and update the BufferView /// if needed. /// \param recenter Whether the cursor should be centered on screen - void showCursor(DocIterator const & dit, bool recenter); + void showCursor(DocIterator const & dit, bool recenter, + bool update); /// Scroll to the cursor. void scrollToCursor(); /// Scroll to the cursor. @@ -174,7 +175,7 @@ public: /// scroll document by the given number of pixels. int scroll(int pixels); /// Scroll the view by a number of pixels. - void scrollDocView(int pixels); + void scrollDocView(int pixels, bool update); /// Set the cursor position based on the scrollbar one. void setCursorFromScrollbar(); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 368fa774b1..d67ee9ad0c 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -618,7 +618,7 @@ void GuiWorkArea::updateScrollbar() void GuiWorkArea::scrollTo(int value) { stopBlinkingCursor(); - buffer_view_->scrollDocView(value); + buffer_view_->scrollDocView(value, true); if (lyxrc.cursor_follows_scrollbar) { buffer_view_->setCursorFromScrollbar(); diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 7639d54a87..475362fcc6 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -3931,7 +3931,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) // col_type const col = tabular.cellColumn(cur.idx()); // int const t = cur.bv().top_y() + cur.bv().height(); // if (t < yo() + tabular.getHeightOfTabular()) { -// cur.bv().scrollDocView(t); +// cur.bv().scrollDocView(t, true); // cur.idx() = tabular.cellBelow(first_visible_cell) + col; // } else { // cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + col; @@ -3947,7 +3947,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) // col_type const col = tabular.cellColumn(cur.idx()); // int const t = cur.bv().top_y() + cur.bv().height(); // if (yo() < 0) { -// cur.bv().scrollDocView(t); +// cur.bv().scrollDocView(t, true); // if (yo() > 0) // cur.idx() = col; // else -- 2.39.2