This fixes a bug in InsetCollapsable::metrics, where textwidth was not restored
2 bugs in InsetCaption::metrics - textwidth was not restored - remove an extra metrics call (maybe it should be better to use Changers to avoid this kind of problems?) Abdel or Martin you are the players in this area, is this ok? A/
Index: insets/InsetCaption.cpp =================================================================== --- insets/InsetCaption.cpp (revision 19953) +++ insets/InsetCaption.cpp (working copy) @@ -128,24 +128,22 @@ bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const { int const width_offset = TEXT_TO_INSET_OFFSET / 2; - mi.base.textwidth -= width_offset; labelwidth_ = theFontMetrics(mi.base.font).width(full_label_); // add some space to separate the label from the inset text labelwidth_ += 2 * TEXT_TO_INSET_OFFSET; dim.wid = labelwidth_; Dimension textdim; - InsetText::metrics(mi, textdim); - // Correct for button width, and re-fit + dim.wid += width_offset; + // Correct for button and label width mi.base.textwidth -= dim.wid; InsetText::metrics(mi, textdim); + mi.base.textwidth += dim.wid; dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des); dim.asc = textdim.asc; dim.wid += textdim.wid; dim.asc += TEXT_TO_INSET_OFFSET; dim.des += TEXT_TO_INSET_OFFSET; - dim.wid += width_offset; - mi.base.textwidth += width_offset; bool const changed = dim_ != dim; dim_ = dim; return changed; Index: insets/InsetCollapsable.cpp =================================================================== --- insets/InsetCollapsable.cpp (revision 19953) +++ insets/InsetCollapsable.cpp (working copy) @@ -219,6 +219,7 @@ // Correct for button width, and re-fit mi.base.textwidth -= dim.wid; InsetText::metrics(mi, textdim_); + mi.base.textwidth += dim.wid; dim.wid += textdim_.wid; dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des); dim.asc = textdim_.asc; Index: insets/InsetText.cpp =================================================================== --- insets/InsetText.cpp (revision 19953) +++ insets/InsetText.cpp (working copy) @@ -170,15 +170,15 @@ TextMetrics & tm = mi.base.bv->textMetrics(&text_); //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl; - mi.base.textwidth -= 2 * border_; font_ = mi.base.font; // Hand font through to contained lyxtext: text_.font_ = mi.base.font; + mi.base.textwidth -= 2 * border_; tm.metrics(mi, dim); + mi.base.textwidth += 2 * border_; dim.asc += border_; dim.des += border_; dim.wid += 2 * border_; - mi.base.textwidth += 2 * border_; bool const changed = dim_ != dim; dim_ = dim; return changed;