fix two metrics bug + remove an extra metrics call

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19954 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2007-08-31 17:32:27 +00:00
parent cc6fe67c35
commit d44c6722f0
3 changed files with 6 additions and 7 deletions

View File

@ -128,24 +128,22 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstItera
bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
int const width_offset = TEXT_TO_INSET_OFFSET / 2; int const width_offset = TEXT_TO_INSET_OFFSET / 2;
mi.base.textwidth -= width_offset;
labelwidth_ = theFontMetrics(mi.base.font).width(full_label_); labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
// add some space to separate the label from the inset text // add some space to separate the label from the inset text
labelwidth_ += 2 * TEXT_TO_INSET_OFFSET; labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
dim.wid = labelwidth_; dim.wid = labelwidth_;
Dimension textdim; Dimension textdim;
InsetText::metrics(mi, textdim); dim.wid += width_offset;
// Correct for button width, and re-fit // Correct for button and label width
mi.base.textwidth -= dim.wid; mi.base.textwidth -= dim.wid;
InsetText::metrics(mi, textdim); InsetText::metrics(mi, textdim);
mi.base.textwidth += dim.wid;
dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des); dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des);
dim.asc = textdim.asc; dim.asc = textdim.asc;
dim.wid += textdim.wid; dim.wid += textdim.wid;
dim.asc += TEXT_TO_INSET_OFFSET; dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET; dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += width_offset;
mi.base.textwidth += width_offset;
bool const changed = dim_ != dim; bool const changed = dim_ != dim;
dim_ = dim; dim_ = dim;
return changed; return changed;

View File

@ -219,6 +219,7 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
// Correct for button width, and re-fit // Correct for button width, and re-fit
mi.base.textwidth -= dim.wid; mi.base.textwidth -= dim.wid;
InsetText::metrics(mi, textdim_); InsetText::metrics(mi, textdim_);
mi.base.textwidth += dim.wid;
dim.wid += textdim_.wid; dim.wid += textdim_.wid;
dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des); dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des);
dim.asc = textdim_.asc; dim.asc = textdim_.asc;

View File

@ -170,15 +170,15 @@ bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
TextMetrics & tm = mi.base.bv->textMetrics(&text_); TextMetrics & tm = mi.base.bv->textMetrics(&text_);
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl; //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
mi.base.textwidth -= 2 * border_;
font_ = mi.base.font; font_ = mi.base.font;
// Hand font through to contained lyxtext: // Hand font through to contained lyxtext:
text_.font_ = mi.base.font; text_.font_ = mi.base.font;
mi.base.textwidth -= 2 * border_;
tm.metrics(mi, dim); tm.metrics(mi, dim);
mi.base.textwidth += 2 * border_;
dim.asc += border_; dim.asc += border_;
dim.des += border_; dim.des += border_;
dim.wid += 2 * border_; dim.wid += 2 * border_;
mi.base.textwidth += 2 * border_;
bool const changed = dim_ != dim; bool const changed = dim_ != dim;
dim_ = dim; dim_ = dim;
return changed; return changed;