From: Jean-Marc Lasgouttes Date: Mon, 24 Feb 2020 09:37:14 +0000 (+0100) Subject: Fixup d207e85c: paint sublabel with the correct background color X-Git-Tag: 2.3.6~104 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f01c23bd5a6c0adcd0bb9238112c3303d1adbc96;p=features.git 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 74540c9896892b8f956f52258a59613af83a5cf8) (cherry picked from commit a71b96ac426438abb4fe835d0ad000c769693421) --- diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp index 7ab62dce11..1124ed81df 100644 --- a/src/MetricsInfo.cpp +++ b/src/MetricsInfo.cpp @@ -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; } diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h index 717a5b09a4..1e247792a1 100644 --- a/src/MetricsInfo.h +++ b/src/MetricsInfo.h @@ -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. diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp index 6c60e0b68e..3a2a9a5646 100644 --- a/src/insets/InsetCollapsible.cpp +++ b/src/insets/InsetCollapsible.cpp @@ -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, diff --git a/status.23x b/status.23x index 1e2bcdd3ed..0cf04438a1 100644 --- a/status.23x +++ b/status.23x @@ -50,6 +50,8 @@ What's new - Ask to save hidden dirty documents (bug 11405). +- Fix background color of collapsible insets with sublabel. + * INTERNALS