From: André Pönitz Date: Fri, 15 Aug 2003 14:54:19 +0000 (+0000) Subject: rowpainter.C: remove extra metrics calls X-Git-Tag: 1.6.10~16278 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=040a03e4a41b660e3f2c446257d0301e651d5489;p=features.git rowpainter.C: remove extra metrics calls lyxtext.h: merge the two constructors into a single one, pass reference to owner's par list BufferView_pimpl.C: text.C: text2.C: adjust git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7557 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 6e1e8ba482..e47e994ac5 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -418,7 +418,7 @@ void BufferView::Pimpl::resizeCurrentBuffer() textcache.show(lyxerr, "resizeCurrentBuffer"); } else { lyxerr << "no text in cache!" << endl; - bv_->text = new LyXText(bv_); + bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs); bv_->text->init(bv_); } diff --git a/src/ChangeLog b/src/ChangeLog index 5ecc733f51..c098941a1e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,15 @@ +2003-08-15 André Pönitz + + * rowpainter.C: remove extra metrics calls + + * lyxtext.h: merge the two constructors into a single one, + pass reference to owner's par list + + * BufferView_pimpl.C: + * text.C: + * text2.C: adjust + 2003-08-15 André Pönitz * lyxrow_funcs.[Ch]: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 70de1ef33c..2708f2ab6b 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -82,7 +82,7 @@ using lyx::textclass_type; InsetText::InsetText(BufferParams const & bp) - : UpdatableInset(), text_(0, this) + : UpdatableInset(), text_(0, this, true, paragraphs) { paragraphs.push_back(Paragraph()); paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout()); @@ -93,7 +93,7 @@ InsetText::InsetText(BufferParams const & bp) InsetText::InsetText(InsetText const & in) - : UpdatableInset(in), text_(0, this) + : UpdatableInset(in), text_(0, this, true, paragraphs) { init(&in); } @@ -1586,8 +1586,8 @@ void InsetText::setViewCache(BufferView const * bv) const { if (bv) { if (bv != text_.bv_owner) { - lyxerr << "setting view cache from " - << text_.bv_owner << " to " << bv << "\n"; + //lyxerr << "setting view cache from " + // << text_.bv_owner << " to " << bv << "\n"; text_.init(const_cast(bv)); } text_.bv_owner = const_cast(bv); diff --git a/src/lyxtext.h b/src/lyxtext.h index b0374573ed..c1cb635c7c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -50,9 +50,8 @@ class Dimension; class LyXText : public TextCursor { public: /// Constructor - LyXText(BufferView *); - /// sets inset as owner - LyXText(BufferView *, InsetText *); + LyXText(BufferView *, InsetText *, bool ininset, + ParagraphList & paragraphs); void init(BufferView *); /// @@ -480,6 +479,11 @@ private: /// mutable lyx::pos_type bidi_end; + /// + const bool in_inset_; + /// + ParagraphList & paragraphs_; + /// void charInserted(); public: diff --git a/src/rowpainter.C b/src/rowpainter.C index cc91b06678..befec68a3e 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -1065,47 +1065,11 @@ int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp) } -void paintRow(BufferView const & bv, LyXText const & text, - ParagraphList::iterator pit, - RowList::iterator rit, int y_offset, int x_offset, int y) -{ - RowPainter painter(bv, text, pit, rit, y_offset, x_offset, y); - painter.paint(); -} - - int paintRows(BufferView const & bv, LyXText const & text, RowList::iterator rit, int xo, int y, int yf, int y2, int yo) { - // fix up missing metrics() call for main LyXText - // calling metrics() directly is (a) slow and (b) crashs - if (&text == bv.text) { -#if 1 - // make sure all insets are updated - ParagraphList::iterator pit = text.ownerParagraphs().begin(); - ParagraphList::iterator end = text.ownerParagraphs().end(); - - // compute inset metrics - for (; pit != end; ++pit) { - InsetList & insetList = pit->insetlist; - InsetList::iterator ii = insetList.begin(); - InsetList::iterator iend = insetList.end(); - for (; ii != iend; ++ii) { - Dimension dim; - LyXFont font; - MetricsInfo mi(perv(bv), font, text.workWidth()); - ii->inset->metrics(mi, dim); - } - } -#else - LyXFont font; - Dimension dim; - MetricsInfo mi(perv(bv), font, text.workWidth()); - const_cast(text).metrics(mi, dim); -#endif - } + //lyxerr << "paintRows: rit: " << &*rit << endl; const_cast(text).updateRowPositions(); - int yy = yf - y; ParagraphList::iterator pit = text.ownerParagraphs().begin(); @@ -1120,7 +1084,8 @@ int paintRows(BufferView const & bv, LyXText const & text, if (row == rit) active = true; if (active) { - paintRow(bv, text, pit, row, y + yo, xo, y + text.top_y()); + RowPainter painter(bv, text, pit, row, y + yo, xo, y + text.top_y()); + painter.paint(); y += row->height(); if (yy + y >= y2) return y; diff --git a/src/text.C b/src/text.C index 1cd7375d0d..7d23d25667 100644 --- a/src/text.C +++ b/src/text.C @@ -103,9 +103,6 @@ int LyXText::top_y() const void LyXText::top_y(int newy) { - if (ownerParagraphs().begin()->rows.empty()) - return; - anchor_y_ = newy; lyxerr[Debug::GUI] << "changing reference to offset: " << anchor_y_ << endl; } diff --git a/src/text2.C b/src/text2.C index 681a8eaec7..e2ae52d493 100644 --- a/src/text2.C +++ b/src/text2.C @@ -59,16 +59,13 @@ using std::pair; using lyx::pos_type; -LyXText::LyXText(BufferView * bv) +LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset, + ParagraphList & paragraphs) : height(0), width(0), anchor_y_(0), - inset_owner(0), the_locking_inset(0), bv_owner(bv) -{} - - -LyXText::LyXText(BufferView * bv, InsetText * inset) - : height(0), width(0), anchor_y_(0), - inset_owner(inset), the_locking_inset(0), bv_owner(bv) -{} + inset_owner(inset), the_locking_inset(0), bv_owner(bv), + in_inset_(ininset), paragraphs_(paragraphs) +{ +} void LyXText::init(BufferView * bview) @@ -595,7 +592,8 @@ void LyXText::fullRebreak() void LyXText::metrics(MetricsInfo & mi, Dimension & dim) { - //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth << endl; + //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth + // << " workWidth: " << workWidth() << endl; //Assert(mi.base.textwidth); // rebuild row cache @@ -1944,17 +1942,14 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) ParagraphList & LyXText::ownerParagraphs() const { - if (inset_owner) { - return inset_owner->paragraphs; - } - return bv_owner->buffer()->paragraphs; + return paragraphs_; } bool LyXText::isInInset() const { // Sub-level has non-null bv owner and non-null inset owner. - return inset_owner != 0 && bv_owner != 0; + return inset_owner != 0; }