mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
Change getColumnNearX to getPosNearX
The semantics was bad: the old implementation would return pos - row.pos(), and then all user of the function had to re-add row.pos().
This commit is contained in:
parent
9ba97a85f0
commit
f686375eec
@ -17,7 +17,11 @@ What is done:
|
|||||||
metrics are computed. The list of elements is stored in the row
|
metrics are computed. The list of elements is stored in the row
|
||||||
object in visual ordering, not logical.
|
object in visual ordering, not logical.
|
||||||
|
|
||||||
* Re-implement cursorX and getColumnNearX using row elements.
|
* rename getColumnNearX to getPosNearX (and change code accordingly).
|
||||||
|
It does not make sense to return a position relative to the start of
|
||||||
|
row, since nobody needs this.
|
||||||
|
|
||||||
|
* Re-implement cursorX and getPosNearX using row elements.
|
||||||
|
|
||||||
* Implement proper string metrics computation (with cache), when
|
* Implement proper string metrics computation (with cache), when
|
||||||
lyxrc.force_paint_single_char is false. In this case, remove also
|
lyxrc.force_paint_single_char is false. In this case, remove also
|
||||||
@ -34,10 +38,6 @@ Next steps:
|
|||||||
kept for comparison purpose, guarded with KEEP_OLD_METRICS_CODE in
|
kept for comparison purpose, guarded with KEEP_OLD_METRICS_CODE in
|
||||||
order to check computations.
|
order to check computations.
|
||||||
|
|
||||||
* rename getColumnNearX to getPosNearX or x2pos (and change code
|
|
||||||
accordingly). It does not make sense to return a position relative
|
|
||||||
to the start of row, since nobody needs this.
|
|
||||||
|
|
||||||
* Re-implement row painting using row elements. This is not difficult
|
* Re-implement row painting using row elements. This is not difficult
|
||||||
in principle, but the code is intricate and needs some careful
|
in principle, but the code is intricate and needs some careful
|
||||||
analysis. First thing that needs to be done is to break row elements
|
analysis. First thing that needs to be done is to break row elements
|
||||||
|
@ -2090,9 +2090,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
|
|||||||
|
|
||||||
Row const & real_next_row = tm.parMetrics(pit()).rows()[next_row];
|
Row const & real_next_row = tm.parMetrics(pit()).rows()[next_row];
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
pos_type const col = tm.getColumnNearX(pit(), real_next_row,
|
top().pos() = tm.getPosNearX(pit(), real_next_row, xo, bound);
|
||||||
xo, bound);
|
|
||||||
top().pos() = real_next_row.pos() + col;
|
|
||||||
boundary(bound);
|
boundary(bound);
|
||||||
|
|
||||||
updateNeeded |= bv().checkDepm(*this, old);
|
updateNeeded |= bv().checkDepm(*this, old);
|
||||||
|
@ -104,7 +104,7 @@ pos_type Row::Element::x2pos(double &x, bool const low) const
|
|||||||
x = x2;
|
x = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//lyxerr << "=> p=" << i << " x=" << x << endl;
|
//lyxerr << "=> p=" << pos + i << " x=" << x << endl;
|
||||||
return pos + i;
|
return pos + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,7 +1114,7 @@ void TextMetrics::setRowHeight(Row & row, pit_type const pit,
|
|||||||
// x is an absolute screen coord
|
// x is an absolute screen coord
|
||||||
// returns the column near the specified x-coordinate of the row
|
// returns the column near the specified x-coordinate of the row
|
||||||
// x is set to the real beginning of this column
|
// x is set to the real beginning of this column
|
||||||
pos_type TextMetrics::getColumnNearX(pit_type const pit,
|
pos_type TextMetrics::getPosNearX(pit_type const pit,
|
||||||
Row const & row, int & x, bool & boundary) const
|
Row const & row, int & x, bool & boundary) const
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1291,7 +1291,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
|
|||||||
|
|
||||||
if (abs(x2 - x) > 0.1 || boundary != boundary
|
if (abs(x2 - x) > 0.1 || boundary != boundary
|
||||||
|| c != pos) {
|
|| c != pos) {
|
||||||
lyxerr << "getColumnNearX(" << x_orig << "): new=(x=" << x - xo << ", b=" << boundary << ", p=" << pos << "), "
|
lyxerr << "getPosNearX(" << x_orig << "): new=(x=" << x - xo << ", b=" << boundary << ", p=" << pos << "), "
|
||||||
<< "old=(x=" << x2 - xo << ", b=" << boundary2 << ", p=" << c << "), " << row;
|
<< "old=(x=" << x2 - xo << ", b=" << boundary2 << ", p=" << c << "), " << row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1307,7 +1307,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
|
|||||||
return min(col, end - 1 - row.pos());
|
return min(col, end - 1 - row.pos());
|
||||||
#endif // 0
|
#endif // 0
|
||||||
#endif // KEEP_OLD_METRICS_CODE
|
#endif // KEEP_OLD_METRICS_CODE
|
||||||
return pos - row.pos();
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1322,7 +1322,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
|
|||||||
LBUFERR(row < int(pm.rows().size()));
|
LBUFERR(row < int(pm.rows().size()));
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
Row const & r = pm.rows()[row];
|
Row const & r = pm.rows()[row];
|
||||||
return r.pos() + getColumnNearX(pit, r, x, bound);
|
return getPosNearX(pit, r, x, bound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1482,10 +1482,9 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
|
|||||||
|
|
||||||
if (!it) {
|
if (!it) {
|
||||||
// No inset, set position in the text
|
// No inset, set position in the text
|
||||||
bool bound = false; // is modified by getColumnNearX
|
bool bound = false; // is modified by getPosNearX
|
||||||
int xx = x; // is modified by getColumnNearX
|
int xx = x; // is modified by getPosNearX
|
||||||
cur.pos() = row.pos()
|
cur.pos() = getPosNearX(pit, row, xx, bound);
|
||||||
+ getColumnNearX(pit, row, xx, bound);
|
|
||||||
cur.boundary(bound);
|
cur.boundary(bound);
|
||||||
cur.setCurrentFont();
|
cur.setCurrentFont();
|
||||||
cur.setTargetX(xx);
|
cur.setTargetX(xx);
|
||||||
@ -1536,7 +1535,7 @@ void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x, int const
|
|||||||
|
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
int xx = x;
|
int xx = x;
|
||||||
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
|
pos_type const pos = getPosNearX(pit, row, xx, bound);
|
||||||
|
|
||||||
LYXERR(Debug::DEBUG, "setting cursor pit: " << pit << " pos: " << pos);
|
LYXERR(Debug::DEBUG, "setting cursor pit: " << pit << " pos: " << pos);
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ private:
|
|||||||
|
|
||||||
// Temporary public:
|
// Temporary public:
|
||||||
public:
|
public:
|
||||||
/// returns the column near the specified x-coordinate of the row.
|
/// returns the position near the specified x-coordinate of the row.
|
||||||
/// x is an absolute screen coord, it is set to the real beginning
|
/// x is an absolute screen coord, it is set to the real beginning
|
||||||
/// of this column.
|
/// of this column.
|
||||||
pos_type getColumnNearX(pit_type pit, Row const & row, int & x,
|
pos_type getPosNearX(pit_type pit, Row const & row, int & x,
|
||||||
bool & boundary) const;
|
bool & boundary) const;
|
||||||
|
|
||||||
/// returns pos in given par at given x coord.
|
/// returns pos in given par at given x coord.
|
||||||
|
@ -1002,7 +1002,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
|
|||||||
// Find the position of the cursor
|
// Find the position of the cursor
|
||||||
bool bound;
|
bool bound;
|
||||||
int x = d->synthetic_mouse_event_.cmd.x();
|
int x = d->synthetic_mouse_event_.cmd.x();
|
||||||
pos_type const pos = rit->pos() + tm.getColumnNearX(pit, *rit, x, bound);
|
pos_type const pos = tm.getPosNearX(pit, *rit, x, bound);
|
||||||
|
|
||||||
// Set the cursor
|
// Set the cursor
|
||||||
cur.pit() = pit;
|
cur.pit() = pit;
|
||||||
|
Loading…
Reference in New Issue
Block a user