From 998787c78b13b3547b0c561493d0f92d74478ed1 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Tue, 25 Mar 2008 21:26:03 +0000 Subject: [PATCH] make selecting several rows/col more convenient git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23955 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetTabular.cpp | 18 +++++++++++------- src/insets/InsetTabular.h | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 64d0089e5d..d7ffb3446d 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2753,7 +2753,8 @@ bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd, InsetTabular::InsetTabular(Buffer const & buf, row_type rows, col_type columns) - : tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), scx_(0) + : tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), scx_(0), + rowselect_(false), colselect_(false) { setBuffer(const_cast(buf)); // FIXME: remove later } @@ -3111,7 +3112,6 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_MOUSE_PRESS: { //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl; - // select row if (cmd.x < xo(cur.bv()) + ADD_TO_TABULAR_WIDTH || cmd.x > xo(cur.bv()) + tabular.width()) { @@ -3123,6 +3123,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) cur.pos() = cur.lastpos(); cur.selection() = true; bvcur = cur; + rowselect_ = true; break; } // select column @@ -3137,6 +3138,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) cur.pos() = cur.lastpos(); cur.selection() = true; bvcur = cur; + colselect_ = true; break; } // do not reset cursor/selection if we have selected @@ -3159,8 +3161,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) break; } // select (additional) row - if (cmd.x < xo(cur.bv()) + ADD_TO_TABULAR_WIDTH - || cmd.x > xo(cur.bv()) + tabular.width()) { + if (rowselect_) { row_type r = rowFromY(cur, cmd.y); cur.idx() = tabular.getLastCellInRow(r); bvcur.setCursor(cur); @@ -3168,9 +3169,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) break; } // select (additional) column - int const y0 = yo(cur.bv()) - tabular.rowAscent(0); - if (cmd.y < y0 + ADD_TO_TABULAR_WIDTH - || cmd.y > y0 + tabular.height()) { + if (colselect_) { col_type c = columnFromX(cur, cmd.x); cur.idx() = tabular.cellIndex(tabular.rowCount() - 1, c); bvcur.setCursor(cur); @@ -3187,6 +3186,11 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) } break; + case LFUN_MOUSE_RELEASE: + rowselect_ = false; + colselect_ = false; + break; + case LFUN_CELL_BACKWARD: movePrevCell(cur); cur.selection() = false; diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index f149f6b91c..493c03eeb1 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -864,6 +864,10 @@ private: mutable idx_type first_visible_cell; /// mutable int scx_; + /// true when selecting rows with the mouse + bool rowselect_; + /// true when selecting columns with the mouse + bool colselect_; }; -- 2.39.2