On Mon, Jul 21, 2003 at 07:54:30PM +0100, John Levon wrote: > This moves the inset metrics update from the (very frequent) > singleWidth() function into rowBreakPoint(). This has two advantages : > > o no metrics recalculation for something that should be const-like > o we can work out the remaining width in order to break inset contents > properly > > Please test it. Note that this only ensures that the text contents > itself doesn't extend past the right of the screen (try insert footnote > on clean CVS for comparison). > > The actual red frame drawing itself is a bit tougher. I'm looking into > it.
The red frame could wait... just a few pixels off and I've not seen a situation where it hampers usability. > -#if 1 > -#warning inset->update FIXME > - // this IS needed otherwise on initialitation we don't get the > fill > - // of the row right (ONLY on initialization if we read a file!) > - // should be changed! (Jug 20011204) > - //tmpinset->update(bv()); > - Dimension dim; > - MetricsInfo mi(bv(), font, workWidth()); > - tmpinset->metrics(mi, dim); > - return dim.wid; > -#else > + > return tmpinset->width(); > -#endif Ah good. Last time I tried that there were massive drawing problems immediately after buffer loading. If that works now, we are moving in the right direction. > } > return 0; > } > @@ -826,26 +815,38 @@ pos_type LyXText::rowBreakPoint(Row cons > > char const c = pit->getChar(i); > > - int thiswidth; > + int labeladdwidth = 0; > > // add the auto-hfill from label end to the body > if (body_pos && i == body_pos) { > - thiswidth = font_metrics::width(layout->labelsep, > + labeladdwidth = font_metrics::width(layout->labelsep, > getLabelFont(bv()->buffer(), pit)); > if (pit->isLineSeparator(i - 1)) > - thiswidth -= singleWidth(pit, i - 1); > + labeladdwidth -= singleWidth(pit, i - 1); > int left_margin = labelEnd(row); > - if (thiswidth + x < left_margin) > - thiswidth = left_margin - x; > - thiswidth += singleWidth(pit, i, c); > + if (labeladdwidth + x < left_margin) > + labeladdwidth = left_margin - x; > + } Good. > + > + int thiswidth; > + > + Inset * in = pit->isInset(i) ? pit->getInset(i) : 0; > + /* update the metrics */ > + if (in) { > + LyXFont const font = getFont(bv()->buffer(), pit, pos); > + Dimension dim; > + MetricsInfo mi(bv(), font, workWidth() - (x + labeladdwidth)); > + in->metrics(mi, dim); > + thiswidth = dim.wid; Ah... so it is still needed. Pity. Maybe we should move the metrics calls even higher to whatever calls rowBreakPoint(). Sort of metrics() for paragraphs or such. I think we should try hard to get two-phase-drawing for the texts (not just for the inset). > } else { > thiswidth = singleWidth(pit, i, c); > } > > + thiswidth += labeladdwidth; > + > x += thiswidth; > chunkwidth += thiswidth; > > - Inset * in = pit->isInset(i) ? pit->getInset(i) : 0; > fullrow = (in && (in->display() || in->needFullRow())); > > // break before a character that will fall off Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)