]> git.lyx.org Git - features.git/commitdiff
Fix bug #7662: Incorrect scrolling for rows with larger ascent.
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 17 Aug 2011 10:44:50 +0000 (10:44 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 17 Aug 2011 10:44:50 +0000 (10:44 +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.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39486 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index 7076cc8989c680614de7bf0b1fb3b3e3052b6d9d..8fa8a036bccaf95c33b30c12d4c69026bd5f9eca 100644 (file)
@@ -888,16 +888,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);
                }