Adhere to semantic background color with default branches

This fixes color mismatched when "use system colors" is checked

See https://marc.info/?l=lyx-users&m=172797086718347

(cherry picked from commit 1f7e8d3ffe)
This commit is contained in:
Juergen Spitzmueller 2024-10-05 14:15:19 +02:00 committed by Richard Kimberly Heck
parent f73b86132c
commit 478d59f5dd
3 changed files with 12 additions and 4 deletions

View File

@ -109,12 +109,14 @@ void Branch::setColors(string const & lmcol, string const & dmcol)
string lmcolor = lmcolor_; string lmcolor = lmcolor_;
string dmcolor = dmcolor_; string dmcolor = dmcolor_;
if (lmcolor == "none") if (lmcolor == "none")
lmcolor = lcolor.getX11HexName(Color_background); lmcolor = "background";
else if (lmcolor.size() != 7 || lmcolor[0] != '#') // if we have background color, keep semantic value, as system colors might vary
else if (lmcolor != "background" && (lmcolor.size() != 7 || lmcolor[0] != '#'))
lmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(lmcolor)); lmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(lmcolor));
if (dmcolor == "none") if (dmcolor == "none")
dmcolor = lcolor.getX11HexName(Color_background, true); dmcolor = "background";
else if (dmcolor.size() != 7 || dmcolor[0] != '#') // if we have background color, keep semantic value, as system colors might vary
else if (dmcolor != "background" && (dmcolor.size() != 7 || dmcolor[0] != '#'))
dmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(dmcolor), true); dmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(dmcolor), true);
// FIXME UNICODE // FIXME UNICODE

View File

@ -156,6 +156,10 @@ ColorCode InsetBranch::backgroundColor(PainterInfo const & pi) const
// FIXME UNICODE // FIXME UNICODE
string const branchcol = "branch" + branch_id + to_utf8(params_.branch); string const branchcol = "branch" + branch_id + to_utf8(params_.branch);
ColorCode c = lcolor.getFromLyXName(branchcol); ColorCode c = lcolor.getFromLyXName(branchcol);
// if we have background color, set to semantic value, as system colors
// might vary
if (lcolor.getX11HexName(c, (theApp() && theApp()->isInDarkMode())) == "background")
c = Color_background;
if (c == Color_none) if (c == Color_none)
c = Color_error; c = Color_error;
return c; return c;

View File

@ -66,6 +66,8 @@ What's new
- Allow negative offset values in Horizontal Line dialog (bug 13102). - Allow negative offset values in Horizontal Line dialog (bug 13102).
- Adhere to semantic background color with default branches.
* INTERNALS * INTERNALS