]> git.lyx.org Git - features.git/commitdiff
Remove the special horizontal scrolling support in InsetTabular
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 26 Jul 2014 20:25:48 +0000 (22:25 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Jan 2015 21:55:11 +0000 (22:55 +0100)
It is not necessary anymore now that there is a global mechanism.

Also, fix the clearing of rows in SingleParUpdate mode.

src/BufferView.cpp
src/TextMetrics.cpp
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h

index e4e2a83b4f2efa57ee5228c92c016e3e4a596975..6c95d8df833d2836c2f1cd8a26e3dbc375dca833 100644 (file)
@@ -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;
 
index f325da7734ec53a49f885edf16fb7c292e8d8a79..e41874a98f0a587e826854e5b2df5d30a6be39e6 100644 (file)
@@ -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);
                }
 
index 8a8c2129f6e518a9a8dd6c049915d4d221b008ab..507f30233fd80676d23328228d55fca97ea7a1e4 100644 (file)
@@ -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);
 }
 
 
index 774949ca229a39ec5b5caecba478c7775c2927eb..a055543eff15a723e159acd70dee406af37ad041 100644 (file)
@@ -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_;