From ab1a045d10e9e3e24f731086d6354336253f8b81 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sat, 26 Jan 2008 00:47:22 +0000 Subject: [PATCH] * fix random jumps when scrolling very fast using a touchpad or mouse wheel. The problem was this: The value in BufferView::scrollDocView(int value) is relative to the d->scrollbarParameters_.min/max interval and _not_ absolute. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22675 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 2a543ff5a7..e563a4f81d 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -508,7 +508,12 @@ void BufferView::scrollDocView(int value) return; } - int par_pos = 0; + // cut off at the top + if (value < d->scrollbarParameters_.min) + value = d->scrollbarParameters_.min; + + // find paragraph at target positin + int par_pos = d->scrollbarParameters_.min; for (size_t i = 0; i != d->par_height_.size(); ++i) { par_pos += d->par_height_[i]; if (par_pos >= value) { @@ -521,7 +526,15 @@ void BufferView::scrollDocView(int value) << "\tanchor_ref_ = " << d->anchor_pit_ << "\tpar_pos = " << par_pos); + // cut off at the end of the buffer + if (value > par_pos) { + value = d->scrollbarParameters_.max; + d->anchor_pit_ = d->par_height_.size() - 1; + } + + // set pixel offset of screen to anchor pit d->anchor_ypos_ = par_pos - value; + updateMetrics(); buffer_.changed(); }