mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Get rid of Inset::setDimCache
This helper method is used to set the inset dimension cache at metrics time. However this is already done by the metrics code itself (MathRow::metrics, TextMetrics::redoParagraph), so that there is no need to do this same work again in a different place. Also, InsetPhantom::metrics is removed, since it does not do anything interesting. This commit comes with a mild risk attached (it might be that some of these calls were useful after all!), but all of this is fixable.
This commit is contained in:
parent
02e82157ec
commit
7f6f56f40a
@ -625,12 +625,6 @@ ColorCode Inset::labelColor() const
|
||||
}
|
||||
|
||||
|
||||
void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
|
||||
{
|
||||
mi.base.bv->coordCache().insets().add(this, dim);
|
||||
}
|
||||
|
||||
|
||||
Buffer const * Inset::updateFrontend() const
|
||||
{
|
||||
//FIXME (Abdel 03/12/10): see bugs #6814 and #6949
|
||||
|
@ -216,8 +216,6 @@ public:
|
||||
int xo(BufferView const & bv) const;
|
||||
/// last drawn position for 'important' insets
|
||||
int yo(BufferView const & bv) const;
|
||||
///
|
||||
void setDimCache(MetricsInfo const &, Dimension const &) const;
|
||||
/// do we cover screen position x/y?
|
||||
bool covers(BufferView const & bv, int x, int y) const;
|
||||
/// get the screen positions of the cursor (see note in Cursor.cpp)
|
||||
|
@ -188,8 +188,6 @@ void InsetIPA::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.des += TEXT_TO_INSET_OFFSET;
|
||||
// insert a one pixel gap
|
||||
dim.wid += 1;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
Dimension dim_dummy;
|
||||
MetricsInfo mi_dummy = mi;
|
||||
InsetText::metrics(mi_dummy, dim_dummy);
|
||||
|
@ -173,9 +173,6 @@ void InsetIPADeco::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
theFontMetrics(font).rectText(label, w, a, d);
|
||||
dim.des += int(d * 1.5);
|
||||
}
|
||||
|
||||
// cache the inset dimension
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
@ -413,7 +410,6 @@ void InsetIPAChar::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
docstring ds(s.begin(), s.end());
|
||||
dim.wid = fm.width(ds);
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,9 +132,6 @@ void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
dim.asc = max(fm.maxAscent(), offset_ + height_);
|
||||
dim.des = max(fm.maxDescent(), - offset_);
|
||||
|
||||
// Cache the inset dimension
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,8 +103,6 @@ void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.asc = defaultRowHeight();
|
||||
dim.des = defaultRowHeight();
|
||||
dim.wid = mi.base.textwidth;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,15 +135,6 @@ docstring InsetPhantom::layoutName() const
|
||||
}
|
||||
|
||||
|
||||
void InsetPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
|
||||
// cache the inset dimension
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetPhantom::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// draw the text
|
||||
|
@ -62,8 +62,6 @@ private:
|
||||
///
|
||||
docstring layoutName() const;
|
||||
///
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &) const;
|
||||
|
@ -174,8 +174,6 @@ void InsetPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.des += TEXT_TO_INSET_OFFSET;
|
||||
// insert a one pixel gap
|
||||
dim.wid += 1;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
Dimension dim_dummy;
|
||||
MetricsInfo mi_dummy = mi;
|
||||
InsetText::metrics(mi_dummy, dim_dummy);
|
||||
|
@ -260,8 +260,6 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
// shut up compiler
|
||||
break;
|
||||
}
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,8 +129,6 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
if (dim.wid == 0)
|
||||
dim.wid = fm.width(s);
|
||||
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,8 +150,6 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.asc = height / 2 + (a - d) / 2; // align cursor with the
|
||||
dim.des = height - dim.asc; // label text
|
||||
dim.wid = ADD_TO_VSPACE_WIDTH + 2 * vspace_arrow_size + 5 + w;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,8 +43,6 @@ void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
button_.update(screenLabel(), true);
|
||||
}
|
||||
button_.metrics(mi, dim);
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -589,8 +589,6 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
*/
|
||||
dim.wid += leftMargin() + rightMargin();
|
||||
metricsMarkers2(mi, dim);
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -515,8 +515,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
if (display())
|
||||
dim.des += displayMargin();
|
||||
}
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -550,9 +548,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
math_font_max_dim(mi.base.font, asc, des);
|
||||
dim.asc = max(dim.asc, asc);
|
||||
dim.des = max(dim.des, des);
|
||||
// Cache the inset dimension.
|
||||
// FIXME: This will overwrite InsetMathGrid dimension, is that OK?
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
@ -578,8 +578,6 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.wid += 6;
|
||||
dim.des += 2;
|
||||
dim.asc += 2;
|
||||
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user