From 86e8f751e1f61c5df708483ea22178c127254191 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 5 Oct 2007 09:38:40 +0000 Subject: [PATCH] Small API cleanup: as BufferView already use Buffer::changed() make it use it some more instead of WorkArea. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20747 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 25 ++++++++++++++----------- src/BufferView.h | 3 +-- src/frontends/WorkArea.cpp | 5 +---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 0abea62854..180c2b1aa7 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1315,7 +1315,7 @@ Inset const * BufferView::getCoveringInset(Text const & text, int x, int y) } -bool BufferView::workAreaDispatch(FuncRequest const & cmd0) +void BufferView::mouseEventDispatch(FuncRequest const & cmd0) { //lyxerr << BOOST_CURRENT_FUNCTION << "[ cmd0 " << cmd0 << "]" << endl; @@ -1340,7 +1340,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) getCoveringInset(buffer_.text(), cmd.x, cmd.y); if (covering_inset == last_inset_) // Same inset, no need to do anything... - return false; + return; bool need_redraw = false; // const_cast because of setMouseHover(). @@ -1353,7 +1353,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) need_redraw |= inset->setMouseHover(true); last_inset_ = inset; if (!need_redraw) - return false; + return; // if last metrics update was in singlepar mode, WorkArea::redraw() will // not expose the button for redraw. We adjust here the metrics dimension @@ -1375,7 +1375,8 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) // This event (moving without mouse click) is not passed further. // This should be changed if it is further utilized. - return true; + buffer_.changed(); + return; } // Build temporary cursor. @@ -1388,9 +1389,8 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) // via the temp cursor. If the inset wishes to change the real // cursor it has to do so explicitly by using // cur.bv().cursor() = cur; (or similar) - if (inset) { + if (inset) inset->dispatch(cur, cmd); - } // Now dispatch to the temporary cursor. If the real cursor should // be modified, the inset's dispatch has to do so explicitly. @@ -1400,11 +1400,14 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0) //Do we have a selection? theSelection().haveSelection(cursor().selection()); - // Redraw if requested and necessary. - if (cur.result().dispatched() && cur.result().update()) - return update(cur.result().update()); - - return false; + // If the command has been dispatched, + if (cur.result().dispatched() + // an update is asked, + && cur.result().update() + // and redraw is needed, + && update(cur.result().update())) + // then trigger a redraw. + buffer_.changed(); } diff --git a/src/BufferView.h b/src/BufferView.h index 07d4c0370d..192742b8c4 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -170,8 +170,7 @@ public: /// dispatch method helper for \c WorkArea /// \sa WorkArea - /// \retval true if a redraw is needed - bool workAreaDispatch(FuncRequest const & ev); + void mouseEventDispatch(FuncRequest const & ev); /// access to anchor. pit_type anchor_ref() const; diff --git a/src/frontends/WorkArea.cpp b/src/frontends/WorkArea.cpp index dadb3e10c5..86a4d93cf5 100644 --- a/src/frontends/WorkArea.cpp +++ b/src/frontends/WorkArea.cpp @@ -203,10 +203,7 @@ void WorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod) && cmd.button() == mouse_button::none)) stopBlinkingCursor(); - bool const needRedraw = buffer_view_->workAreaDispatch(cmd); - - if (needRedraw) - buffer_view_->buffer().changed(); + buffer_view_->mouseEventDispatch(cmd); // Skip these when selecting if (cmd.action != LFUN_MOUSE_MOTION) {