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
This commit is contained in:
Vincent van Ravesteijn 2010-06-14 21:48:23 +00:00
parent e1ba93a068
commit 7f593196fc
4 changed files with 16 additions and 14 deletions

View File

@ -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();
}

View File

@ -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();

View File

@ -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();

View File

@ -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