]> git.lyx.org Git - lyx.git/commitdiff
Fixup d207e85c: paint sublabel with the correct background color
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Feb 2020 09:37:14 +0000 (10:37 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 7 Jun 2020 12:25:48 +0000 (14:25 +0200)
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)

src/MetricsInfo.cpp
src/MetricsInfo.h
src/insets/InsetCollapsible.cpp
status.23x

index 7ab62dce112f0c06381cc720d93267236de624da..1124ed81df516db279ae455c749e3abd49973659 100644 (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;
 }
 
 
index 717a5b09a4c0e737ca966d553681137800febfdd..1e247792a1ab7d64c88980ae2c2fa9d45be7f5df 100644 (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.
index 6c60e0b68e7a177f4ada985cb11f959ef48b1d7d..3a2a9a56465084731ed72e72d6f6af47161ac8c7 100644 (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,
index 1e2bcdd3edbabf12e64a7587895356e0d3a26568..0cf04438a15de113b4dc28cc20c09a21866ee533 100644 (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