]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCollapsable.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetCollapsable.cpp
index 7844247ad681decb43ebdda2780566ea2894dfa3..654979df7f16116b1bdf393098ffd9eb095baf23 100644 (file)
@@ -170,7 +170,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const
 }
 
 
-bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        autoOpen_ = mi.base.bv->cursor().isInside(this);
 
@@ -195,8 +195,7 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
                int d = 0;
                docstring s = layout_.labelstring;
                theFontMetrics(font).rectText(s, w, a, d);
-               dim.wid = max(dim.wid, w);
-               dim.des += ascent();
+               dim.des += a + d;
                break;
                }
        case TopButton:
@@ -220,10 +219,6 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
                }
                break;
        }
-
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
 }
 
 
@@ -288,10 +283,8 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                InsetText::draw(pi, textx, texty);
                const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
 
-               int desc = InsetText::descent();
-               if (geometry() == SubLabel)
-                       desc -= ascent();
-               else
+               int desc = textdim.descent();
+               if (geometry() == Corners)
                        desc -= 3;
 
                const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
@@ -326,14 +319,16 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                        int d = 0;
                        docstring s = layout_.labelstring;
                        theFontMetrics(font).rectText(s, w, a, d);
-                       pi.pain.rectText(x + (textdim.wid - w) / 2, y + desc + a,
+                       int const ww = max(textdim.wid, w);
+                       pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
                                s, font, Color::none, Color::none);
+                       desc += d;
                }
 
                // a visual cue when the cursor is inside the inset
                Cursor & cur = pi.base.bv->cursor();
                if (cur.isInside(this)) {
-                       y -= ascent();
+                       y -= textdim.asc;
                        y += 3;
                        pi.pain.line(xx1, y + 4, xx1, y, layout_.labelfont.color());
                        pi.pain.line(xx1 + 4, y, xx1, y, layout_.labelfont.color());