mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
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:
parent
dfbd44997a
commit
b853229344
@ -11,6 +11,8 @@
|
|||||||
* rowpainter.C:
|
* rowpainter.C:
|
||||||
* text2.C: don't call inset->update() anymore
|
* text2.C: don't call inset->update() anymore
|
||||||
|
|
||||||
|
* metricsinfo.[Ch]: add convenience constructor
|
||||||
|
|
||||||
2003-07-16 André Pönitz <poenitz@gmx.net>
|
2003-07-16 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* lyxcursor.[Ch]:
|
* lyxcursor.[Ch]:
|
||||||
|
@ -145,9 +145,7 @@ int Inset::latexTextWidth(BufferView * bv) const
|
|||||||
int Inset::ascent(BufferView * bv, LyXFont const & font) const
|
int Inset::ascent(BufferView * bv, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
MetricsInfo mi;
|
MetricsInfo mi(bv, font);
|
||||||
mi.base.bv = bv;
|
|
||||||
mi.base.font = font;
|
|
||||||
metrics(mi, dim);
|
metrics(mi, dim);
|
||||||
return dim.ascent();
|
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
|
int Inset::descent(BufferView * bv, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
MetricsInfo mi;
|
MetricsInfo mi(bv, font);
|
||||||
mi.base.bv = bv;
|
|
||||||
mi.base.font = font;
|
|
||||||
metrics(mi, dim);
|
metrics(mi, dim);
|
||||||
return dim.descent();
|
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
|
int Inset::width(BufferView * bv, LyXFont const & font) const
|
||||||
{
|
{
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
MetricsInfo mi;
|
MetricsInfo mi(bv, font);
|
||||||
mi.base.bv = bv;
|
|
||||||
mi.base.font = font;
|
|
||||||
metrics(mi, dim);
|
metrics(mi, dim);
|
||||||
return dim.width();
|
return dim.width();
|
||||||
}
|
}
|
||||||
|
@ -1245,10 +1245,11 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c
|
|||||||
if ((need_update != INIT) &&
|
if ((need_update != INIT) &&
|
||||||
(the_locking_inset == tabular.getCellInset(actcell))) {
|
(the_locking_inset == tabular.getCellInset(actcell))) {
|
||||||
for(int i = 0; i < tabular.columns(); ++i) {
|
for(int i = 0; i < tabular.columns(); ++i) {
|
||||||
maxAsc = max(tabular.getCellInset(actrow, i)->ascent(bv, font),
|
Dimension dim;
|
||||||
maxAsc);
|
MetricsInfo mi(bv, font);
|
||||||
maxDesc = max(tabular.getCellInset(actrow, i)->descent(bv, font),
|
tabular.getCellInset(actrow, i)->metrics(mi, dim);
|
||||||
maxDesc);
|
maxAsc = max(dim.asc, maxAsc);
|
||||||
|
maxDesc = max(dim.des, maxDesc);
|
||||||
}
|
}
|
||||||
changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font));
|
changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font));
|
||||||
changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed;
|
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))
|
if (tabular.isPartOfMultiColumn(i,j))
|
||||||
continue;
|
continue;
|
||||||
++cell;
|
++cell;
|
||||||
inset = tabular.getCellInset(cell);
|
Dimension dim;
|
||||||
maxAsc = max(maxAsc, inset->ascent(bv, font));
|
MetricsInfo mi(bv, font);
|
||||||
maxDesc = max(maxDesc, inset->descent(bv, font));
|
tabular.getCellInset(cell)->metrics(mi, dim);
|
||||||
changed = tabular.setWidthOfCell(cell, inset->width(bv, font)) || changed;
|
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.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
|
||||||
changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
|
changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
|
||||||
|
@ -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()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font)
|
||||||
|
: base(bv, font)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PainterInfo::PainterInfo(BufferView * bv)
|
PainterInfo::PainterInfo(BufferView * bv)
|
||||||
|
@ -27,6 +27,8 @@ enum Styles {
|
|||||||
struct MetricsBase {
|
struct MetricsBase {
|
||||||
///
|
///
|
||||||
MetricsBase();
|
MetricsBase();
|
||||||
|
///
|
||||||
|
MetricsBase(BufferView * bv, LyXFont const & font);
|
||||||
|
|
||||||
/// the current view
|
/// the current view
|
||||||
BufferView * bv;
|
BufferView * bv;
|
||||||
@ -50,6 +52,8 @@ struct MetricsBase {
|
|||||||
struct MetricsInfo {
|
struct MetricsInfo {
|
||||||
///
|
///
|
||||||
MetricsInfo();
|
MetricsInfo();
|
||||||
|
///
|
||||||
|
MetricsInfo(BufferView * bv, LyXFont const & font);
|
||||||
|
|
||||||
///
|
///
|
||||||
MetricsBase base;
|
MetricsBase base;
|
||||||
|
Loading…
Reference in New Issue
Block a user