From 65dc5e83374c1fd45ef141e6f7e38c80026be9e2 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 19 Dec 2007 07:47:03 +0000 Subject: [PATCH] Fix some scrolling issues. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22211 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 27 ++++++++++++++++++++++----- src/frontends/qt4/GuiWorkArea.cpp | 1 - 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index cb16a948e1..45b2102dd7 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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(); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 77aaa9bf27..2c20a1a817 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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)