]> git.lyx.org Git - lyx.git/commitdiff
Extracted from r14281
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 8 Jul 2006 20:24:32 +0000 (20:24 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 8 Jul 2006 20:24:32 +0000 (20:24 +0000)
* frontends/LyXView:
- redrawWorkArea(): new temporary method called from within
  BufferView::pimpl::update() that calls WorkArea::redraw()
  in order to do the actual screen redrawing.
* frontends/WorkArea:
- the redraw() method now check if the the attached bufferView
  needs a screen redraw().
* BufferView:
- needsRedraw(): new method for WorkArea::redraw()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14381 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/WorkArea.C
src/frontends/WorkArea.h

index f1c1834b1c24523ccbe437d3d69c161b1e5c78b2..aba91428770c2082bd58cb4c47892bf005caa336 100644 (file)
@@ -408,3 +408,15 @@ ViewMetricsInfo const & BufferView::viewMetricsInfo()
 {
        return pimpl_->viewMetricsInfo();
 }
+
+
+bool BufferView::needsRedraw() const
+{
+       return pimpl_->needsRedraw();
+}
+
+
+void BufferView::needsRedraw(bool redraw_needed)
+{
+       pimpl_->needsRedraw(redraw_needed);
+}
index 924637e10c1832713f24c2d28c3bc9dacb10130f..a967a2fed479fe916fe95b98f05de712756718ff 100644 (file)
@@ -226,6 +226,10 @@ public:
 
        ///
        ViewMetricsInfo const & viewMetricsInfo();
+
+       ///
+       bool needsRedraw() const;
+       void needsRedraw(bool redraw_needed);
 private:
        ///
        class Pimpl;
index 2365d64f11a17e1f5110d7c4ef7332305fc41e8f..2fb94a60adc337e9922aa72e4f4864be90b662bb 100644 (file)
@@ -139,7 +139,7 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code)
 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner)
        : bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400),
          using_xterm_cursor(false), cursor_(bv),
-         multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0)
+         multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0), needs_redraw_(false)
 {
        xsel_cache_.set = false;
 
@@ -699,39 +699,38 @@ void BufferView::Pimpl::update(Update::flags flags)
                        << "]  buffer: " << buffer_ << endl;
        }
 
+       // This, together with doneUpdating(), verifies (using
+       // asserts) that screen redraw is not called from
+       // within itself.
+       theCoords.startUpdating();
+
        // Check needed to survive LyX startup
        if (buffer_) {
                // Update macro store
                buffer_->buildMacros();
 
-               // This, together with doneUpdating(), verifies (using
-               // asserts) that screen redraw is not called from
-               // within itself.
-               theCoords.startUpdating();
-
                // First drawing step
                bool singlePar = flags & Update::SinglePar;
-               bool forceupdate(flags & (Update::Force | Update::SinglePar));
+               needs_redraw_ = flags & (Update::Force | Update::SinglePar);
 
                if ((flags & (Update::FitCursor | Update::MultiParSel))
                    && (fitCursor() || multiParSel())) {
-                       forceupdate = true;
+                       needs_redraw_ = true;
                        singlePar = false;
                }
 
-               if (forceupdate) {
+               if (needs_redraw_) {
                        // Second drawing step
                        updateMetrics(singlePar);
-                       owner_->workArea()->redraw(*bv_);
-               } else {
-                       // Abort updating of the coord
-                       // cache - just restore the old one
-                       theCoords.doneUpdating();
                }
-       } else
-               owner_->workArea()->greyOut();
+       }
 
+       owner_->redrawWorkArea();
        owner_->view_state_changed();
+
+       // Abort updating of the coord
+       // cache - just restore the old one
+       theCoords.doneUpdating();
 }
 
 
index c39e137dc2ae0b27b2e071340069bbfa5ed6297e..6edea86b5a01f947245117d7a4f8419c14cebe96 100644 (file)
@@ -120,6 +120,15 @@ public:
 
        ///
        ViewMetricsInfo const & viewMetricsInfo();
+       ///
+       bool needsRedraw() const
+       {
+               return needs_redraw_;
+       }
+       void needsRedraw(bool redraw_needed)
+       {
+               needs_redraw_ = redraw_needed;
+       }
 private:
        ///
        int width_;
@@ -127,6 +136,8 @@ private:
        int height_;
        ///
        ScrollbarParameters scrollbarParameters_;
+       ///
+       bool needs_redraw_;
 
        /// An error list (replaces the error insets)
        ErrorList errorlist_;
index 8581ac2ec3c4adbe3081e2b73d6f3508f2852780..7cf2a058872ab425c93c0f3bdce2a808864eaa4e 100644 (file)
@@ -81,14 +81,20 @@ LyXView::LyXView(Gui & owner)
 }
 
 
+LyXView::~LyXView()
+{
+}
+
+
 void LyXView::setWorkArea(WorkArea * work_area)
 {
        work_area_ = work_area;
 }
 
 
-LyXView::~LyXView()
+void LyXView::redrawWorkArea()
 {
+       work_area_->redraw();
 }
 
 
index ef1377a4ed1724785ead353b8e734ad50316b3a7..36245d0f5bfddcacb44c47ab95d727fbda7ef13f 100644 (file)
@@ -153,6 +153,9 @@ public:
        virtual lyx::frontend::Gui & gui();
 
        lyx::frontend::WorkArea * workArea() const { return work_area_; }
+
+       /// Temporary method used by the kernel to redraw the work area.
+       virtual void redrawWorkArea();
 protected:
        /// current work area (screen view of a BufferView).
        /**
index 9abf811b11453db9b4013a852a42f5f954987a50..debf0005d97e8cbdd532675f62ee18ae70893d1e 100644 (file)
@@ -155,10 +155,20 @@ void WorkArea::checkAndGreyOut()
 }
 
 
-void WorkArea::redraw(BufferView & bv)
+void WorkArea::redraw()
 {
+       BOOST_ASSERT(buffer_view_);
+
+       if (!buffer_view_->buffer()) {
+               greyOut();
+               return;
+       }
+
+       if (!buffer_view_->needsRedraw())
+               return;
+
        greyed_out_ = false;
-       ViewMetricsInfo const & vi = bv.viewMetricsInfo();
+       ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
        getPainter().start();
        paintText(*buffer_view_, vi);
        lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
@@ -167,7 +177,14 @@ void WorkArea::redraw(BufferView & bv)
                ( vi.p2 < vi.size - 1 ?  vi.y2 : height() );
        expose(0, ymin, width(), ymax - ymin);
        getPainter().end();
-       theCoords.doneUpdating();
+       //theCoords.doneUpdating();
+       buffer_view_->needsRedraw(false);
+
+       if (lyxerr.debugging(Debug::DEBUG)) {
+               lyxerr[Debug::DEBUG]
+                       << "  ymin = " << ymin << "  width() = " << width()
+                       << "  ymax-ymin = " << ymax-ymin << std::endl;
+       }
 }
 
 
index ad55382e601a8e561b3268d649776938cf3f7d21..083bd600dfe3132c604f6935bbc162d7fe6eabc5 100644 (file)
@@ -64,7 +64,7 @@ public:
        virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
 
        /// redraw the screen, without using existing pixmap
-       virtual void redraw(BufferView & bv);
+       virtual void redraw();
 
        /// grey out (no buffer)
        void greyOut();