}
-bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
{
autoOpen_ = mi.base.bv->cursor().isInside(this);
case Corners:
InsetText::metrics(mi, dim);
dim.des -= 3;
- dim.asc -= 3;
+ dim.asc -= 1;
break;
case SubLabel: {
InsetText::metrics(mi, dim);
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:
} else {
dim.des += textdim.height() + TEXT_TO_BOTTOM_OFFSET;
dim.wid = max(dim.wid, textdim.wid);
- if (hasFixedWidth())
- dim.wid = max(dim.wid, mi.base.textwidth);
}
}
break;
}
-
- bool const changed = dim_ != dim;
- dim_ = dim;
- return changed;
}
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;
- const int xx2 = x + dim_.wid - 2 * TEXT_TO_INSET_OFFSET - 1;
+ const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
pi.pain.line(xx1, y + desc - 4,
xx1, y + desc,
layout_.labelfont.color());
xx2, y + desc,
layout_.labelfont.color());
}
- pi.pain.line(x + dim_.wid - 3, y + desc, x + dim_.wid - 3, y + desc - 4,
+ pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3, y + desc - 4,
layout_.labelfont.color());
// the label below the text. Can be toggled.
int w = 0;
int a = 0;
int d = 0;
- // FIXME UNICODE
docstring s = layout_.labelstring;
theFontMetrics(font).rectText(s, w, a, d);
- pi.pain.rectText(x + (dim_.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 clue when the cursor is inside the inset
+ // 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());
- pi.pain.line(xx2, y + 4, x + dim_.wid - 3, y,
+ pi.pain.line(xx2, y + 4, xx2, y,
layout_.labelfont.color());
pi.pain.line(xx2 - 4, y, xx2, y,
layout_.labelfont.color());
void InsetCollapsable::cursorPos(BufferView const & bv,
CursorSlice const & sl, bool boundary, int & x, int & y) const
{
+ if (geometry() == ButtonOnly)
+ status_ = Open;
BOOST_ASSERT(geometry() != ButtonOnly);
InsetText::cursorPos(bv, sl, boundary, x, y);