]> git.lyx.org Git - features.git/commitdiff
* Bufferview::updateMetrics(): Separate out the SinglePar optimization.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 6 Nov 2007 08:32:25 +0000 (08:32 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 6 Nov 2007 08:32:25 +0000 (08:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21463 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/frontends/WorkArea.cpp
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp

index 5275791927862902c13e92d9efcc3a4a0bd59bdd..2cf95fdf1f0efc8844b93e739d990afd719984f5 100644 (file)
@@ -532,7 +532,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
                bool const fit_cursor = fitCursor();
                // tell the frontend to update the screen if needed.
                if (fit_cursor) {
-                       updateMetrics(false);
+                       updateMetrics();
                        buffer_.changed();
                        return;
                }
@@ -550,8 +550,9 @@ void BufferView::processUpdateFlags(Update::flags flags)
        if (flags & Update::MultiParSel)
                full_metrics |= multiParSel();
 
-       bool const single_par = !full_metrics;
-       updateMetrics(single_par);
+       if (full_metrics || singleParUpdate())
+               // We have to update the full screen metrics.
+               updateMetrics();
 
        if (!(flags & Update::FitCursor)) {
                buffer_.changed();
@@ -569,7 +570,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
 
        // The screen has been recentered around the cursor position so
        // refresh it:
-       updateMetrics(false);
+       updateMetrics();
        buffer_.changed();
 }
 
@@ -653,7 +654,7 @@ void BufferView::scrollDocView(int value)
        tm.redoParagraph(d->anchor_ref_);
        int const h = tm.parMetrics(d->anchor_ref_).height();
        d->offset_ref_ = int((bar * t.paragraphs().size() - d->anchor_ref_) * h);
-       updateMetrics(false);
+       updateMetrics();
        buffer_.changed();
 }
 
@@ -1345,7 +1346,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
                if (p.y_ < 0 || p.y_ > height_) {
                        // The cursor is off-screen so recenter before proceeding.
                        center();
-                       updateMetrics(false);
+                       updateMetrics();
                        //FIXME: updateMetrics() does not update paragraph position
                        // This is done at draw() time. So we need a redraw!
                        buffer_.changed();
@@ -1430,7 +1431,7 @@ void BufferView::resize(int width, int height)
        width_ = width;
        height_ = height;
 
-       updateMetrics(false);
+       updateMetrics();
 }
 
 
@@ -1584,7 +1585,7 @@ void BufferView::scrollDown(int offset)
                tm.newParMetricsDown();
        }
        d->offset_ref_ += offset;
-       updateMetrics(false);
+       updateMetrics();
        buffer_.changed();
 }
 
@@ -1608,7 +1609,7 @@ void BufferView::scrollUp(int offset)
                tm.newParMetricsUp();
        }
        d->offset_ref_ -= offset;
-       updateMetrics(false);
+       updateMetrics();
        buffer_.changed();
 }
 
@@ -1701,7 +1702,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
 
        updateLabels(buffer_);
 
-       updateMetrics(false);
+       updateMetrics();
        buffer_.changed();
        return true;
 }
@@ -1837,12 +1838,8 @@ bool BufferView::singleParUpdate()
 }
 
 
-void BufferView::updateMetrics(bool singlepar)
+void BufferView::updateMetrics()
 {
-       if (singlepar && singleParUpdate())
-               // No need to update the full screen metrics.
-               return;
-
        Text & buftext = buffer_.text();
        pit_type const npit = int(buftext.paragraphs().size());
 
@@ -1993,7 +1990,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
        // emit message signal.
        message(bformat(res, disp_fn));
        buffer_.errors("Parse");
-       updateMetrics(false);
+       updateMetrics();
 }
 
 
index 16cbcd7aa26220321f8c856c3d4476e24b2f3f34..b553f26f8365be7141154726ca5aa67b1f8857c7 100644 (file)
@@ -201,8 +201,7 @@ public:
        /// \sa ViewMetricsInfo
        ViewMetricsInfo const & viewMetricsInfo();
        /// update the internal \c ViewMetricsInfo.
-       /// \param singlepar indicates wether
-       void updateMetrics(bool singlepar = false);
+       void updateMetrics();
 
        ///
        TextMetrics const & textMetrics(Text const * t) const;
index c3abe443b29ae6c145b40c42b85d71c30769936a..06f22e096bdc59387a723d93cde962a013034167 100644 (file)
@@ -131,7 +131,7 @@ void WorkArea::redraw()
        // metrics are already up to date.
        if (lyx_view_ != theApp()->currentView()) {
                // FIXME: it would be nice to optimize for the off-screen case.
-               buffer_view_->updateMetrics(false);
+               buffer_view_->updateMetrics();
                buffer_view_->cursor().fixIfBroken();
        }
 
index 29b7e8c8162b1a8128d7afe51eaf7d59ad02cce2..9e26f5cc2a0d52d366c5a145ed535b2242b038b5 100644 (file)
@@ -297,7 +297,7 @@ void GuiParagraph::dispatchParams()
                return;
        }
 
-       bufferview()->updateMetrics(false);
+       bufferview()->updateMetrics();
        bufferview()->buffer().changed();
 }
 
index bf924837a943817930d9092a1915467c955033a8..f58e7be7895b8a1a617fbb1dff1ad94aef338996 100644 (file)
@@ -810,7 +810,7 @@ WorkArea * GuiView::addWorkArea(Buffer & buffer)
        GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
        wa->setUpdatesEnabled(false);
        d.tab_widget_->addTab(wa, toqstr(buffer.fileName().displayName(30)));
-       wa->bufferView().updateMetrics(false);
+       wa->bufferView().updateMetrics();
        if (d.stack_widget_)
                d.stack_widget_->setCurrentWidget(d.tab_widget_);
        // Hide tabbar if there's only one tab.
index 9b55e9173f99c207d5fcd2207d2dd486c7e3583c..4e6eaf160a0e2c37a13764497f4cfe6bf787f893 100644 (file)
@@ -507,7 +507,7 @@ void GuiWorkArea::updateScreen()
 void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
 {
        if (schedule_redraw_) {
-               buffer_view_->updateMetrics(false);
+               buffer_view_->updateMetrics();
                updateScreen();
                viewport()->update(QRect(0, 0, viewport()->width(), viewport()->height()));
                schedule_redraw_ = false;
@@ -568,7 +568,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
        }
 
        GuiPainter pain(&screen_);
-       buffer_view_->updateMetrics(false);
+       buffer_view_->updateMetrics();
        buffer_view_->draw(pain);
        FontInfo font = buffer_view_->cursor().getFont().fontInfo();
        FontMetrics const & fm = theFontMetrics(font);
@@ -809,7 +809,7 @@ void TabWorkArea::on_currentTabChanged(int i)
        GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
        BOOST_ASSERT(wa);
        BufferView & bv = wa->bufferView();
-       bv.updateMetrics(false);
+       bv.updateMetrics();
        bv.cursor().fixIfBroken();
        wa->setUpdatesEnabled(true);
        wa->redraw();