mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Remove space between button and text with inlines collapsible insets
Typically there are two sources of spacing: * the button has two pixels added to the left and to the right * the frame around the text also has 2 pixels to the left and to the right Note that this value of two pixels is given here for simplicity, but these are parameterized by methods like textOffset or leftOffset. What we want to remove is the space after the button and the space before the frame. This is done in 3 places In dimensionCollapsed(), the extra space is removed from the dimension after its computation In metrics(), the space avoided before the frame is removed from width. In draw, the whome text inset is drawn with a negative offset. Fixes #12335.
This commit is contained in:
parent
fb37682d74
commit
04ece4f0d6
@ -188,8 +188,13 @@ Dimension InsetCollapsible::dimensionCollapsed(BufferView const & bv) const
|
||||
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
|
||||
if (geometry(bv) == LeftButton)
|
||||
// this form makes a difference if offset is even
|
||||
dim.wid -= offset - offset / 2;
|
||||
return dim;
|
||||
}
|
||||
|
||||
@ -236,8 +241,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 {
|
||||
@ -314,7 +319,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;
|
||||
|
Loading…
Reference in New Issue
Block a user