On Sat, Jun 17, 2006 at 11:24:51PM +0300, Martin Vermeer wrote: > On Wed, Jun 14, 2006 at 11:14:19AM +0300, Martin Vermeer wrote: > > ... > > > PS Getting rid of Wide() would only be possible if you have, inside > > insettext, access to the _maximum_ left and right edges of the contained > > text, rather than the _actual_ ones... > > Yesss! This is precisely the solution. Patch forthcoming... > > Nothing as inspiring as a weekend in nature.
Here's the patch you've been looking for... it simplifies things which is always a good sign. - Martin
Index: rowpainter.C =================================================================== --- rowpainter.C (revision 14139) +++ rowpainter.C (working copy) @@ -817,8 +817,7 @@ if (in) { InsetText const * const t = in->asTextInset(); if (t) - t->Wide() = in_inset_alone_on_row && - t->Tall(); + t->Wide() = in_inset_alone_on_row; } } @@ -836,8 +835,8 @@ // (if paragraph background was not cleared) if (!repaintAll && (!in_inset_alone_on_row || row_has_changed)) { - pi.pain.fillRectangle(( rowno ? 0 : x - 10 ), y - rit->ascent(), - pi.base.bv->workWidth(), rit->height(), + pi.pain.fillRectangle(x, y - rit->ascent(), + text.maxwidth_, rit->height(), text.backgroundColor()); // If outer row has changed, force nested // insets to repaint completely Index: insets/insettext.C =================================================================== --- insets/insettext.C (revision 14139) +++ insets/insettext.C (working copy) @@ -207,13 +207,8 @@ int const w = text_.width() + 2 * border_; int const a = text_.ascent() + border_; int const h = a + text_.descent() + border_; - int const ww = pi.base.bv->workWidth(); - if (w > ww - 40 || Wide()) { - pi.pain.line(0, y - a, ww, y - a, frameColor()); - pi.pain.line(0, y - a + h, ww, y - a + h, frameColor()); - } else { - pi.pain.rectangle(x, y - a, w, h, frameColor()); - } + pi.pain.rectangle(x, y - a, (Wide() ? text_.maxwidth_ : w), h, + frameColor()); } } @@ -223,13 +218,8 @@ int const w = text_.width() + 2 * border_; int const a = text_.ascent() + border_; int const h = a + text_.descent() + border_; - int const ww = pi.base.bv->workWidth(); - if (Wide()) - pi.pain.fillRectangle(0, y - a, ww, h, - backgroundColor()); - else - pi.pain.fillRectangle(x, y - a, w, h, - backgroundColor()); + pi.pain.fillRectangle(x, y - a, (Wide() ? text_.maxwidth_ : w), h, + backgroundColor()); text_.drawSelection(pi, x, y); } @@ -258,12 +248,6 @@ } -bool const InsetText::Tall() const -{ - return text_.ascent() + text_.descent() > 2 * defaultRowHeight(); -} - - void InsetText::forceParagraphsToDefault(LCursor & cur) { BufferParams const & bp = cur.buffer().params(); Index: insets/insettext.h =================================================================== --- insets/insettext.h (revision 14139) +++ insets/insettext.h (working copy) @@ -142,8 +142,6 @@ /// bool & Wide() const { return wide_inset_; } /// - bool const Tall() const; - /// void forceParagraphsToDefault(LCursor & cur); protected: Index: insets/insetcollapsable.C =================================================================== --- insets/insetcollapsable.C (revision 14139) +++ insets/insetcollapsable.C (working copy) @@ -140,6 +140,9 @@ InsetText::metrics(mi, textdim_); openinlined_ = textdim_.wid + 2 * dim.wid <= mi.base.textwidth; if (openinlined_) { + // Correct for button width, and re-fit + mi.base.textwidth -= dim.wid; + InsetText::metrics(mi, textdim_); dim.wid += textdim_.wid; dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des); dim.asc = textdim_.asc;
pgpC5crPO5KIR.pgp
Description: PGP signature