branch: Fix bug #6141: Scrolling error with insets at top of file.

Fix the regression introduced in r28397 while fixing bug #5573.

see r34296, r28397 and #5573.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@34307 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-04-27 13:11:57 +00:00
parent 0e36db41eb
commit abd26a734c
2 changed files with 19 additions and 3 deletions

View File

@ -839,10 +839,23 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter)
int scrolled = 0;
if (recenter)
scrolled = scroll(ypos - height_/2);
// If the top part of the row falls of the screen, we scroll
// up to align the top of the row with the top of the screen.
else if (ypos - row_dim.ascent() < 0)
scrolled = scrollUp(- ypos + row_dim.ascent());
else if (ypos + row_dim.descent() > height_)
scrolled = scrollDown(ypos - height_ + defaultRowHeight());
scrolled = scrollUp(-ypos + row_dim.ascent());
// If the bottom of the row falls of the screen, we scroll down.
// However, we have to be careful not to scroll that much that
// the top falls of the screen.
else if (ypos + row_dim.descent() > height_) {
int ynew = height_ - row_dim.descent();
if (ynew < row_dim.ascent())
ynew = row_dim.ascent();
int const scroll = ypos - ynew;
scrolled = scrollDown(scroll);
}
// else, nothing to do, the cursor is already visible so we just return.
if (scrolled != 0) {
updateMetrics();

View File

@ -313,6 +313,9 @@ What's new
- Allow to change a shortcut back to a previous value.
- Fix the painting of large insets at the top of the document
(bug 6141).
* DOCUMENTATION AND LOCALIZATION