]> git.lyx.org Git - features.git/commitdiff
branch: Fix bug #7662: Incorrect scrolling for rows with larger ascent.
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 26 Oct 2011 13:35:47 +0000 (13:35 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 26 Oct 2011 13:35:47 +0000 (13:35 +0000)
- After introducing the displayed vertical alignment for tables, we met for the first time situations in which row.ascent is very large. To make sure the scrolling still works, we have to do the same as we did for rows with a large descent.
- change row.ascent into defaultRowHeight. Before the above mentioned change, row.ascent usually was approximately the same as defaultRowHeight (by chance). However, it is now clear we don't really want row.ascent here.

see r39486.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40009 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index 0b5eef50838b7fc437d048c417043038e6bde7c2..f5d3487b21c6371123f1aa8be9f6170b622063e5 100644 (file)
@@ -889,16 +889,25 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter)
 
                // 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.ascent() < 0 && ypos < height_) {
+                       int ynew = row_dim.ascent();
+                       if (ynew > height_ - row_dim.descent())
+                               // FIXME: Recursively find the rowheight of the row in the inset
+                               // until we find a row which can be visualized completely.
+                               ynew = height_ - defaultRowHeight();
+                       int const scroll = ynew - ypos;
+                       scrolled = scrollUp(scroll);
+               }
 
                // 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_) {
+               else if (ypos + row_dim.descent() > height_ && ypos > 0) {
                        int ynew = height_ - row_dim.descent();
                        if (ynew < row_dim.ascent())
-                               ynew = row_dim.ascent();
+                               // FIXME: Recursively find the rowheight of the row in the inset
+                               // until we find a row which can be visualized completely.
+                               ynew = defaultRowHeight();
                        int const scroll = ypos - ynew;
                        scrolled = scrollDown(scroll);
                }