From 1bbcd403fc1c0e64416371610ab18e0b6df5bf36 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 27 Mar 2009 17:27:38 +0000 Subject: [PATCH] Fix bug 4733: Auto popup of math toolbar hides the math editor http://bugzilla.lyx.org/show_bug.cgi?id=4733 * GuiWorkArea: This adds "buffer_view_->scrollToCursor();" to GuiWorkArea::resizeBufferView() to make sure that the cursor remains visible. * BufferView: Make sure that we can call the scrollToCursor function without causing a new repaint. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28946 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 21 +++++++++++++++++---- src/BufferView.h | 5 +++++ src/frontends/qt4/GuiWorkArea.cpp | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index f23704dbe4..6e120dc53d 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -800,11 +800,24 @@ void BufferView::showCursor() void BufferView::showCursor(DocIterator const & dit, bool recenter) +{ + if (scrollToCursor(dit, recenter)) + buffer_.changed(); +} + + +void BufferView::scrollToCursor() +{ + scrollToCursor(d->cursor_, false); +} + + +bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter) { // We are not properly started yet, delay until resizing is // done. if (height_ == 0) - return; + return false; LYXERR(Debug::SCROLLING, "recentering!"); @@ -845,9 +858,9 @@ void BufferView::showCursor(DocIterator const & dit, bool recenter) // else, nothing to do, the cursor is already visible so we just return. if (scrolled != 0) { updateMetrics(); - buffer_.changed(); + return true; } - return; + return false; } // fix inline completion position @@ -875,7 +888,7 @@ void BufferView::showCursor(DocIterator const & dit, bool recenter) d->anchor_ypos_ = defaultRowHeight() * 2; updateMetrics(); - buffer_.changed(); + return true; } diff --git a/src/BufferView.h b/src/BufferView.h index 9335a85ab4..fcf58544a7 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -158,6 +158,11 @@ public: /// if needed. /// \param recenter Whether the cursor should be centered on screen void showCursor(DocIterator const & dit, bool recenter = false); + /// Scroll to the cursor. + void scrollToCursor(); + /// Scroll to the cursor. + /// \param recenter Whether the cursor should be centered on screen + bool scrollToCursor(DocIterator const & dit, bool recenter); /// LFUN_SCROLL Helper. void lfunScroll(FuncRequest const & cmd); /// scroll down document by the given number of pixels. diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index f8014e70b3..3823401325 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -518,6 +518,7 @@ void GuiWorkArea::resizeBufferView() // We are already inside a paint event. lyx_view_->setBusy(true); buffer_view_->resize(viewport()->width(), viewport()->height()); + buffer_view_->scrollToCursor(); updateScreen(); // Update scrollbars which might have changed due different -- 2.39.2