Hi all,
This patch should hopefully all scrolling issues. As an added bonus,
mouse scrolling should be faster due to a deleted call to
BufferView::update() that was not usefull (the important call to
updateMetrics() is done in WorkArea()).
I am going to commit this soon unless there's some style objection.
Abdel.
Log:
* BufferView/pimpl:
- scrollDocView(): call to BufferView::update() deleted.
- scrollDocView(): second part is now in adjustCursorWithScrollbar()
- adjustCursorWithScrollbar(): new method.
* WorkArea:
- setBufferView(): show the cursor immediately
- redraw(): call to updateScrollbar()
- updateScrollbar(): new method
- scrollBufferView(): fix it and show the cursor immediately.
* qt4/GuiWorkArea
- setScrollbarParams(): now disable the Qt scrollbar tracking.
* qt3/QWorkArea
- setScrollbarParams(): now disable the Qt scrollbar tracking.
* qt3/QWorkArea
- paintEvent(): scrollbar related code deleted
Index: BufferView.C
===================================================================
--- BufferView.C (revision 14700)
+++ BufferView.C (working copy)
@@ -150,6 +150,12 @@
}
+void BufferView::adjustCursorWithScrollbar()
+{
+ pimpl_->adjustCursorWithScrollbar();
+}
+
+
bool BufferView::available() const
{
return pimpl_->available();
Index: BufferView.h
===================================================================
--- BufferView.h (revision 14700)
+++ BufferView.h (working copy)
@@ -160,6 +160,8 @@
void scroll(int lines);
/// Scroll the view by a number of pixels
void scrollDocView(int pixels);
+ /// Adjust the cursor position with the scrollbar one.
+ void adjustCursorWithScrollbar();
/// return the pixel width of the document view
int workWidth() const;
Index: BufferView_pimpl.C
===================================================================
--- BufferView_pimpl.C (revision 14700)
+++ BufferView_pimpl.C (working copy)
@@ -435,11 +435,13 @@
t.redoParagraph(anchor_ref_);
int const h = t.getPar(anchor_ref_).height();
offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
- update();
+}
- if (!lyxrc.cursor_follows_scrollbar)
- return;
+void BufferView::Pimpl::adjustCursorWithScrollbar()
+{
+ LyXText & t = *bv_->text();
+
int const height = 2 * defaultRowHeight();
int const first = height;
int const last = height_ - height;
Index: BufferView_pimpl.h
===================================================================
--- BufferView_pimpl.h (revision 14700)
+++ BufferView_pimpl.h (working copy)
@@ -66,6 +66,8 @@
ScrollbarParameters const & scrollbarParameters() const;
///
void scrollDocView(int value);
+ ///
+ void adjustCursorWithScrollbar();
/// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
void scroll(int lines);
///
Index: frontends/qt3/QContentPane.C
===================================================================
--- frontends/qt3/QContentPane.C (revision 14700)
+++ frontends/qt3/QContentPane.C (working copy)
@@ -357,14 +357,6 @@
QPainter q(this);
q.drawPixmap(QPoint(r.x(), r.y()),
*pixmap_.get(), r);
-
- buffer_view_->updateScrollbar();
- ScrollbarParameters const & scroll_ =
buffer_view_->scrollbarParameters();
-
- wa_->scrollbar_->setTracking(false);
- wa_->setScrollbarParams(scroll_.height, scroll_.position,
- scroll_.lineScrollHeight);
- wa_->scrollbar_->setTracking(true);
}
Index: frontends/qt3/QWorkArea.C
===================================================================
--- frontends/qt3/QWorkArea.C (revision 14700)
+++ frontends/qt3/QWorkArea.C (working copy)
@@ -88,6 +88,7 @@
void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
{
+ scrollbar_->setTracking(false);
// do what cursor movement does (some grey)
h += height() / 4;
@@ -99,6 +100,8 @@
content_->trackScrollbar(true);
scrollbar_->setLineStep(line_h);
scrollbar_->setPageStep(height());
+
+ scrollbar_->setTracking(true);
}
} // namespace frontend
Index: frontends/qt4/GuiWorkArea.C
===================================================================
--- frontends/qt4/GuiWorkArea.C (revision 14700)
+++ frontends/qt4/GuiWorkArea.C (working copy)
@@ -184,6 +184,8 @@
void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int
scroll_line_step)
{
+ verticalScrollBar()->setTracking(false);
+
// do what cursor movement does (some grey)
h += height() / 4;
int scroll_max_ = std::max(0, h - height());
@@ -191,6 +193,8 @@
verticalScrollBar()->setRange(0, scroll_max_);
verticalScrollBar()->setSliderPosition(scroll_pos);
verticalScrollBar()->setSingleStep(scroll_line_step);
+
+ verticalScrollBar()->setTracking(true);
}
@@ -478,15 +482,6 @@
if (show_hcursor_)
q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
-
- buffer_view_->updateScrollbar();
-
- ScrollbarParameters const & scroll_ =
buffer_view_->scrollbarParameters();
-
- verticalScrollBar()->setTracking(false);
- setScrollbarParams(scroll_.height, scroll_.position,
- scroll_.lineScrollHeight);
- verticalScrollBar()->setTracking(true);
}
Index: frontends/WorkArea.C
===================================================================
--- frontends/WorkArea.C (revision 14700)
+++ frontends/WorkArea.C (working copy)
@@ -159,7 +159,9 @@
void WorkArea::setBufferView(BufferView * buffer_view)
{
+ hideCursor();
buffer_view_ = buffer_view;
+ toggleCursor();
}
@@ -193,6 +195,9 @@
}
buffer_view_->updateMetrics(false);
+
+ updateScrollbar();
+
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
greyed_out_ = false;
getPainter().start();
@@ -266,11 +271,25 @@
}
+void WorkArea::updateScrollbar()
+{
+ buffer_view_->updateScrollbar();
+ ScrollbarParameters const & scroll_ =
buffer_view_->scrollbarParameters();
+ setScrollbarParams(scroll_.height, scroll_.position,
+ scroll_.lineScrollHeight);
+}
+
+
void WorkArea::scrollBufferView(int position)
{
buffer_view_->scrollDocView(position);
- lyx_view_.updateLayoutChoice();
redraw();
+ hideCursor();
+ if (lyxrc.cursor_follows_scrollbar) {
+ buffer_view_->adjustCursorWithScrollbar();
+ lyx_view_.updateLayoutChoice();
+ }
+ toggleCursor();
}
Index: frontends/WorkArea.h
===================================================================
--- frontends/WorkArea.h (revision 14700)
+++ frontends/WorkArea.h (working copy)
@@ -140,6 +140,8 @@
private:
///
+ void updateScrollbar();
+ ///
void checkAndGreyOut();
///