From fcaf5b5fc8a0949987d7e49949f2ce0a74792008 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 26 Jul 2014 22:25:48 +0200 Subject: [PATCH] Remove the special horizontal scrolling support in InsetTabular It is not necessary anymore now that there is a global mechanism. Also, fix the clearing of rows in SingleParUpdate mode. --- src/BufferView.cpp | 10 +++++++- src/TextMetrics.cpp | 5 +++- src/insets/InsetTabular.cpp | 49 ++++--------------------------------- src/insets/InsetTabular.h | 4 --- 4 files changed, 18 insertions(+), 50 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index e4e2a83b4f..6c95d8df83 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2955,7 +2955,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi) || !d->last_row_slice_.empty())) { // FIXME: if one uses SingleParUpdate, then home/end // will not work on long rows. Why? - d->update_strategy_ = FullScreenUpdate;//DecorationUpdate; + d->update_strategy_ = FullScreenUpdate; } d->horiz_scroll_offset_ = offset; @@ -2982,6 +2982,7 @@ void BufferView::draw(frontend::Painter & pain) case NoScreenUpdate: // If no screen painting is actually needed, only some the different // coordinates of insets and paragraphs needs to be updated. + LYXERR(Debug::PAINTING, "Strategy: NoScreenUpdate"); pi.full_repaint = true; pi.pain.setDrawingEnabled(false); tm.draw(pi, 0, y); @@ -2989,6 +2990,7 @@ void BufferView::draw(frontend::Painter & pain) case SingleParUpdate: pi.full_repaint = false; + LYXERR(Debug::PAINTING, "Strategy: SingleParUpdate"); // In general, only the current row of the outermost paragraph // will be redrawn. Particular cases where selection spans // multiple paragraph are correctly detected in TextMetrics. @@ -3001,6 +3003,12 @@ void BufferView::draw(frontend::Painter & pain) // because of the single backing pixmap. case FullScreenUpdate: + + LYXERR(Debug::PAINTING, + ((d->update_strategy_ == FullScreenUpdate) + ? "Strategy: FullScreenUpdate" + : "Strategy: DecorationUpdate")); + // The whole screen, including insets, will be refreshed. pi.full_repaint = true; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index f325da7734..e41874a98f 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1903,7 +1903,10 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co // Clear background of this row if paragraph background was not // already cleared because of a full repaint. if (!pi.full_repaint && row_has_changed) { - pi.pain.fillRectangle(x, y - row.ascent(), + LYXERR(Debug::PAINTING, "Clear rect@(" + << max(x, 0) << ", " << y-row.ascent() << ")=" + << width() << " x " << row.height()); + pi.pain.fillRectangle(max(x, 0), y - row.ascent(), width(), row.height(), pi.background_color); } diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8a8c2129f6..507f30233f 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -3456,14 +3456,14 @@ docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const InsetTabular::InsetTabular(Buffer * buf, row_type rows, col_type columns) - : Inset(buf), tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), scx_(0), + : Inset(buf), tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), rowselect_(false), colselect_(false) { } InsetTabular::InsetTabular(InsetTabular const & tab) - : Inset(tab), tabular(tab.tabular), scx_(0) + : Inset(tab), tabular(tab.tabular) { } @@ -3714,11 +3714,10 @@ bool InsetTabular::isCellSelected(Cursor & cur, row_type row, col_type col) void InsetTabular::draw(PainterInfo & pi, int x, int y) const { - x += scx_ + ADD_TO_TABULAR_WIDTH; + x += ADD_TO_TABULAR_WIDTH; BufferView * bv = pi.base.bv; Cursor & cur = pi.base.bv->cursor(); - resetPos(cur); // FIXME: As the full background is painted in drawBackground(), // we have no choice but to do a full repaint for the Text cells. @@ -3766,7 +3765,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const void InsetTabular::drawBackground(PainterInfo & pi, int x, int y) const { - x += scx_ + ADD_TO_TABULAR_WIDTH; + x += ADD_TO_TABULAR_WIDTH; y += offset_valign_ - tabular.rowAscent(0); pi.pain.fillRectangle(x, y, tabular.width(), tabular.height(), pi.backgroundColor(this)); @@ -3776,9 +3775,8 @@ void InsetTabular::drawBackground(PainterInfo & pi, int x, int y) const void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const { Cursor & cur = pi.base.bv->cursor(); - resetPos(cur); - x += scx_ + ADD_TO_TABULAR_WIDTH; + x += ADD_TO_TABULAR_WIDTH; if (!cur.selection()) return; @@ -3894,7 +3892,6 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection) } cur.setCurrentFont(); // FIXME: this accesses the position cache before it is initialized - //resetPos(cur); //cur.bv().fitCursor(); } @@ -5083,7 +5080,6 @@ void InsetTabular::cursorPos(BufferView const & bv, x += cellXPos(sl.idx()); x += tabular.textHOffset(sl.idx()); x += ADD_TO_TABULAR_WIDTH; - x += scx_; } @@ -5124,7 +5120,6 @@ Inset * InsetTabular::editXY(Cursor & cur, int x, int y) cur.setSelection(false); cur.push(*this); cur.idx() = getNearestCell(cur.bv(), x, y); - resetPos(cur); return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y); } @@ -5174,36 +5169,6 @@ int InsetTabular::cellXPos(idx_type const cell) const } -void InsetTabular::resetPos(Cursor & cur) const -{ - BufferView & bv = cur.bv(); - int const maxwidth = bv.workWidth(); - - int const scx_old = scx_; - int const i = cur.find(this); - if (i == -1) { - scx_ = 0; - } else { - int const X1 = 0; - int const X2 = maxwidth; - int const offset = ADD_TO_TABULAR_WIDTH + 2; - int const x1 = xo(cur.bv()) + cellXPos(cur[i].idx()) + offset; - int const x2 = x1 + tabular.cellWidth(cur[i].idx()); - - if (x1 < X1) - scx_ = X1 + 20 - x1; - else if (x2 > X2) - scx_ = X2 - 20 - x2; - else - scx_ = 0; - } - - // only update if offset changed - if (scx_ != scx_old) - cur.screenUpdateFlags(Update::Force | Update::FitCursor); -} - - void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from) { row_type const row = tabular.cellRow(cur.idx()); @@ -5238,7 +5203,6 @@ void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from) if (cur.selIsMultiCell()) { cur.pit() = cur.lastpit(); cur.pos() = cur.lastpos(); - resetPos(cur); return; } @@ -5261,7 +5225,6 @@ void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from) } cur.setCurrentFont(); - resetPos(cur); } @@ -5296,7 +5259,6 @@ void InsetTabular::movePrevCell(Cursor & cur, EntryDirection entry_from) if (cur.selIsMultiCell()) { cur.pit() = cur.lastpit(); cur.pos() = cur.lastpos(); - resetPos(cur); return; } @@ -5319,7 +5281,6 @@ void InsetTabular::movePrevCell(Cursor & cur, EntryDirection entry_from) } cur.setCurrentFont(); - resetPos(cur); } diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 774949ca22..a055543eff 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -989,8 +989,6 @@ private: /// int cellYPos(idx_type cell) const; /// - void resetPos(Cursor & cur) const; - /// bool copySelection(Cursor & cur); /// bool pasteClipboard(Cursor & cur); @@ -1013,8 +1011,6 @@ private: col_type col_start, col_type col_end) const; /// mutable idx_type first_visible_cell; - /// - mutable int scx_; /// The vertical offset of the table due to the vertical /// alignment with respect to the baseline. mutable int offset_valign_; -- 2.39.2