Merge branch 'master' into biblatex2

This commit is contained in:
Juergen Spitzmueller 2017-01-12 14:29:55 +01:00
commit 239b9919ff
7 changed files with 31 additions and 19 deletions

View File

@ -39,6 +39,25 @@ docstring InsetMathBig::name() const
} }
MathClass InsetMathBig::mathClass() const
{
/* The class of the delimiter depends on the type (l, m, r, nothing).
* For example, the definition of \bigl in LaTeX sources is
* \def\bigl{\mathopen\big}
*/
switch(name_.back()) {
case 'l':
return MC_OPEN;
case 'm':
return MC_REL;
case 'r':
return MC_CLOSE;
default:
return MC_ORD;
}
}
Inset * InsetMathBig::clone() const Inset * InsetMathBig::clone() const
{ {
return new InsetMathBig(*this); return new InsetMathBig(*this);
@ -49,9 +68,9 @@ InsetMathBig::size_type InsetMathBig::size() const
{ {
// order: big Big bigg Bigg biggg Biggg // order: big Big bigg Bigg biggg Biggg
// 0 1 2 3 4 5 // 0 1 2 3 4 5
char_type const c = name_[name_.size() - 1]; char_type const c = name_.back();
int const base_size = (c == 'l' || c == 'm' || c == 'r') ? 4 : 3; int const base_size = (c == 'l' || c == 'm' || c == 'r') ? 4 : 3;
return name_[0] == 'B' ? return name_.front() == 'B' ?
2 * (name_.size() - base_size) + 1: 2 * (name_.size() - base_size) + 1:
2 * (name_.size() - base_size); 2 * (name_.size() - base_size);
} }

View File

@ -24,6 +24,8 @@ public:
InsetMathBig(docstring const & name, docstring const & delim); InsetMathBig(docstring const & name, docstring const & delim);
/// ///
docstring name() const; docstring name() const;
/// class is different for l(eft), r(ight) and m(iddle)
MathClass mathClass() const;
/// ///
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;
/// ///

View File

@ -42,7 +42,7 @@ Inset * InsetMathCancelto::clone() const
void InsetMathCancelto::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathCancelto::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
Changer dummy = mi.base.changeEnsureMath(); Changer dummy = mi.base.changeEnsureMath();
InsetMathNest::metrics(mi); cellsMetrics(mi);
Dimension const & dim0 = cell(0).dimension(*mi.base.bv); Dimension const & dim0 = cell(0).dimension(*mi.base.bv);
Dimension const & dim1 = cell(1).dimension(*mi.base.bv); Dimension const & dim1 = cell(1).dimension(*mi.base.bv);
dim.asc = max(dim0.ascent() + 2, dim0.ascent() + dim1.ascent()) + 2 + 8; dim.asc = max(dim0.ascent() + 2, dim0.ascent() + dim1.ascent()) + 2 + 8;

View File

@ -176,12 +176,12 @@ void InsetMathNest::cursorPos(BufferView const & bv,
} }
void InsetMathNest::metrics(MetricsInfo const & mi) const void InsetMathNest::cellsMetrics(MetricsInfo const & mi) const
{ {
MetricsInfo m = mi; MetricsInfo m = mi;
for (idx_type i = 0, n = nargs(); i != n; ++i) { for (auto const & cell : cells_) {
Dimension dim; Dimension dim;
cell(i).metrics(m, dim); cell.metrics(m, dim);
} }
} }

View File

@ -33,17 +33,8 @@ public:
/// ///
void setBuffer(Buffer &); void setBuffer(Buffer &);
// The method below hides inset::metrics() intentionally! /// Update the cells metrics
// We have to tell clang not to be fussy about that. void cellsMetrics(MetricsInfo const & mi) const;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#endif
/// the size is usually some sort of convex hull of the cells
void metrics(MetricsInfo const & mi) const;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/// draw background if locked /// draw background if locked
void draw(PainterInfo & pi, int x, int y) const; void draw(PainterInfo & pi, int x, int y) const;
/// draw selection background /// draw selection background

View File

@ -42,7 +42,7 @@ Inset * InsetMathRoot::clone() const
void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
Changer dummy = mi.base.changeEnsureMath(); Changer dummy = mi.base.changeEnsureMath();
InsetMathNest::metrics(mi); cellsMetrics(mi);
Dimension const & dim0 = cell(0).dimension(*mi.base.bv); Dimension const & dim0 = cell(0).dimension(*mi.base.bv);
Dimension const & dim1 = cell(1).dimension(*mi.base.bv); Dimension const & dim1 = cell(1).dimension(*mi.base.bv);
dim.asc = max(dim0.ascent() + 5, dim1.ascent()) + 2; dim.asc = max(dim0.ascent() + 5, dim1.ascent()) + 2;

View File

@ -289,7 +289,7 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) const
// the box is not visible in non-editable context (except for grey macro boxes). // the box is not visible in non-editable context (except for grey macro boxes).
if (e.color != Color_none) if (e.color != Color_none)
pi.pain.rectangle(x + e.before, y - d.ascent(), pi.pain.rectangle(x + e.before, y - d.ascent(),
d.width(), d.height(), e.color); d.width() - 1, d.height() - 1, e.color);
x += d.wid + e.before + e.after; x += d.wid + e.before + e.after;
break; break;
} }