Compute a height from current font and current cell vertical
dimensions in MathData::metrics(), because this is where current font
is known.
Introduce BufferView::setCaretAscentDescent to remember this value.
This mechanism is not used for text because Cursor::current_font is
restored by undo, and the caret height would not be changed then. But
in principle it is doable.
(cherry picked from commit
90cfe4ec3b4ff22ef798a63e98ca70d0d33a1656)
struct BufferView::Private
{
- Private(BufferView & bv) : update_strategy_(FullScreenUpdate),
+ Private(BufferView & bv) :
+ update_strategy_(FullScreenUpdate),
update_flags_(Update::Force),
wh_(0), cursor_(bv),
anchor_pit_(0), anchor_ypos_(0),
last_inset_(0), clickable_inset_(false),
mouse_position_cache_(),
bookmark_edit_position_(-1), gui_(0),
- horiz_scroll_offset_(0)
+ horiz_scroll_offset_(0),
+ caret_ascent_(0), caret_descent_(0)
{
xsel_cache_.set = false;
}
/// a slice pointing to the start of the row where cursor was
/// at previous draw event
CursorSlice last_row_slice_;
+
+ // The vertical size of the blinking caret. Only used for math
+ // Using it for text could be bad when undo restores the cursor
+ // current font, since the caret size could become wrong.
+ int caret_ascent_;
+ int caret_descent_;
};
}
+void BufferView::setCaretAscentDescent(int asc, int des)
+{
+ d->caret_ascent_ = asc;
+ d->caret_descent_ = des;
+}
+
+
void BufferView::caretPosAndHeight(Point & p, int & h) const
{
+ int asc, des;
Cursor const & cur = cursor();
- Font const font = cur.real_current_font;
- frontend::FontMetrics const & fm = theFontMetrics(font);
- int const asc = fm.maxAscent();
- int const des = fm.maxDescent();
+ if (cur.inMathed()) {
+ asc = d->caret_ascent_;
+ des = d->caret_descent_;
+ } else {
+ Font const font = cur.real_current_font;
+ frontend::FontMetrics const & fm = theFontMetrics(font);
+ asc = fm.maxAscent();
+ des = fm.maxDescent();
+ }
h = asc + des;
p = getPos(cur);
p.y_ -= asc;
bool paragraphVisible(DocIterator const & dit) const;
/// is the cursor currently visible in the view
bool cursorInView(Point const & p, int h) const;
+ /// set the ascent and descent of the caret
+ void setCaretAscentDescent(int asc, int des);
/// get the position and height of the caret
void caretPosAndHeight(Point & p, int & h) const;
void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
{
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
+ BufferView * bv = mi.base.bv;
int const Iascent = fm.dimension('I').ascent();
int xascent = fm.dimension('x').ascent();
if (xascent >= Iascent)
MathRow mrow(mi, this);
mrow.metrics(mi, dim);
- mrow_cache_[mi.base.bv] = mrow;
- kerning_ = mrow.kerning(mi.base.bv);
+ mrow_cache_[bv] = mrow;
+ kerning_ = mrow.kerning(bv);
// Set a minimal ascent/descent for the cell
if (tight)
dim.des = max(dim.des, fm.maxDescent());
}
+ // This is one of the the few points where the drawing font is known,
+ // so that we can set the caret vertical dimensions.
+ Cursor & cur = bv->cursor();
+ if (cur.inMathed() && &cur.cell() == this)
+ bv->setCaretAscentDescent(min(dim.asc, fm.maxAscent()),
+ min(dim.des, fm.maxDescent()));
+
// Cache the dimension.
- mi.base.bv->coordCache().arrays().add(this, dim);
+ bv->coordCache().arrays().add(this, dim);
}
to relevant directories) by setting the preference
\use_native_filedialog true
+- Let caret height depend on character size in math editor.
+
- Handle properly top/bottom of inset with mac-like cursor movement
(bug 10701).
- Improve rendering of square roots in math editor (bug 10814).
+- Set minimum height for math cells (bug 11050).
+
- Fix display of citation labels when pasting from a document
with other citation type (bug 10829).