]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Fix bug #10213 as discussed there: We now display the same button
[lyx.git] / src / BufferView.cpp
index 1daee5c720faff049b907e5d452da7106e804aa1..6922770f2966c558fe8d28f867c094f43eeeed0d 100644 (file)
@@ -370,13 +370,13 @@ int BufferView::leftMargin() const
 
 bool BufferView::isTopScreen() const
 {
-       return d->scrollbarParameters_.position == d->scrollbarParameters_.min;
+       return 0 == d->scrollbarParameters_.min;
 }
 
 
 bool BufferView::isBottomScreen() const
 {
-       return d->scrollbarParameters_.position == d->scrollbarParameters_.max;
+       return 0 == d->scrollbarParameters_.max;
 }
 
 
@@ -559,7 +559,6 @@ void BufferView::updateScrollbar()
        for (size_t i = last.first + 1; i != parsize; ++i)
                d->scrollbarParameters_.max += d->par_height_[i];
 
-       d->scrollbarParameters_.position = 0;
        // The reference is the top position so we remove one page.
        if (lyxrc.scroll_below_document)
                d->scrollbarParameters_.max -= minVisiblePart();
@@ -600,17 +599,19 @@ string BufferView::contextMenu(int x, int y) const
 }
 
 
-void BufferView::scrollDocView(int value, bool update)
+
+void BufferView::scrollDocView(int const value, bool update)
 {
-       int const offset = value - d->scrollbarParameters_.position;
+       // The scrollbar values are relative to the top of the screen, therefore the
+       // offset is equal to the target value.
 
        // No scrolling at all? No need to redraw anything
-       if (offset == 0)
+       if (value == 0)
                return;
 
        // If the offset is less than 2 screen height, prefer to scroll instead.
-       if (abs(offset) <= 2 * height_) {
-               d->anchor_ypos_ -= offset;
+       if (abs(value) <= 2 * height_) {
+               d->anchor_ypos_ -= value;
                buffer_.changed(true);
                updateHoveredInset();
                return;
@@ -2914,15 +2915,26 @@ int BufferView::horizScrollOffset() const
 }
 
 
-CursorSlice const & BufferView::currentRowSlice() const
+int BufferView::horizScrollOffset(Text const * text,
+                                  pit_type pit, pos_type pos) const
 {
-       return d->current_row_slice_;
+       // Is this a row that is currently scrolled?
+       if (!d->current_row_slice_.empty()
+           && &text->inset() == d->current_row_slice_.inset().asInsetText()
+           && pit ==  d->current_row_slice_.pit()
+           && pos ==  d->current_row_slice_.pos())
+               return d->horiz_scroll_offset_;
+       return 0;
 }
 
 
-CursorSlice const & BufferView::lastRowSlice() const
+bool BufferView::hadHorizScrollOffset(Text const * text,
+                                      pit_type pit, pos_type pos) const
 {
-       return d->last_row_slice_;
+       return !d->last_row_slice_.empty()
+              && &text->inset() == d->last_row_slice_.inset().asInsetText()
+              && pit ==  d->last_row_slice_.pit()
+              && pos ==  d->last_row_slice_.pos();
 }
 
 
@@ -2988,8 +3000,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
                bool const drawing = pi.pain.isDrawingEnabled();
                pi.pain.setDrawingEnabled(false);
                // No need to care about vertical position.
-               RowPainter rp(pi, buffer().text(), d->cursor_.bottom().pit(), row,
-                             -d->horiz_scroll_offset_, 0);
+               RowPainter rp(pi, buffer().text(), row, -d->horiz_scroll_offset_, 0);
                rp.paintText();
                pi.pain.setDrawingEnabled(drawing);
        }