]> git.lyx.org Git - lyx.git/commitdiff
fix toggling of collapsable insets with the mouse (bug 1558)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 13 Aug 2004 14:56:06 +0000 (14:56 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 13 Aug 2004 14:56:06 +0000 (14:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8901 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/insets/ChangeLog
src/insets/insetbase.C
src/insets/insetcollapsable.C
src/lyxfunc.C

index 2c264a7d207564cd85fc08dddef5699df77c75c9..a54c32e82eb5962b563855b8a9587d58c813a6ec 100644 (file)
@@ -883,18 +883,17 @@ bool BufferView::Pimpl::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)'
-       DispatchResult res;
        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.
-       if (!res.dispatched())
-               res = cur.dispatch(cmd);
+       if (!cur.result().dispatched())
+               cur.dispatch(cmd);
 
-       if (res.dispatched()) {
+       if (cur.result().dispatched()) {
                // Redraw if requested or necessary.
-               if (fitCursor() || res.update())
+               if (fitCursor() || cur.result().update())
                        update();
        }
 
index ea87c4538c282c0b8d7b97be4a6abc7ef6ba45db..9629e53bd094e7ed6d7887427df7e594d0b9f81f 100644 (file)
@@ -1,3 +1,16 @@
+2004-08-13  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       Fix toggling of collapsable insets with the mouse (bug 1558)
+       
+       * lyxfunc.C (dispatch): adapt to LCursor changes
+
+       * BufferView_pimpl.C (workAreaDispatch): adapt to LCursor changes;
+       make sure that dispatch is not invoked twice
+
+       * cursor.C (needsUpdate): new method
+       (dispatch): return void
+       (result): new method, to access the DispatchResult of the cursor.
+
 2004-08-13  José Matos  <jamatos@lyx.org>
 
        * tabular.C (docbook): close empty tags in XML. Fix bug 1147.
@@ -12,7 +25,8 @@
 2004-08-12  André Pönitz  <poenitz@gmx.net>
 
        * text3.C: take out the 'cursor right' form insertInset and only
-   do it in those places when it is really needed. Fixes crash on C-m...
+       do it in those places when it is really needed. Fixes crash on
+       C-m...
 
 2004-08-08  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
index c2de922fb858c1633c51d2219f7dcf1da04a5321..2e4c8017d4b21c91d24b571e916dbbe3209d7abe 100644 (file)
@@ -84,11 +84,11 @@ void LCursor::setCursor(DocIterator const & cur, bool sel)
 }
 
 
-DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
+void LCursor::dispatch(FuncRequest const & cmd0)
 {
        lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
        if (empty())
-               return DispatchResult();
+               return;
 
        FuncRequest cmd = cmd0;
        LCursor safe = *this;
@@ -115,6 +115,11 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
                operator=(safe);
                disp_.dispatched(false);
        }
+}
+
+
+DispatchResult LCursor::result() const
+{
        return disp_;
 }
 
@@ -1123,7 +1128,15 @@ void LCursor::dispatched()
 }
 
 
+void LCursor::needsUpdate()
+{
+       disp_.update(true);
+}
+
+
 void LCursor::noUpdate()
 {
        disp_.update(false);
 }
+
+
index e99a8a06bd4e16ba32c5e91988ea2e5cdae4e1d5..5fbad76ef74b89b93617088c32876222694c6403 100644 (file)
@@ -38,7 +38,9 @@ public:
        explicit LCursor(BufferView & bv);
 
        /// dispatch from innermost inset upwards
-       DispatchResult dispatch(FuncRequest const & cmd);
+       void dispatch(FuncRequest const & cmd);
+       /// get the resut of the last dispatch
+       DispatchResult result() const;
        /// are we willing to handle this event?
        bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
 
@@ -145,6 +147,8 @@ public:
        void undispatched();
        /// the event was already dispatched
        void dispatched();
+       /// call update() when done
+       void needsUpdate();
        /// don't call update() when done
        void noUpdate();
 
index 77bcf614de2bfd96e939f71dbc3e014c6d7717d5..19287b23781dbd39f92d88dcd0a2d4e94be2dfea 100644 (file)
@@ -1,3 +1,14 @@
+2004-08-13  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insetcollapsable.C (priv_dispatch): on a mouse press event, do
+       not ask for an update if we did nothing; on a mouse release, make
+       sure that the cursor is  moved to the right position; on a mouse
+       release, exit from the inset instead of invoking a
+       LFUN_FINISHED_RIGHT. 
+
+       * insetbase.C (dispatch): before invoking dispatch, set cursor
+       result to dispatch=update=true.
+
 2004-08-13  José Matos  <jamatos@lyx.org>
 
        * insetgraphics.C (docbook): close empty tags in XML. Fix bug 1147.
index cf7e3604c36016d77a0d007750fcda869c3ada8d..4346c3705b9199c510f7bc6957f23eac507b17b0 100644 (file)
@@ -113,6 +113,8 @@ InsetBase::Code InsetBase::translate(std::string const & name)
 
 void InsetBase::dispatch(LCursor & cur, FuncRequest & cmd)
 {
+       cur.needsUpdate();
+       cur.dispatched();
        priv_dispatch(cur, cmd);
 }
 
index 6d908ce86e3d68ef327bfd58c3d62e33e670b16a..7b31d8e750189fb14a2c8158c69950b3b3845f58 100644 (file)
@@ -245,11 +245,6 @@ InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
        cur.push(*this);
        //lyxerr << "InsetCollapsable: edit xy" << endl;
        if (status_ == Collapsed) {
-               setStatus(Open);
-               // We are not calling editXY() because the row cache of the
-               // inset might be invalid. 'Entering from the left' should be
-               // ok, though.
-               InsetText::edit(cur, true);
                return this;
        }
        return InsetText::editXY(cur, x, y);
@@ -258,14 +253,17 @@ InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
 
 void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 {
-       //lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
-       //      << "  button y: " << button_dim.y2 << endl;
+//     lyxerr << "InsetCollapsable::priv_dispatch (begin): cmd: " << cmd
+//            << "  button y: " << button_dim.y2 
+//            << "  coll/inline/open: " << status_ << endl;
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
                if (status_ == Inlined)
                        InsetText::priv_dispatch(cur, cmd);
                else if (status_ == Open && !hitButton(cmd))
                        InsetText::priv_dispatch(cur, cmd);
+               else 
+                   cur.noUpdate();
                break;
 
        case LFUN_MOUSE_MOTION:
@@ -287,15 +285,15 @@ void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                        lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
                        setStatus(Open);
                        edit(cur, true);
+                       cur.bv().cursor() = cur;
                        break;
 
                case Open: {
-                       FuncRequest cmd1 = cmd;
-                       if (hitButton(cmd1)) {
+                       if (hitButton(cmd)) {
                                lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
                                setStatus(Collapsed);
-                               cur.undispatched();
-                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                               leaveInset(cur, *this);
+                               cur.bv().cursor() = cur;
                        } else {
                                lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
                                InsetText::priv_dispatch(cur, cmd);
index 5ed01e177f8468f08c44e66695f385ff943c4749..f4fac34f66115f3050800e2d55a387f41d6c6c73 100644 (file)
@@ -1422,9 +1422,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
 
                default: {
                        update = false;
-                       DispatchResult res = view()->cursor().dispatch(cmd);
-                       if (res.dispatched())
-                               update |= res.update();
+                       view()->cursor().dispatch(cmd);
+                       if (view()->cursor().result().dispatched())
+                               update |= view()->cursor().result().update();
                        else
                                update |= view()->dispatch(cmd);