]> git.lyx.org Git - features.git/commitdiff
Fix some scrolling issues.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 19 Dec 2007 07:47:03 +0000 (07:47 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 19 Dec 2007 07:47:03 +0000 (07:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22211 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/frontends/qt4/GuiWorkArea.cpp

index cb16a948e1164224ed9d18e17ee6999c73c349d6..45b2102dd7a547710ef5fb5fc1ea72c7f685d488 100644 (file)
@@ -392,9 +392,16 @@ void BufferView::processUpdateFlags(Update::flags flags)
 
        bool const full_metrics = flags & Update::Force;
 
-       if (full_metrics || !singleParUpdate())
+       if (full_metrics || !singleParUpdate()) {
+               if (flags & Update::FitCursor) {
+                       CursorSlice const & bot = d->cursor_.bottom();
+                       TextMetrics const & tm = d->text_metrics_[bot.text()];
+                       if (!tm.has(bot.pit()))
+                               center();
+               }
                // We have to update the full screen metrics.
                updateMetrics();
+       }
 
        if (!(flags & Update::FitCursor)) {
                buffer_.changed();
@@ -403,6 +410,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
 
        //FIXME: updateMetrics() does not update paragraph position
        // This is done at draw() time. So we need a redraw!
+
        buffer_.changed();
        if (!fitCursor())
                // The screen has already been updated thanks to the
@@ -672,13 +680,20 @@ void BufferView::updateOffsetRef()
        if (height_ == 0)
                return;
 
+       d->need_centering_ = false;
+
        CursorSlice & bot = d->cursor_.bottom();
        TextMetrics & tm = d->text_metrics_[bot.text()];
        ParagraphMetrics const & pm = tm.parMetrics(bot.pit());
-       int y = coordOffset(d->cursor_, d->cursor_.boundary()).y_;
-       d->offset_ref_ = y + pm.ascent() - height_ / 2;
-
-       d->need_centering_ = false;
+       if (d->anchor_ref_ == 0)
+               d->offset_ref_ = 0;
+       else if (d->anchor_ref_ >= pos_type(bot.text()->paragraphs().size() - 1)) {
+               d->anchor_ref_ = bot.text()->paragraphs().size() - 1;
+               d->offset_ref_ = pm.height() - height_;
+       } else {
+               int y = coordOffset(d->cursor_, d->cursor_.boundary()).y_;
+               d->offset_ref_ = y + pm.ascent() - height_ / 2;
+       }
 }
 
 
@@ -1694,6 +1709,8 @@ void BufferView::updateMetrics()
 
        d->update_strategy_ = FullScreenUpdate;
 
+       updateScrollbar();
+
        if (lyxerr.debugging(Debug::WORKAREA)) {
                LYXERR(Debug::WORKAREA, "BufferView::updateMetrics");
                d->coord_cache_.dump();
index 77aaa9bf2732e9e5a87918795e211f6b279248ce..2c20a1a8177bf7fe05f876280a4f48918b775c2c 100644 (file)
@@ -460,7 +460,6 @@ void GuiWorkArea::updateScrollbar()
 {
        verticalScrollBar()->setTracking(false);
 
-       buffer_view_->updateScrollbar();
        ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
 
        // do what cursor movement does (some grey)