]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
* There are cases where updateLabels is not called because no
[lyx.git] / src / BufferView.cpp
index 9edd183157e5309333d5d98bfc10818167e29bf9..3518d0b7e8c5c18a9186ccc8d51790124849d287 100644 (file)
@@ -1336,6 +1336,8 @@ void BufferView::clearSelection()
 
 void BufferView::resize(int width, int height)
 {
+       bool initialResize = (height_ == 0);
+       
        // Update from work area
        width_ = width;
        height_ = height;
@@ -1344,6 +1346,13 @@ void BufferView::resize(int width, int height)
        d->par_height_.clear();
 
        updateMetrics();
+
+       // view got his initial size, make sure that
+       // the cursor has a proper position
+       if (initialResize) {
+               updateScrollbar();
+               showCursor();
+       }
 }
 
 
@@ -1768,6 +1777,19 @@ void BufferView::updateMetrics()
        // Rebreak anchor paragraph.
        tm.redoParagraph(d->anchor_pit_);
        ParagraphMetrics & anchor_pm = tm.par_metrics_[d->anchor_pit_];
+       
+       // position anchor
+       if (d->anchor_pit_ == 0) {
+               int scrollRange = d->scrollbarParameters_.max - d->scrollbarParameters_.min;
+               
+               // Complete buffer visible? Then it's easy.
+               if (scrollRange == 0)
+                       d->anchor_ypos_ = anchor_pm.ascent();
+       
+               // FIXME: Some clever handling needed to show
+               // the _first_ paragraph up to the top if the cursor is
+               // in the first line.
+       }               
        anchor_pm.setPosition(d->anchor_ypos_);
 
        LYXERR(Debug::PAINTING, "metrics: "