Fixup 74540c98: handle selection for label background

74540c98 was a fixup of d207e85c, which avoided using inset background
as inset label background.

d207e85c introduced a background under inset labels to avoid fake bold
effect.

Hopefully, this last variation will be the right one !
This commit is contained in:
Jean-Marc Lasgouttes 2020-06-05 22:32:58 +02:00
parent cb26ecbb58
commit a71b96ac42
3 changed files with 14 additions and 12 deletions

View File

@ -153,19 +153,21 @@ 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;
if (pain.develMode() && !inset->isBufferValid())
// This inset is in error
return Color_error;
// special handling for inset background
if (inset != nullptr) {
if (pain.develMode() && !inset->isBufferValid())
// This inset is in error
return Color_error;
if (color_bg != Color_none)
// This inset has its own color
return color_bg;
ColorCode const color_bg = inset->backgroundColor(*this);
if (color_bg != Color_none)
// This inset has its own color
return color_bg;
}
if (background_color == Color_none)
// This inset has no own color and does not inherit a color

View File

@ -116,11 +116,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

@ -371,7 +371,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.background_color;
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,