]> git.lyx.org Git - features.git/commitdiff
This commit should hopefully fix all scrolling issues. As an added bonus, mouse scrol...
authorAbdelrazak Younes <younes@lyx.org>
Wed, 16 Aug 2006 15:24:38 +0000 (15:24 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 16 Aug 2006 15:24:38 +0000 (15:24 +0000)
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

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/frontends/WorkArea.C
src/frontends/WorkArea.h
src/frontends/qt3/QContentPane.C
src/frontends/qt3/QWorkArea.C
src/frontends/qt4/GuiWorkArea.C

index f5b1db983ecb0032fe231a42753818dc479c2e46..f30d87a050bf32e81c6cd09233f0394363e40aaa 100644 (file)
@@ -150,6 +150,12 @@ void BufferView::scrollDocView(int value)
 }
 
 
+void BufferView::setCursorFromScrollbar()
+{
+       pimpl_->setCursorFromScrollbar();
+}
+
+
 bool BufferView::available() const
 {
        return pimpl_->available();
index 5704ab97c86dd49b96716570cd6327ea3d7de556..fdc9181ab2cf0a4d64df01a4c904fd55570358e5 100644 (file)
@@ -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;
index 9b3499bc202797afe167a273cc708e454686bb4d..067fa63660065593793186b3ba2993688ed275f9 100644 (file)
@@ -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;
index a59825bbe07c658eaa62752311e5167600046be3..14c4d52ba5740b6f6ccddcfd99264f071f1b951b 100644 (file)
@@ -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);
        ///
index ecb920d5a995193fc568cccdb90f2df84269a960..277e3ee560dd15d016f7b482d0f5e5f447158470 100644 (file)
@@ -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();
 }
 
 
index 63fcc1c147f4cdf763b89c43725a1d8a54795c5e..49e5b0c946872d8652a744870828ae40c679d1ee 100644 (file)
@@ -139,6 +139,8 @@ protected:
        LyXView & lyx_view_;
 
 private:
+       ///
+       void updateScrollbar();
        ///
        void checkAndGreyOut();
 
index dc4cf14e10ecf703e2d23ad6b0bd9f9bf6cc92d8..c3a652103ae6cc6b549785abfa4b6092c9e3e007 100644 (file)
@@ -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);
 }
 
 
index 0f1610fa3eb3cb2139a407523e66924c2e9970a5..94a925a33f77f2a1ddc3c2b28e609eaad60e3eb7 100644 (file)
@@ -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
index fc5be29b62b1f96e72839e305563eda72b87c0f2..47464a2b86aa2eadb30552c69d3f0f06a49b3c6b 100644 (file)
@@ -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);
 }