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
This commit is contained in:
Vincent van Ravesteijn 2009-03-27 17:27:38 +00:00
parent 2420f5ed1e
commit 1bbcd403fc
3 changed files with 23 additions and 4 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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