mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 16:50:39 +00:00
Get rid of TextMetrics::x2pos
Replace it with code that uses getPosNearX.
This commit is contained in:
parent
4c72def295
commit
6701a5d55c
@ -1454,21 +1454,6 @@ pair<pos_type, bool> TextMetrics::getPosNearX(Row const & row, int & x) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME: only InsetTabular uses this. Remove?
|
|
||||||
pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
|
|
||||||
{
|
|
||||||
// We play safe and use parMetrics(pit) to make sure the
|
|
||||||
// ParagraphMetrics will be redone and OK to use if needed.
|
|
||||||
// Otherwise we would use an empty ParagraphMetrics in
|
|
||||||
// upDownInText() while in selection mode.
|
|
||||||
ParagraphMetrics const & pm = parMetrics(pit);
|
|
||||||
|
|
||||||
LBUFERR(row < int(pm.rows().size()));
|
|
||||||
Row const & r = pm.rows()[row];
|
|
||||||
return getPosNearX(r, x).first;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// y is screen coordinate
|
// y is screen coordinate
|
||||||
pit_type TextMetrics::getPitNearY(int y)
|
pit_type TextMetrics::getPitNearY(int y)
|
||||||
{
|
{
|
||||||
|
@ -191,12 +191,6 @@ public:
|
|||||||
/// of this column. This takes in account horizontal cursor row scrolling.
|
/// of this column. This takes in account horizontal cursor row scrolling.
|
||||||
std::pair<pos_type, bool> getPosNearX(Row const & row, int & x) const;
|
std::pair<pos_type, bool> getPosNearX(Row const & row, int & x) const;
|
||||||
|
|
||||||
/// returns pos in given par at given x coord.
|
|
||||||
pos_type x2pos(pit_type pit, int row, int x) const;
|
|
||||||
|
|
||||||
// FIXME: is there a need for this?
|
|
||||||
//int pos2x(pit_type pit, pos_type pos) const;
|
|
||||||
|
|
||||||
/// returns the row near the specified y-coordinate in a given paragraph
|
/// returns the row near the specified y-coordinate in a given paragraph
|
||||||
/// (relative to the screen). If assert_in_view is true, it is made sure
|
/// (relative to the screen). If assert_in_view is true, it is made sure
|
||||||
/// that the row is on screen completely; this might change the given pit.
|
/// that the row is on screen completely; this might change the given pit.
|
||||||
|
@ -5292,15 +5292,15 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
// setting also the right targetX.
|
// setting also the right targetX.
|
||||||
cur.selHandle(act == LFUN_DOWN_SELECT);
|
cur.selHandle(act == LFUN_DOWN_SELECT);
|
||||||
if (tabular.cellRow(cur.idx()) != tabular.nrows() - 1) {
|
if (tabular.cellRow(cur.idx()) != tabular.nrows() - 1) {
|
||||||
int const xtarget = cur.targetX();
|
int xtarget = cur.targetX();
|
||||||
// WARNING: Once cur.idx() has been reset, the cursor is in
|
// WARNING: Once cur.idx() has been reset, the cursor is in
|
||||||
// an inconsistent state until pos() has been set. Be careful
|
// an inconsistent state until pos() has been set. Be careful
|
||||||
// what you do with it!
|
// what you do with it!
|
||||||
cur.idx() = tabular.cellBelow(cur.idx());
|
cur.idx() = tabular.cellBelow(cur.idx());
|
||||||
cur.pit() = 0;
|
cur.pit() = 0;
|
||||||
TextMetrics const & tm =
|
TextMetrics const & tm = cur.bv().textMetrics(cell(cur.idx())->getText(0));
|
||||||
cur.bv().textMetrics(cell(cur.idx())->getText(0));
|
ParagraphMetrics const & pm = tm.parMetrics(cur.pit());
|
||||||
cur.pos() = tm.x2pos(cur.pit(), 0, xtarget);
|
cur.pos() = tm.getPosNearX(pm.rows().front(), xtarget).first;
|
||||||
cur.setCurrentFont();
|
cur.setCurrentFont();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5331,7 +5331,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
// setting also the right targetX.
|
// setting also the right targetX.
|
||||||
cur.selHandle(act == LFUN_UP_SELECT);
|
cur.selHandle(act == LFUN_UP_SELECT);
|
||||||
if (tabular.cellRow(cur.idx()) != 0) {
|
if (tabular.cellRow(cur.idx()) != 0) {
|
||||||
int const xtarget = cur.targetX();
|
int xtarget = cur.targetX();
|
||||||
// WARNING: Once cur.idx() has been reset, the cursor is in
|
// WARNING: Once cur.idx() has been reset, the cursor is in
|
||||||
// an inconsistent state until pos() has been set. Be careful
|
// an inconsistent state until pos() has been set. Be careful
|
||||||
// what you do with it!
|
// what you do with it!
|
||||||
@ -5339,9 +5339,8 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
cur.pit() = cur.lastpit();
|
cur.pit() = cur.lastpit();
|
||||||
Text const * text = cell(cur.idx())->getText(0);
|
Text const * text = cell(cur.idx())->getText(0);
|
||||||
TextMetrics const & tm = cur.bv().textMetrics(text);
|
TextMetrics const & tm = cur.bv().textMetrics(text);
|
||||||
ParagraphMetrics const & pm =
|
ParagraphMetrics const & pm = tm.parMetrics(cur.lastpit());
|
||||||
tm.parMetrics(cur.lastpit());
|
cur.pos() = tm.getPosNearX(pm.rows().back(), xtarget).first;
|
||||||
cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, xtarget);
|
|
||||||
cur.setCurrentFont();
|
cur.setCurrentFont();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user