Update::flags update_flags_;
///
CoordCache coord_cache_;
+ ///
+ typedef map<MathData const *, MathRow> MathRows;
+ MathRows math_rows_;
/// Estimated average par height for scrollbar.
int wh_;
}
+MathRow const & BufferView::mathRow(MathData const * cell) const
+{
+ auto it = d->math_rows_.find(cell);
+ LATTEST(it != d->math_rows_.end());
+ return it->second;
+}
+
+
+void BufferView::setMathRow(MathData const * cell, MathRow const & mrow)
+{
+ d->math_rows_[cell] = mrow;
+}
+
+
Buffer & BufferView::buffer()
{
return buffer_;
// Clear out the position cache in case of full screen redraw,
d->coord_cache_.clear();
+ d->math_rows_.clear();
// Clear out paragraph metrics to avoid having invalid metrics
// in the cache from paragraphs not relayouted below
int asc, des;
Cursor const & cur = cursor();
if (cur.inMathed()) {
- asc = cur.cell().caretAscent(this);
- des = cur.cell().caretDescent(this);
+ MathRow const & mrow = mathRow(&cur.cell());
+ asc = mrow.caret_ascent;
+ des = mrow.caret_descent;
} else {
Font const font = cur.real_current_font;
frontend::FontMetrics const & fm = theFontMetrics(font);
class Intl;
class Inset;
class Length;
+class MathData;
+class MathRow;
class ParIterator;
class ParagraphMetrics;
class Point;
///
CoordCache const & coordCache() const;
+ ///
+ MathRow const & mathRow(MathData const * cell) const;
+ ///
+ void setMathRow(MathData const * cell, MathRow const & mrow);
+
///
Point getPos(DocIterator const & dit) const;
/// is the paragraph of the cursor visible ?
#endif
-int MathData::caretAscent(BufferView const * bv) const
-{
- return mrow_cache_[bv].caret_ascent;
-}
-
-
-int MathData::caretDescent(BufferView const * bv) const
-{
- return mrow_cache_[bv].caret_descent;
-}
-
-
void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
{
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
// so that we can set the caret vertical dimensions.
mrow.caret_ascent = min(dim.asc, fm.maxAscent());
mrow.caret_descent = min(dim.des, fm.maxDescent());
+ /// do the same for math cells linearized in the row
+ MathRow caret_row = MathRow(mrow.caret_ascent, mrow.caret_descent);
+ for (auto const & e : mrow)
+ if (e.type == MathRow::BEGIN && e.ar)
+ bv->setMathRow(e.ar, caret_row);
// Cache row and dimension.
- mrow_cache_[bv] = mrow;
+ bv->setMathRow(this, mrow);
bv->coordCache().arrays().add(this, dim);
}
setXY(*pi.base.bv, x, y);
drawSelection(pi, x, y);
- MathRow const & mrow = mrow_cache_[pi.base.bv];
+ MathRow const & mrow = pi.base.bv->mathRow(this);
mrow.draw(pi, x, y);
}
#include <cstddef>
#include <vector>
-#include <map>
namespace lyx {
/// Add this array to a math row. Return true if contents got added
bool addToMathRow(MathRow &, MetricsInfo & mi) const;
- // ascent of caret in this cell
- int caretAscent(BufferView const * bv) const;
- /// descent of caret in this cell
- int caretDescent(BufferView const * bv) const;
-
/// rebuild cached metrics information
/** When \c tight is true, the height of the cell will be at least
* the x height of the font. Otherwise, it will be the max height
mutable int kerning_;
Buffer * buffer_;
- /// cached object that describes typeset data
- mutable std::map<BufferView const *, MathRow> mrow_cache_;
-
private:
/// is this an exact match at this position?
bool find1(MathData const & ar, size_type pos) const;
};
///
- MathRow() : caret_ascent(0), caret_descent(0) {};
+ MathRow(int asc = 0, int des = 0) : caret_ascent(asc), caret_descent(des) {};
///
typedef std::vector<Element> Elements;
///