From: Abdelrazak Younes Date: Wed, 16 Aug 2006 15:24:38 +0000 (+0000) Subject: This commit should hopefully fix all scrolling issues. As an added bonus, mouse scrol... X-Git-Tag: 1.6.10~12800 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dd429b7f268a00eea7d57767363e1aebcb08a25f;p=lyx.git This commit should hopefully fix 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()). Log: * BufferView/pimpl: - scrollDocView(): call to BufferView::update() deleted. - scrollDocView(): second part is now in setCursorFromScrollbar() - setCursorFromScrollbar(): 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. - paintEvent(): scrollbar related code deleted * qt3/QWorkArea - setScrollbarParams(): now disable the Qt scrollbar tracking. * qt3/QContentPane - paintEvent(): scrollbar related code deleted git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14704 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index f5b1db983e..f30d87a050 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -150,6 +150,12 @@ void BufferView::scrollDocView(int value) } +void BufferView::setCursorFromScrollbar() +{ + pimpl_->setCursorFromScrollbar(); +} + + bool BufferView::available() const { return pimpl_->available(); diff --git a/src/BufferView.h b/src/BufferView.h index 5704ab97c8..fdc9181ab2 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -160,6 +160,8 @@ public: void scroll(int lines); /// Scroll the view by a number of pixels void scrollDocView(int pixels); + /// Set the cursor position based on the scrollbar one. + void setCursorFromScrollbar(); /// return the pixel width of the document view int workWidth() const; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 9b3499bc20..067fa63660 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -435,10 +435,12 @@ void BufferView::Pimpl::scrollDocView(int value) 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::setCursorFromScrollbar() +{ + LyXText & t = *bv_->text(); int const height = 2 * defaultRowHeight(); int const first = height; diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index a59825bbe0..14c4d52ba5 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -66,6 +66,8 @@ public: ScrollbarParameters const & scrollbarParameters() const; /// void scrollDocView(int value); + /// + void setCursorFromScrollbar(); /// Wheel mouse scroll, move by multiples of text->defaultRowHeight(). void scroll(int lines); /// diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index ecb920d5a9..277e3ee560 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -159,7 +159,9 @@ WorkArea::WorkArea(LyXView & lyx_view) void WorkArea::setBufferView(BufferView * buffer_view) { + hideCursor(); buffer_view_ = buffer_view; + toggleCursor(); } @@ -193,6 +195,9 @@ void WorkArea::redraw() } buffer_view_->updateMetrics(false); + + updateScrollbar(); + ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo(); greyed_out_ = false; getPainter().start(); @@ -266,11 +271,25 @@ void WorkArea::resizeBufferView() } +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_->setCursorFromScrollbar(); + lyx_view_.updateLayoutChoice(); + } + toggleCursor(); } diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 63fcc1c147..49e5b0c946 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -139,6 +139,8 @@ protected: LyXView & lyx_view_; private: + /// + void updateScrollbar(); /// void checkAndGreyOut(); diff --git a/src/frontends/qt3/QContentPane.C b/src/frontends/qt3/QContentPane.C index dc4cf14e10..c3a652103a 100644 --- a/src/frontends/qt3/QContentPane.C +++ b/src/frontends/qt3/QContentPane.C @@ -357,14 +357,6 @@ void QContentPane::paintEvent(QPaintEvent * e) 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); } diff --git a/src/frontends/qt3/QWorkArea.C b/src/frontends/qt3/QWorkArea.C index 0f1610fa3e..94a925a33f 100644 --- a/src/frontends/qt3/QWorkArea.C +++ b/src/frontends/qt3/QWorkArea.C @@ -88,6 +88,7 @@ QWorkArea::~QWorkArea() 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 @@ void QWorkArea::setScrollbarParams(int h, int pos, int line_h) content_->trackScrollbar(true); scrollbar_->setLineStep(line_h); scrollbar_->setPageStep(height()); + + scrollbar_->setTracking(true); } } // namespace frontend diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index fc5be29b62..47464a2b86 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -184,6 +184,8 @@ GuiWorkArea::~GuiWorkArea() 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 @@ void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step verticalScrollBar()->setRange(0, scroll_max_); verticalScrollBar()->setSliderPosition(scroll_pos); verticalScrollBar()->setSingleStep(scroll_line_step); + + verticalScrollBar()->setTracking(true); } @@ -478,15 +482,6 @@ void GuiWorkArea::paintEvent(QPaintEvent * e) 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); }