X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCollapsible.cpp;h=a0a789cc6759416bd14f50b149928c8809870bf1;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=84bb314f3c667e619149d23e6c2f63ab68faa67f;hpb=06a77312749f679b0c81a8a4b7277c17bd684262;p=lyx.git diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp index 84bb314f3c..a0a789cc67 100644 --- a/src/insets/InsetCollapsible.cpp +++ b/src/insets/InsetCollapsible.cpp @@ -187,12 +187,17 @@ Dimension InsetCollapsible::dimensionCollapsed(BufferView const & bv) const { Dimension dim; FontInfo labelfont(getLabelfont()); - int const offset = - (geometry(bv) != LeftButton && geometry(bv) != TopButton) - ? Inset::textOffset(&bv) : 0; labelfont.realize(sane_font); + int const offset = Inset::textOffset(&bv); theFontMetrics(labelfont).buttonText( 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; } @@ -239,8 +244,8 @@ void InsetCollapsible::metrics(MetricsInfo & mi, Dimension & dim) const 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 { @@ -317,7 +322,9 @@ void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const 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; @@ -420,7 +427,7 @@ void InsetCollapsible::cursorPos(BufferView const & bv, 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;