]> git.lyx.org Git - features.git/commitdiff
Make the scrolling for large insets more naturally (bug #7662)
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 18 Sep 2011 09:35:06 +0000 (09:35 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 18 Sep 2011 09:35:06 +0000 (09:35 +0000)
The patch fixes a case that I had forgotten. Namely, the case that when the height of a row was larger than the height of the screen and that the cursor is already visible. That's why I added a new if case to catch all situations in which the row height is larger than the height of the screen. If we then need scrolling we scroll to height/4 and 3*height/4. In the end, the height_/4 and 3*height_/4 should be replaced by the rowheights in the inset, but we need some extra infrastructure for that.

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

src/BufferView.cpp

index 5cfe25df9d4bf69f1ad1ba81c83658bdc8d61133..0af790786cc60906bfe10d5c36d432b6a73d2ba0 100644 (file)
@@ -886,29 +886,28 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter)
                if (recenter)
                        scrolled = scroll(ypos - height_/2);
 
+               // We try to visualize the whole row, if the row height is larger than
+               // the screen height, we scroll to a heuristic value of height_ / 4.
+               // FIXME: This heuristic value should be replaced by a recursive search
+               // for a row in the inset that can be visualized completely.
+               else if (row_dim.height() > height_) {
+                       if (ypos < defaultRowHeight())
+                               scrolled = scroll(ypos - height_ / 4);
+                       else if (ypos > height_ - defaultRowHeight())
+                               scrolled = scroll(ypos - 3 * height_ / 4);
+               }
+
                // 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 && 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);
+                       scrolled = scrollUp(ynew - ypos);
                }
 
                // 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_ && ypos > 0) {
                        int ynew = height_ - row_dim.descent();
-                       if (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);
+                       scrolled = scrollDown(ypos - ynew);
                }
 
                // else, nothing to do, the cursor is already visible so we just return.