reduce number of metrics calls in InsetTabular calculate_dimensions_

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7301 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-17 09:10:16 +00:00
parent dfbd44997a
commit b853229344
5 changed files with 30 additions and 17 deletions

View File

@ -11,6 +11,8 @@
* rowpainter.C:
* text2.C: don't call inset->update() anymore
* metricsinfo.[Ch]: add convenience constructor
2003-07-16 André Pönitz <poenitz@gmx.net>
* lyxcursor.[Ch]:

View File

@ -145,9 +145,7 @@ int Inset::latexTextWidth(BufferView * bv) const
int Inset::ascent(BufferView * bv, LyXFont const & font) const
{
Dimension dim;
MetricsInfo mi;
mi.base.bv = bv;
mi.base.font = font;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.ascent();
}
@ -156,9 +154,7 @@ int Inset::ascent(BufferView * bv, LyXFont const & font) const
int Inset::descent(BufferView * bv, LyXFont const & font) const
{
Dimension dim;
MetricsInfo mi;
mi.base.bv = bv;
mi.base.font = font;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.descent();
}
@ -167,9 +163,7 @@ int Inset::descent(BufferView * bv, LyXFont const & font) const
int Inset::width(BufferView * bv, LyXFont const & font) const
{
Dimension dim;
MetricsInfo mi;
mi.base.bv = bv;
mi.base.font = font;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.width();
}

View File

@ -1245,10 +1245,11 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c
if ((need_update != INIT) &&
(the_locking_inset == tabular.getCellInset(actcell))) {
for(int i = 0; i < tabular.columns(); ++i) {
maxAsc = max(tabular.getCellInset(actrow, i)->ascent(bv, font),
maxAsc);
maxDesc = max(tabular.getCellInset(actrow, i)->descent(bv, font),
maxDesc);
Dimension dim;
MetricsInfo mi(bv, font);
tabular.getCellInset(actrow, i)->metrics(mi, dim);
maxAsc = max(dim.asc, maxAsc);
maxDesc = max(dim.des, maxDesc);
}
changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font));
changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed;
@ -1262,10 +1263,12 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c
if (tabular.isPartOfMultiColumn(i,j))
continue;
++cell;
inset = tabular.getCellInset(cell);
maxAsc = max(maxAsc, inset->ascent(bv, font));
maxDesc = max(maxDesc, inset->descent(bv, font));
changed = tabular.setWidthOfCell(cell, inset->width(bv, font)) || changed;
Dimension dim;
MetricsInfo mi(bv, font);
tabular.getCellInset(cell)->metrics(mi, dim);
maxAsc = max(maxAsc, dim.asc);
maxDesc = max(maxDesc, dim.des);
changed = tabular.setWidthOfCell(cell, dim.wid) || changed;
}
changed = tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;

View File

@ -16,11 +16,21 @@ MetricsBase::MetricsBase()
MetricsBase::MetricsBase(BufferView * b, LyXFont const & f)
: bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
restrictwidth(false), textwidth(0)
{}
MetricsInfo::MetricsInfo()
{}
MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font)
: base(bv, font)
{}
PainterInfo::PainterInfo(BufferView * bv)

View File

@ -27,6 +27,8 @@ enum Styles {
struct MetricsBase {
///
MetricsBase();
///
MetricsBase(BufferView * bv, LyXFont const & font);
/// the current view
BufferView * bv;
@ -50,6 +52,8 @@ struct MetricsBase {
struct MetricsInfo {
///
MetricsInfo();
///
MetricsInfo(BufferView * bv, LyXFont const & font);
///
MetricsBase base;