Compare commits

..

No commits in common. "629a692ce28db51a8d49ca17f61e311947de8437" and "6701a5d55c17e66c0db466d6a0cc52ce2883329e" have entirely different histories.

5 changed files with 15 additions and 33 deletions

View File

@ -1197,7 +1197,8 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) const
right_pos = -1;
Row const & row = textRow();
Row::const_iterator cit = row.findElement(pos(), boundary());
double dummy = 0;
Row::const_iterator cit = row.findElement(pos(), boundary(), dummy);
// Handle the case of empty row
if (cit == row.end()) {
if (row.isRTL())
@ -2550,8 +2551,6 @@ void Cursor::checkBufferStructure()
void Cursor::moveToClosestEdge(int const x, bool const edit)
{
if (Inset const * inset = nextInset()) {
// This is only used in mathed.
LATTEST(inset->asInsetMath());
// stay in front of insets for which we want to open the dialog
// (e.g. InsetMathSpace).
if (edit && (inset->hasSettings() || !inset->contextMenuName().empty()))

View File

@ -753,9 +753,8 @@ void Row::reverseRTL()
reverse(elements_.begin(), elements_.end());
}
Row::const_iterator const
Row::findElementHelper(pos_type const pos, bool const boundary, double & x) const
Row::findElement(pos_type const pos, bool const boundary, double & x) const
{
/**
* When boundary is true, position i is in the row element (pos, endpos)
@ -804,19 +803,4 @@ Row::findElementHelper(pos_type const pos, bool const boundary, double & x) cons
}
Row::const_iterator const Row::findElement(pos_type const pos, bool const boundary) const
{
double dummy;
return findElementHelper(pos, boundary, dummy);
}
double Row::pos2x(pos_type const pos, bool const boundary) const
{
double x;
findElementHelper(pos, boundary, x);
return x;
}
} // namespace lyx

View File

@ -257,10 +257,6 @@ public:
* adjusted to the actual pixel position.
*/
std::pair<pos_type, bool> x2pos(int & x) const;
/** Return the pixel position that corresponds to the position and
* boundary.
*/
double pos2x(pos_type const pos, bool const boundary) const;
///
void add(pos_type pos, Inset const * ins, Dimension const & dim,
@ -335,8 +331,8 @@ public:
///
void needsChangeBar(bool ncb) { changebar_ = ncb; }
/// Find row element that contains \c pos.
const_iterator const findElement(pos_type pos, bool boundary) const;
/// Find row element that contains \c pos, and compute x offset.
const_iterator const findElement(pos_type pos, bool boundary, double & x) const;
friend std::ostream & operator<<(std::ostream & os, Row const & row);
@ -376,9 +372,6 @@ private:
*/
bool sameString(Font const & f, Change const & ch) const;
/// Find row element that contains \c pos, and compute x offset.
const_iterator const findElementHelper(pos_type pos, bool boundary, double & x) const;
///
Elements elements_;

View File

@ -125,9 +125,10 @@ void RowPainter::paintInset(Row::Element const & e) const
pi_.selected = pi_selected;
#ifdef DEBUG_METRICS
int const x2 = x1 + e.dim.wid;
int const y1 = yo_ + e.dim.des;
int const y2 = yo_ - e.dim.asc;
Dimension const & dim = pi_.base.bv->coordCache().insets().dim(e.inset);
int const x2 = x1 + dim.wid;
int const y1 = yo_ + dim.des;
int const y2 = yo_ - dim.asc;
pi_.pain.line(x1, y1, x1, y2, Color_green);
pi_.pain.line(x1, y1, x2, y1, Color_green);
pi_.pain.line(x2, y1, x2, y2, Color_green);

View File

@ -1691,7 +1691,12 @@ int TextMetrics::cursorX(CursorSlice const & sl,
if (pm.rows().empty())
return 0;
Row const & row = pm.getRow(sl.pos(), boundary);
return row.pos2x(sl.pos(), boundary);
pos_type const pos = sl.pos();
double x = 0;
row.findElement(pos, boundary, x);
return int(x);
}