Fixup d207e85c: paint sublabel with the correct background color

The above mentionned patch did paint the background of the sublabel to
avoid "bold-like" effect. However the correct backgound color is the
row's one, not the inset's one.

To fix this, extend MetricsInfo::backgroundColor to work when no inset
is specified. The code is also simplified as in master.

(cherry picked from commit 74540c9896)
(cherry picked from commit a71b96ac42)
This commit is contained in:
Jean-Marc Lasgouttes 2020-02-24 10:37:14 +01:00
parent 696d9dc52b
commit f01c23bd5a
4 changed files with 17 additions and 15 deletions

View File

@ -138,24 +138,24 @@ void PainterInfo::draw(int x, int y, docstring const & str)
ColorCode PainterInfo::backgroundColor(Inset const * inset, bool sel) const
{
ColorCode const color_bg = inset->backgroundColor(*this);
if (selected && sel)
// This inset is in a selection
return Color_selection;
else {
// special handling for inset background
if (inset != nullptr) {
ColorCode const color_bg = inset->backgroundColor(*this);
if (color_bg != Color_none)
// This inset has its own color
return color_bg;
else {
if (background_color == Color_none)
// This inset has no own color and does not inherit a color
return Color_background;
else
// This inset has no own color, but inherits a color
return background_color;
}
}
if (background_color == Color_none)
// This inset has no own color and does not inherit a color
return Color_background;
// This inset has no own color, but inherits a color
return background_color;
}

View File

@ -107,11 +107,11 @@ public:
void draw(int x, int y, char_type c);
///
void draw(int x, int y, docstring const & str);
/// Determines the background color for the specified inset based on the
/// Determines the background color based on the
/// selection state, the background color inherited from the parent inset
/// and the inset's own background color.
/// and the inset's own background color (if one is specified).
/// \param sel whether to take the selection state into account
ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
ColorCode backgroundColor(Inset const * inset = nullptr, bool sel = true) const;
/// Determines the text color based on the intended color, the
/// change tracking state and the selection state.

View File

@ -336,7 +336,7 @@ void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const
int w = 0;
int a = 0;
int d = 0;
Color const col = pi.full_repaint ? Color_none : pi.backgroundColor(this);
Color const col = pi.full_repaint ? Color_none : pi.backgroundColor();
theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
int const ww = max(textdim.wid, w);
pi.pain.rectText(x + (ww - w) / 2, y + desc + a,

View File

@ -50,6 +50,8 @@ What's new
- Ask to save hidden dirty documents (bug 11405).
- Fix background color of collapsible insets with sublabel.
* INTERNALS