]> git.lyx.org Git - features.git/commitdiff
Compute metrics when graphics is updated
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 14 Sep 2017 13:50:30 +0000 (15:50 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 14 Sep 2017 13:50:30 +0000 (15:50 +0200)
Remove the old schedule_redraw_ mechanism that was only useful because
of our synchronous drawing code. Now that actual painting is
scheduled instead of forced, it becomes pointless.

Rename WorkArea::redraw(bool) to scheduleRedraw(bool), to show that
the drawing is not done right away.

In GuiView::updateInset, call scheduleRedraw(true), so that metrics
are correctly computed (this was the whole point of the exercise).

src/frontends/WorkArea.h
src/frontends/WorkAreaManager.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h
src/frontends/qt4/GuiWorkArea_Private.h

index 8e459ca37524f3aa11240b1947f81ca1d4d00591..c21555913e8fd602261d2741b1a0f8fa49c10c6c 100644 (file)
@@ -36,8 +36,8 @@ public:
        ///
        virtual ~WorkArea() {}
 
-       /// redraw the screen, without using existing pixmap
-       virtual void redraw(bool update_metrics) = 0;
+       /// Update metrics if needed and schedule a paint event
+       virtual void scheduleRedraw(bool update_metrics) = 0;
 
        /// close this work area.
        /// Slot for Buffer::closing signal.
index b98163ceccc26a4ef03c31158b3c5d33811e9bc4..c79f08bef7d018787d059958b652a867e08df2c4 100644 (file)
@@ -35,7 +35,7 @@ void WorkAreaManager::remove(WorkArea * wa)
 void WorkAreaManager::redrawAll(bool update_metrics)
 {
        for (WorkArea * wa : work_areas_)
-               wa->redraw(update_metrics);
+               wa->scheduleRedraw(update_metrics);
 }
 
 
index e1c024e9e6915073a0bf3bdadb3ff956a0c2a27f..7644efc63f23d207b0ddf295a2e0a66b85f7b691 100644 (file)
@@ -4345,7 +4345,7 @@ Buffer const * GuiView::updateInset(Inset const * inset)
                        continue;
                Buffer const * buffer = &(wa->bufferView().buffer());
                if (inset_buffer == buffer)
-                       wa->scheduleRedraw();
+                       wa->scheduleRedraw(true);
        }
        return inset_buffer;
 }
index bd3104c2509becef89527debc4aa3951f1fa410f..cb9769ab52af8699a8476735edd4a7490728b90d 100644 (file)
@@ -237,7 +237,7 @@ SyntheticMouseEvent::SyntheticMouseEvent()
 GuiWorkArea::Private::Private(GuiWorkArea * parent)
 : p(parent), buffer_view_(0), lyx_view_(0),
   caret_(0), caret_visible_(false),
-  need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
+  need_resize_(false), preedit_lines_(1),
   pixel_ratio_(1.0),
   completer_(new GuiCompleter(p, p)), dialog_mode_(false), shell_escape_(false),
   read_only_(false), clean_(true), externally_modified_(false)
@@ -449,7 +449,7 @@ void GuiWorkArea::toggleCaret()
 }
 
 
-void GuiWorkArea::redraw(bool update_metrics)
+void GuiWorkArea::scheduleRedraw(bool update_metrics)
 {
        if (!isVisible())
                // No need to redraw in this case.
@@ -630,18 +630,6 @@ void GuiWorkArea::Private::showCaret()
 
        caret_->update(point.x_, point.y_, h, l_shape, isrtl, completable);
 
-       if (schedule_redraw_) {
-               // This happens when a graphic conversion is finished. As we don't know
-               // the size of the new graphics, it's better the update everything.
-               // We can't use redraw() here because this would trigger a infinite
-               // recursive loop with showCaret().
-               buffer_view_->resize(p->viewport()->width(), p->viewport()->height());
-               p->viewport()->update();
-               updateScrollbar();
-               schedule_redraw_ = false;
-               return;
-       }
-
        p->viewport()->update(caret_->rect());
 }
 
@@ -1352,12 +1340,6 @@ bool GuiWorkArea::isFullScreen() const
 }
 
 
-void GuiWorkArea::scheduleRedraw()
-{
-       d->schedule_redraw_ = true;
-}
-
-
 bool GuiWorkArea::inDialogMode() const
 {
        return d->dialog_mode_;
@@ -1770,7 +1752,7 @@ void TabWorkArea::on_currentTabChanged(int i)
        GuiWorkArea * wa = workArea(i);
        LASSERT(wa, return);
        wa->setUpdatesEnabled(true);
-       wa->redraw(true);
+       wa->scheduleRedraw(true);
        wa->setFocus();
        ///
        currentWorkAreaChanged(wa);
index 2a875ad4ce39c2bfeb412a5694cff304c4843130..4fd524909c55864d8828dc68b00e14b3e508c693 100644 (file)
@@ -59,13 +59,11 @@ public:
        /// is GuiView in fullscreen mode?
        bool isFullScreen() const;
        ///
-       void scheduleRedraw();
-       ///
        BufferView & bufferView();
        ///
        BufferView const & bufferView() const;
        ///
-       void redraw(bool update_metrics);
+       void scheduleRedraw(bool update_metrics);
 
        /// return true if the key is part of a shortcut
        bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
index 199ce253d6c89e8ef593e29776de888a8e4456d7..8be28694cdd2667e34fcd78079f117a5e9e7eabf 100644 (file)
@@ -122,8 +122,6 @@ struct GuiWorkArea::Private
 
        ///
        bool need_resize_;
-       ///
-       bool schedule_redraw_;
 
        /// the current preedit text of the input method
        docstring preedit_string_;