mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Change mouse cursor on tabular selection zones
This is done by implementing the clickable method. It is not possible yet to have the usual left and down arrows, because Qt does not implement them as far as I can see. Factor the code that triggers row/column selection and fix the logic. Now it is possible to select also at the right of the tabular inset.
This commit is contained in:
parent
6a1803e18d
commit
23ef2947a3
@ -3951,6 +3951,29 @@ void InsetTabular::addToToc(DocIterator const & cpit, bool output_active,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetTabular::hitSelectRow(BufferView const & bv, int x) const
|
||||||
|
{
|
||||||
|
int const x0 = xo(bv) + ADD_TO_TABULAR_WIDTH;
|
||||||
|
return x < x0 || x > x0 + tabular.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetTabular::hitSelectColumn(BufferView const & bv, int y) const
|
||||||
|
{
|
||||||
|
int const y0 = yo(bv) - tabular.rowAscent(0) + offset_valign_;
|
||||||
|
// FIXME: using ADD_TO_TABULAR_WIDTH is not really correct since
|
||||||
|
// there is no margin added vertically to tabular insets.
|
||||||
|
// However, it works for now.
|
||||||
|
return y < y0 + ADD_TO_TABULAR_WIDTH || y > y0 + tabular.height() - ADD_TO_TABULAR_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetTabular::clickable(BufferView const & bv, int x, int y) const
|
||||||
|
{
|
||||||
|
return hitSelectRow(bv, x) || hitSelectColumn(bv, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::DEBUG, "# InsetTabular::doDispatch: cmd: " << cmd
|
LYXERR(Debug::DEBUG, "# InsetTabular::doDispatch: cmd: " << cmd
|
||||||
@ -3965,8 +3988,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_MOUSE_PRESS: {
|
case LFUN_MOUSE_PRESS: {
|
||||||
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
|
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
|
||||||
// select row
|
// select row
|
||||||
if (cmd.x() < xo(cur.bv()) + ADD_TO_TABULAR_WIDTH
|
if (hitSelectRow(cur.bv(), cmd.x())) {
|
||||||
|| cmd.x() > xo(cur.bv()) + tabular.width()) {
|
|
||||||
row_type r = rowFromY(cur, cmd.y());
|
row_type r = rowFromY(cur, cmd.y());
|
||||||
cur.idx() = tabular.getFirstCellInRow(r);
|
cur.idx() = tabular.getFirstCellInRow(r);
|
||||||
cur.pit() = 0;
|
cur.pit() = 0;
|
||||||
@ -3981,9 +4003,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// select column
|
// select column
|
||||||
int const y0 = yo(cur.bv()) - tabular.rowAscent(0) + offset_valign_;
|
if (hitSelectColumn(cur.bv(), cmd.y())) {
|
||||||
if (cmd.y() < y0 + ADD_TO_TABULAR_WIDTH
|
|
||||||
|| cmd.y() > y0 + tabular.height()) {
|
|
||||||
col_type c = columnFromX(cur, cmd.x());
|
col_type c = columnFromX(cur, cmd.x());
|
||||||
cur.idx() = tabular.cellIndex(0, c);
|
cur.idx() = tabular.cellIndex(0, c);
|
||||||
cur.pit() = 0;
|
cur.pit() = 0;
|
||||||
|
@ -1003,6 +1003,13 @@ private:
|
|||||||
///
|
///
|
||||||
Inset * clone() const { return new InsetTabular(*this); }
|
Inset * clone() const { return new InsetTabular(*this); }
|
||||||
|
|
||||||
|
///
|
||||||
|
bool hitSelectRow(BufferView const & bv, int x) const;
|
||||||
|
///
|
||||||
|
bool hitSelectColumn(BufferView const & bv, int y) const;
|
||||||
|
/// Returns true if coordinates are on row/column selection zones
|
||||||
|
bool clickable(BufferView const &, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void drawCellLines(PainterInfo &, int x, int y, row_type row,
|
void drawCellLines(PainterInfo &, int x, int y, row_type row,
|
||||||
idx_type cell) const;
|
idx_type cell) const;
|
||||||
|
@ -25,6 +25,8 @@ What's new
|
|||||||
- Increase the maximum value for the number of last open files that LyX can
|
- Increase the maximum value for the number of last open files that LyX can
|
||||||
remember (bug 9924).
|
remember (bug 9924).
|
||||||
|
|
||||||
|
- Change mouse cursor to indicate row/column selection in tabulars.
|
||||||
|
|
||||||
* DOCUMENTATION AND LOCALIZATION
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user