]> git.lyx.org Git - features.git/commitdiff
inlined open submode, in the hope someone will actually test it. Easy take it back...
authorAlfredo Braunstein <abraunst@lyx.org>
Wed, 10 Mar 2004 08:50:46 +0000 (08:50 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Wed, 10 Mar 2004 08:50:46 +0000 (08:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8483 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h

index 0e41f9c9e7337f6a7ced449074f7156819dbcb0b..d5bf35af27b4998facf4d72a628a868d69637177 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-09  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * insetcollapsable.[Ch] (metrics, draw): implemented an inlined-Open 
+       submode.
+
 2004-03-07  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * insetcite.[Ch]: support jurabib.
index 8174217e5dac6f317a89280aa85ffab0154c33b3..9ae7b1541ac3160532b3e19fdb8eef370e1c2a7a 100644 (file)
@@ -41,7 +41,7 @@ using std::ostream;
 
 InsetCollapsable::InsetCollapsable(BufferParams const & bp,
        CollapseStatus status)
-       : inset(bp), label("Label"), status_(status)
+       : inset(bp), label("Label"), status_(status), openinlined_(false)
 {
        inset.setOwner(this);
        inset.setAutoBreakRows(true);
@@ -127,14 +127,6 @@ void InsetCollapsable::dimension_collapsed(Dimension & dim) const
 }
 
 
-int InsetCollapsable::height_collapsed() const
-{
-       Dimension dim;
-       font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
-       return dim.asc + dim.des;
-}
-
-
 void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (status_ == Inlined) {
@@ -144,8 +136,16 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
                if (status_ == Open) {
                        Dimension insetdim;
                        inset.metrics(mi, insetdim);
-                       dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET;
-                       dim.wid = max(dim.wid, insetdim.wid);
+                       openinlined_ = (insetdim.wid + dim.wid <= mi.base.textwidth);
+                       if (openinlined_) {
+                               dim.wid += insetdim.wid;
+                               dim.des = max(dim.des, insetdim.des);
+                               dim.asc = max(dim.asc, insetdim.asc);
+                       } else {
+                               dim.des += insetdim.height()
+                                       + TEXT_TO_BOTTOM_OFFSET;
+                               dim.wid = max(dim.wid, insetdim.wid);
+                       }
                }
        }
        dim_ = dim;
@@ -177,7 +177,11 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                if (status_ == Open) {
                        if (!owner())
                                x += scroll();
-                       inset.draw(pi, x, y - aa + dimc.height() + inset.ascent());
+                       
+                       if (openinlined_)
+                               inset.draw(pi, x + dimc.width(), y - aa + inset.ascent());
+                       else 
+                               inset.draw(pi, x, y - aa + dimc.height() + inset.ascent());
                }
        }
 }
@@ -324,14 +328,14 @@ void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                case LFUN_MOUSE_PRESS:
                        if (status_ == Inlined)
                                inset.dispatch(cur, cmd);
-                       else if (status_ == Open && cmd.y > button_dim.y2)
+                       else if (status_ == Open && !hitButton(cmd))
                                inset.dispatch(cur, cmd);
                        break;
 
                case LFUN_MOUSE_MOTION:
                        if (status_ == Inlined)
                                inset.dispatch(cur, cmd);
-                       else if (status_ == Open && cmd.y > button_dim.y2)
+                       else if (status_ == Open && !hitButton(cmd))
                                inset.dispatch(cur, cmd);
                        break;
 
index e2911cbc27f3c1e41c8b3eb140431d7aa144b4f1..2ed7643435b5197a5b35d6715e4059b5ab91dfc9 100644 (file)
@@ -127,8 +127,6 @@ protected:
        ///
        void dimension_collapsed(Dimension &) const;
        ///
-       int height_collapsed() const;
-       ///
        void draw_collapsed(PainterInfo & pi, int x, int y) const;
        ///
        int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
@@ -160,6 +158,8 @@ protected:
 private:
        ///
        mutable CollapseStatus status_;
+       /// a substatus of the Open status, determined automatically in metrics
+       mutable bool openinlined_;
 };
 
 #endif