InsetCollapsible::CollapseStatus InsetCollapsible::status(BufferView const & bv) const
{
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return status_;
return view_[&bv].auto_open_ ? Open : status_;
}
InsetCollapsible::Geometry InsetCollapsible::geometry(BufferView const & bv) const
{
switch (decoration()) {
- case InsetLayout::CLASSIC:
+ case InsetDecoration::CLASSIC:
if (status(bv) == Open)
return view_[&bv].openinlined_ ? LeftButton : TopButton;
return ButtonOnly;
- case InsetLayout::MINIMALISTIC: {
+ case InsetDecoration::MINIMALISTIC: {
return status(bv) == Open ?
(tempfile_ ? LeftButton : NoButton)
: ButtonOnly;
}
- case InsetLayout::CONGLOMERATE:
+ case InsetDecoration::CONGLOMERATE:
return status(bv) == Open ? SubLabel : Corners ;
- case InsetLayout::DEFAULT:
+ case InsetDecoration::DEFAULT:
break; // this shouldn't happen
}
Dimension dim;
FontInfo labelfont(getLabelfont());
labelfont.realize(sane_font);
+ int const offset = Inset::textOffset(&bv);
theFontMetrics(labelfont).buttonText(
- buttonLabel(bv), Inset::textOffset(&bv), dim.wid, dim.asc, dim.des);
+ buttonLabel(bv), offset, dim.wid, dim.asc, dim.des);
+ // remove spacing on the right for left buttons; we also do it for
+ // TopButton (although it is not useful per se), because
+ // openinlined_ is not always set properly at this point.
+ Geometry const geom = geometry(bv);
+ if (geom == LeftButton || geom == TopButton)
+ // this form makes a difference if offset is even
+ dim.wid -= offset - offset / 2;
return dim;
}
{
view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
- FontInfo tmpfont = mi.base.font;
- mi.base.font = getFont();
- mi.base.font.realize(tmpfont);
-
BufferView const & bv = *mi.base.bv;
switch (geometry(bv)) {
int d = 0;
theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
dim.des += a + d;
+ dim.wid = max(dim.wid, w);
break;
}
case TopButton:
InsetText::metrics(mi, textdim);
view_[&bv].openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
if (view_[&bv].openinlined_) {
- // Correct for button width.
- dim.wid += textdim.wid;
+ // Correct for button width but remove spacing before frame
+ dim.wid += textdim.wid - leftOffset(mi.base.bv) / 2;
dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
dim.asc = textdim.asc;
} else {
}
break;
}
-
- mi.base.font = tmpfont;
}
}
+ColorCode InsetCollapsible::backgroundColor(PainterInfo const &) const
+{
+ return getLayout().bgcolor();
+}
+
+
+ColorCode InsetCollapsible::labelColor() const
+{
+ return getLayout().labelfont().color();
+}
+
+
void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const
{
BufferView const & bv = *pi.base.bv;
case LeftButton:
case TopButton: {
if (g == LeftButton) {
- textx = x + dimc.width();
+ // correct for spacing added before the frame in
+ // InsetText::draw. We want the button to touch the frame.
+ textx = x + dimc.width() - leftOffset(pi.base.bv) / 2;
texty = baseline;
} else {
textx = x;
switch (geometry(bv)) {
case LeftButton:
- x += dimensionCollapsed(bv).wid;
+ x += dimensionCollapsed(bv).wid - leftOffset(&bv) / 2;
break;
case TopButton: {
y += dimensionCollapsed(bv).des + textdim.asc;
return false;
switch (decoration()) {
- case InsetLayout::CLASSIC:
- case InsetLayout::MINIMALISTIC:
+ case InsetDecoration::CLASSIC:
+ case InsetDecoration::MINIMALISTIC:
return status_ == Open;
default:
return true;
{
// U+1F512 LOCK
docstring const locked = tempfile_ ? docstring(1, 0x1F512) : docstring();
- if (decoration() == InsetLayout::MINIMALISTIC)
- return locked;
// indicate changed content in label (#8645)
// ✎ U+270E LOWER RIGHT PENCIL
docstring const indicator = (isChanged() && geometry(bv) == ButtonOnly)
InsetLayout const & il = getLayout();
docstring const label = getLabel();
if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
- return indicator + label;
+ return locked + indicator + label;
return locked + indicator + getNewLabel(label);
}
}
-InsetLayout::InsetDecoration InsetCollapsible::decoration() const
+InsetDecoration InsetCollapsible::decoration() const
{
- InsetLayout::InsetDecoration const dec = getLayout().decoration();
- return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
+ InsetDecoration const dec = getLayout().decoration();
+ return dec == InsetDecoration::DEFAULT ? InsetDecoration::CLASSIC : dec;
}
{
string context_menu = contextMenuName();
string const it_context_menu = InsetText::contextMenuName();
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return context_menu + ";" + it_context_menu;
string const ic_context_menu = InsetCollapsible::contextMenuName();
string InsetCollapsible::contextMenuName() const
{
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return "context-conglomerate";
else
return "context-collapsible";