]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.C
insetcharstyle drawing cosmetics
[lyx.git] / src / insets / insetcollapsable.C
index 6d908ce86e3d68ef327bfd58c3d62e33e670b16a..3d16d9a15d3143af022f4e6a2ad8678a2b1a477d 100644 (file)
@@ -55,7 +55,7 @@ InsetCollapsable::InsetCollapsable(BufferParams const & bp,
        : InsetText(bp), label("Label"), status_(status), openinlined_(false)
 {
        setAutoBreakRows(true);
-       setDrawFrame(InsetText::ALWAYS);
+       setDrawFrame(true);
        setFrameColor(LColor::collapsableframe);
        setInsetName("Collapsable");
        setButtonLabel();
@@ -240,17 +240,12 @@ void InsetCollapsable::edit(LCursor & cur, bool left)
 }
 
 
-InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
+InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) const
 {
-       cur.push(*this);
+       cur.push(const_cast<InsetCollapsable&>(*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 const_cast<InsetCollapsable*>(this);
        }
        return InsetText::editXY(cur, x, y);
 }
@@ -258,14 +253,21 @@ 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;
+
+       lyxerr << "InsetCollapsable::priv_dispatch (begin): cmd: " << cmd
+               << " cur: " << cur << " bvcur: " << cur.bv().cursor() << 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 +289,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);