From 34600f50555b69405589cecaa1f765c2e02064c0 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 20 Nov 2006 14:42:18 +0000 Subject: [PATCH] * Status.15x: updates. * buffer.h: changed() signal do not have an argument now. * BufferView.C: - setBuffer(): changed update() call to updateMetrics(). - update(): sanitize how the flags are used. - scrollDocView(): add a call to updateMetrics() at the end. * LyXFunc::dispatch(): adjust changed() signal emission. * LyXText/text3.C: - cursorPrevious(): delete BufferView::update call; adjust cursor flag. - cursorNext(): ditto. * frontends/LyXView.C: adjust Buffer::changed() signal connection. * frontends/WorkArea.[Ch]: - redraw(): no need to re-update the metrics if we don't change views. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15997 a592a061-630c-0410-9148-cb99ea01b6c8 --- Status.15x | 34 ++++++++++++++-------------------- src/BufferView.C | 24 +++++++++++------------- src/buffer.h | 2 +- src/frontends/LyXView.C | 2 +- src/frontends/WorkArea.C | 10 +++++++--- src/frontends/WorkArea.h | 2 +- src/lyxfunc.C | 2 +- src/lyxtext.h | 4 ++-- src/text3.C | 18 ++++++++---------- 9 files changed, 46 insertions(+), 52 deletions(-) diff --git a/Status.15x b/Status.15x index f0c1ce47b4..eb9994e960 100644 --- a/Status.15x +++ b/Status.15x @@ -144,21 +144,6 @@ EDITING * Copy/paste using middle mouse button inserts musical notes. -* open a file; mark with the mouse and scroll; assert will fail: - - Row const & LyXText::getRowNearY(BufferView const & bv, int y, pit_type pit) const - { - Paragraph const & par = pars_[pit]; - int yy = bv.coordCache().get(this, pit).y_ - par.ascent(); - BOOST_ASSERT(!par.rows().empty()); - RowList::const_iterator rit = par.rows().begin(); - RowList::const_iterator const rlast = boost::prior(par.rows().end()); - for (; rit != rlast; yy += rit->height(), ++rit) - if (yy + rit->height() > y) - break; - return *rit; - } - * new document; insert note; place cursor in front of the note; activate change tracking; press delete => @@ -205,19 +190,21 @@ LAYOUT PAINTING & PERFORMANCE -* Selection highlighting is broken. Test case: two paragraphs with "Hello" - and "World"; move cursor past "Wor", press Shift+Up +* Too much painting 2 (Edwin 3/11/2006): There is also a lot of painting going + on when selecting text. When selecting a word the whole screen is repainted. + PARTLY FIXED (Abdel 2006-11-20): there's a full repaint only when the mouse is + released. More to come in this area. * Too much painting 1 (Edwin 3/11/2006): when i click in the workarea (to put the cursor in another part of the text) the screen is repainted *twice* whereas it seems to me that no repainting is necessary at all. - -* Too much painting 2 (Edwin 3/11/2006): There is also a lot of painting going - on when selecting text. When selecting a word the whole screen is repainted. + PARTLY FIXED (Abdel 2006-11-20): except for math insets. * Too much painting 3 (Edwin 3/11/2006): the screen is repainted even when the selection does not change (moving the mouse with the left button pushed down always triggers a repaint). + PARTLY FIXED (Abdel 2006-11-20): When within the main text inset only the + current line is repainted. * The cursor is not L-shaped for foreign languages @@ -462,3 +449,10 @@ CREDITS: * M-x is broken (does not bring up the minibuffer). FIXED (Bo, 2006-11-18): set toolbar flag in display function. +* open a file; mark with the mouse and scroll; assert will fail: + FIXED (Abdel 2006-11-20): side effect of updateMetrics() cleanup. + +* Selection highlighting is broken. Test case: two paragraphs with "Hello" + and "World"; move cursor past "Wor", press Shift+Up + FIXED (Abdel 2006-11-20): side effect of updateMetrics() cleanup. + \ No newline at end of file diff --git a/src/BufferView.C b/src/BufferView.C index d1d768ac36..0689719a21 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -197,7 +197,7 @@ void BufferView::setBuffer(Buffer * b) } } - update(); + updateMetrics(false); if (buffer_ && graphics::Previews::status() != LyXRC::PREVIEW_OFF) graphics::Previews::get().generateBufferPreviews(*buffer_); @@ -367,25 +367,22 @@ std::pair BufferView::update(Update::flags flags) // The second drawing step is done in WorkArea::redraw() if needed. // Case when no explicit update is requested. - if (!(flags & (Update::SinglePar | Update::Force))) { - if (fitCursor() || multiParSel()) { - // a CoordCache update is needed - updateMetrics(false); - // tell the frontend to update the screen. - return make_pair(true, false); - } + if (!flags) { // no need to do anything. return make_pair(false, false); } - // We are now in the case (Update::SinglePar | Update::Force) - bool single_par = flags & Update::SinglePar; + bool full_metrics = flags & Update::Force; + if (flags & Update::MultiParSel) + full_metrics |= multiParSel(); + + bool const single_par = !full_metrics; updateMetrics(single_par); - // Don't forget to do check for fitCursor() and multiParSel(). - fitCursor(); - multiParSel(); + if (flags & Update::FitCursor && fitCursor()) + updateMetrics(false); + // tell the frontend to update the screen. return make_pair(true, single_par); } @@ -476,6 +473,7 @@ void BufferView::scrollDocView(int value) t.redoParagraph(*this, anchor_ref_); int const h = t.getPar(anchor_ref_).height(); offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h); + updateMetrics(false); } diff --git a/src/buffer.h b/src/buffer.h index 280fc05c8d..ab48f50817 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -120,7 +120,7 @@ public: bool hasParWithID(int id) const; /// This signal is emitted when the buffer is changed. - boost::signal changed; + boost::signal changed; /// This signal is emitted when some parsing error shows up. boost::signal errors; /// This signal is emitted when some message shows up. diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index fa6da758ad..17cd7bc6d4 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -169,7 +169,7 @@ void LyXView::connectBuffer(Buffer & buf) bufferChangedConnection_ = buf.changed.connect( - boost::bind(&WorkArea::redraw, work_area_, _1)); + boost::bind(&WorkArea::redraw, work_area_)); errorsConnection_ = buf.errors.connect( diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index c2b8faf25c..40bc070341 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -131,7 +131,7 @@ void WorkArea::startBlinkingCursor() } -void WorkArea::redraw(bool singlePar) +void WorkArea::redraw() { if (!buffer_view_ || !buffer_view_->buffer()) { greyed_out_ = true; @@ -140,7 +140,11 @@ void WorkArea::redraw(bool singlePar) return; } - buffer_view_->updateMetrics(singlePar && hasFocus()); + // No need to do anything if this is the current view. The BufferView + // 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); updateScrollbar(); @@ -210,7 +214,7 @@ void WorkArea::dispatch(FuncRequest const & cmd0) toggleCursor(); if (needRedraw.first) - redraw(needRedraw.second); + redraw(); } diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 0db53ceaab..a7ab99fc70 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -83,7 +83,7 @@ public: virtual void setScrollbarParams(int height, int pos, int line_height) = 0; /// redraw the screen, without using existing pixmap - virtual void redraw(bool singlePar = false); + virtual void redraw(); /// void stopBlinkingCursor(); void startBlinkingCursor(); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7de71684d5..1975bce2e9 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1718,7 +1718,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) std::pair needSecondUpdate = view()->update(updateFlags); if (needSecondUpdate.first) - view()->buffer()->changed(needSecondUpdate.second); + view()->buffer()->changed(); lyx_view_->updateStatusBar(); diff --git a/src/lyxtext.h b/src/lyxtext.h index 5bf93d8278..db13b054b2 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -222,9 +222,9 @@ public: /// bool cursorEnd(LCursor & cur); /// - bool cursorPrevious(LCursor & cur); + void cursorPrevious(LCursor & cur); /// - bool cursorNext(LCursor & cur); + void cursorNext(LCursor & cur); /// bool cursorTop(LCursor & cur); /// diff --git a/src/text3.C b/src/text3.C index 9fb01eda4f..2a4b78c825 100644 --- a/src/text3.C +++ b/src/text3.C @@ -198,16 +198,15 @@ string const freefont2string() } -bool LyXText::cursorPrevious(LCursor & cur) +void LyXText::cursorPrevious(LCursor & cur) { pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); int x = cur.x_target(); + // FIXME: there would maybe a need for this 'updated' boolean in the future... bool updated = setCursorFromCoordinates(cur, x, 0); - if (updated) - cur.bv().update(); updated |= cursorUp(cur); if (cpar == cur.pit() && cpos == cur.pos()) { @@ -217,19 +216,18 @@ bool LyXText::cursorPrevious(LCursor & cur) } finishUndo(); - return updated; + cur.updateFlags(Update::Force | Update::FitCursor); } -bool LyXText::cursorNext(LCursor & cur) +void LyXText::cursorNext(LCursor & cur) { pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); int x = cur.x_target(); + // FIXME: there would maybe a need for this 'updated' boolean in the future... bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); - if (updated) - cur.bv().update(); updated |= cursorDown(cur); if (cpar == cur.pit() && cpos == cur.pos()) { @@ -239,7 +237,7 @@ bool LyXText::cursorNext(LCursor & cur) } finishUndo(); - return updated; + cur.updateFlags(Update::Force | Update::FitCursor); } @@ -500,7 +498,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.undispatched(); cmd = FuncRequest(LFUN_FINISHED_UP); } else { - needsUpdate |= cursorPrevious(cur); + cursorPrevious(cur); } break; @@ -512,7 +510,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.undispatched(); cmd = FuncRequest(LFUN_FINISHED_DOWN); } else { - needsUpdate |= cursorNext(cur); + cursorNext(cur); } break; -- 2.39.2