From ee0860e403d144308b1cdcb0ef223bc34008c64b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 30 Nov 2012 17:11:07 +0100 Subject: [PATCH] Fix shaded box UI color (#7395) as good as it gets ATM --- src/BufferParams.cpp | 1 + src/insets/InsetBox.cpp | 15 +++++++++++++++ src/insets/InsetBox.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 403a2cbbe1..b18bf79602 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -819,6 +819,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, lex.eatLine(); string color = lex.getString(); boxbgcolor = lyx::rgbFromHexName(color); + lcolor.setColor("boxbgcolor", color); } else if (token == "\\paperwidth") { lex >> paperwidth; } else if (token == "\\paperheight") { diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 2e611ffd30..f55abcdfa1 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -17,6 +17,7 @@ #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" +#include "ColorSet.h" #include "Cursor.h" #include "DispatchResult.h" #include "FuncStatus.h" @@ -184,6 +185,20 @@ bool InsetBox::forcePlainLayout(idx_type) const } +ColorCode InsetBox::backgroundColor(PainterInfo const &) const +{ + if (params_.type != "Shaded") + return getLayout().bgcolor(); + // FIXME: This hardcoded color is a hack! + if (buffer().params().boxbgcolor == lyx::rgbFromHexName("#ff0000")) + return getLayout().bgcolor(); + ColorCode c = lcolor.getFromLyXName("boxbgcolor"); + if (c == Color_none) + return getLayout().bgcolor(); + return c; +} + + void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index 236525e7a8..cf0f689ed1 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -102,6 +102,8 @@ public: /// DisplayType display() const { return Inline; } /// + ColorCode backgroundColor(PainterInfo const &) const; + /// bool allowParagraphCustomization(idx_type = 0) const { return !forcePlainLayout(); } /// bool forcePlainLayout(idx_type = 0) const; -- 2.39.2