On Fri, Mar 17, 2006 at 01:42:12PM +0100, Georg Baum wrote: > Martin Vermeer wrote: > > > The patch that I proposed restricts going "Wide" to insets having a > > minimum total text height corresponding to more than two rows ("Tall"). > > This appears to work well in my testing. It is still possible to > > construct pathological cases, but ordinary typing even inside a nested > > inset will not normally make the inner inset extend on top of buttons or > > outer text. > > Yes, it works very well for me, too. I still could provoke wide insets, but > in most cases this does not happen anymore. Nice! > > > I attach this patch, to which I have now added the inset methods that I > > discussed about with Georg, and the names you proposed (or at least one > > of them). > > For the other one I think it would be better to use > > virtual InsetText * asInsetText() { return 0; } > > insetad of isTextInsetBased. That is symmetric to > > virtual MathInset * asMathInset() { return 0; }
I committed it to trunk with these changes. Log entry: Changes to the within-inset row rendering caching code. * insets/insetenv.h: * insets/insetcollapsable.h: remove method * insets/insettabular.h: * insets/insetbase.h: rename, add methods * insets/insettext.[Ch]: rename method; add Tall() * paragraph_pimpl.C (Paragraph::Pimpl::simpleTeXSpecialC): rename call * mathed/math_hullinset.h: rename method * rowpainter.C (RowPainter::paintInset): (paintPar): remove isTrueTextInset, move to insets Attached the patch. - Martin
Index: insets/insetenv.h =================================================================== --- insets/insetenv.h (revision 13408) +++ insets/insetenv.h (working copy) @@ -34,8 +34,6 @@ public: /// InsetBase::EDITABLE editable() const { return HIGHLY_EDITABLE; } /// - bool isTextInset() const { return true; } - /// LyXLayout_ptr const & layout() const; /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for Index: insets/insetbase.h =================================================================== --- insets/insetbase.h (revision 13408) +++ insets/insetbase.h (working copy) @@ -21,6 +21,7 @@ class BufferView; class CursorSlice; class FuncRequest; class FuncStatus; +class InsetText; class LaTeXFeatures; class LCursor; class LyXLex; @@ -216,8 +217,10 @@ public: virtual EDITABLE editable() const; /// can we go further down on mouse click? virtual bool descendable() const { return false; } - /// - virtual bool isTextInset() const { return false; } + /// does this contain text that can be change track marked in DVI? + virtual bool canTrackChanges() const { return false; } + /// is this inset based on the TextInset class? + virtual InsetText * asTextInset() const { return 0; } /// return true if the inset should be removed automatically virtual bool autoDelete() const; Index: insets/insettext.h =================================================================== --- insets/insettext.h (revision 13408) +++ insets/insettext.h (working copy) @@ -57,7 +57,9 @@ public: /// EDITABLE editable() const { return HIGHLY_EDITABLE; } /// - bool isTextInset() const { return true; } + bool canTrackChanges() const { return true; } + /// + InsetText * asTextInset() const { return const_cast<InsetText *>(this); } /// int latex(Buffer const &, std::ostream &, OutputParams const &) const; @@ -139,7 +141,9 @@ public: InsetText(InsetText const &); /// bool & Wide() const { return wide_inset_; } - + /// + bool const Tall() const; + protected: /// virtual void doDispatch(LCursor & cur, FuncRequest & cmd); Index: insets/insetcollapsable.h =================================================================== --- insets/insetcollapsable.h (revision 13408) +++ insets/insetcollapsable.h (working copy) @@ -57,8 +57,6 @@ public: /// can we go further down on mouse click? bool descendable() const; /// - bool isTextInset() const { return true; } - /// void setLabel(std::string const & l); /// virtual void setButtonLabel() {} Index: insets/insettabular.h =================================================================== --- insets/insettabular.h (revision 13408) +++ insets/insettabular.h (working copy) @@ -69,7 +69,7 @@ public: /// bool insetAllowed(InsetBase::Code) const { return true; } /// - bool isTextInset() const { return true; } + bool canTrackChanges() const { return true; } /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for insets that may contain several paragraphs */ Index: insets/insettext.C =================================================================== --- insets/insettext.C (revision 13408) +++ insets/insettext.C (working copy) @@ -258,6 +258,12 @@ InsetBase * InsetText::editXY(LCursor & } +bool const InsetText::Tall() const +{ + return text_.ascent() + text_.descent() > 2 * defaultRowHeight(); +} + + void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd) { lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION Index: paragraph_pimpl.C =================================================================== --- paragraph_pimpl.C (revision 13408) +++ paragraph_pimpl.C (working copy) @@ -536,7 +536,7 @@ void Paragraph::Pimpl::simpleTeXSpecialC && runparams.flavor == OutputParams::LATEX && features.isAvailable("dvipost"); - if (inset->isTextInset()) { + if (inset->canTrackChanges()) { column += Changes::latexMarkChange(os, running_change, Change::UNCHANGED, output); running_change = Change::UNCHANGED; Index: mathed/math_hullinset.h =================================================================== --- mathed/math_hullinset.h (revision 13408) +++ mathed/math_hullinset.h (working copy) @@ -189,7 +189,7 @@ public: /// what appears in the minibuffer when opening virtual std::string const editMessage() const; /// - virtual bool isTextInset() const { return true; } + virtual bool canTrackChanges() const { return true; } /// virtual void mutateToText(); /// Index: rowpainter.C =================================================================== --- rowpainter.C (revision 13408) +++ rowpainter.C (working copy) @@ -151,15 +151,6 @@ int RowPainter::leftMargin() const } -bool isTrueTextInset(InsetBase * in) -{ - // Math and tabular insets have isTextInset = true, though they are - // not derived from InsetText. Paint them fully - return (in && in->isTextInset() && in->asMathInset() == 0 - && in->lyxCode() != InsetBase::TABULAR_CODE); -} - - void RowPainter::paintInset(pos_type const pos, LyXFont const & font) { InsetBase const * inset = par_.getInset(pos); @@ -176,8 +167,10 @@ void RowPainter::paintInset(pos_type con InsetBase * in = const_cast<InsetBase *>(inset); // non-wide insets are painted completely. Recursive bool tmp = bv_.repaintAll(); - if (!isTrueTextInset(in) || !static_cast<InsetText*>(in)->Wide()) + if (!in->asTextInset() || !static_cast<InsetText*>(in)->Wide()) { bv_.repaintAll(true); + lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl; + } if (bv_.repaintAll()) inset->drawSelection(pi, int(x_), yo_); inset->draw(pi, int(x_), yo_); @@ -821,9 +814,11 @@ void paintPar for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) { InsetBase* in = const_cast<InsetBase*>(par.getInset(i)); - if (isTrueTextInset(in)) + if (in && in->asTextInset()) { static_cast<InsetText*>(in)->Wide() - = in_inset_alone_on_row; + = in_inset_alone_on_row && + static_cast<InsetText*>(in)->Tall(); + } } // If selection is on, the current row signature differs
pgpCCQy7MjbFU.pgp
Description: PGP signature