]> git.lyx.org Git - features.git/commitdiff
rowpainter.C: remove extra metrics calls
authorAndré Pönitz <poenitz@gmx.net>
Fri, 15 Aug 2003 14:54:19 +0000 (14:54 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 15 Aug 2003 14:54:19 +0000 (14:54 +0000)
 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

src/BufferView_pimpl.C
src/ChangeLog
src/insets/insettext.C
src/lyxtext.h
src/rowpainter.C
src/text.C
src/text2.C

index 6e1e8ba482722a49f627cd10dc43c154e568e8e1..e47e994ac54e74e35ce7ecaaf3bf9cfdde0f5e2b 100644 (file)
@@ -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_);
                }
 
index 5ecc733f515acc0073198296755c703e80fe993c..c098941a1eaa7653ad80e049a40bc79cd1152c90 100644 (file)
@@ -1,4 +1,15 @@
 
+2003-08-15  André Pönitz  <poenitz@gmx.net>
+
+       * 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  <poenitz@gmx.net>
 
        * lyxrow_funcs.[Ch]:
index 70de1ef33c58f0a0978d8d3db86982363038f381..2708f2ab6bd8462a43553d6cd02ea7b281e5a546 100644 (file)
@@ -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<BufferView *>(bv));
                }
                text_.bv_owner = const_cast<BufferView *>(bv);
index b0374573edc24dd4ccf63f6ab287ca28681f85f9..c1cb635c7c8f33bb4805852de42a3c1438a54cd7 100644 (file)
@@ -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:
index cc91b06678edd234e3944f7519d285615bdf8168..befec68a3e77c7c7950faeae3eb5c9cbcb86ba8e 100644 (file)
@@ -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<LyXText&>(text).metrics(mi, dim);
-#endif
-       }
+       //lyxerr << "paintRows: rit: " << &*rit << endl;
        const_cast<LyXText&>(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;
index 1cd7375d0d170cfdb3ab9b118250d935fed75bd0..7d23d256677c5c5f5d3b5d2763b0bbd940188375 100644 (file)
@@ -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;
 }
index 681a8eaec794103b4efcd70df0fe3eba621176b4..e2ae52d49394c18648f6a4b8a1e51a190f2f36b4 100644 (file)
@@ -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;
 }