On Wed, Apr 06, 2022 at 10:15:21AM +0200, Jean-Marc Lasgouttes wrote:
> Le 06/04/2022 à 08:23, Daniel a écrit :
> > On 2022-04-02 17:10, Scott Kostyshak wrote:
> > > If I go to Insert > Box, for the color, I see "Black" for the frame. In
> > > LaTeX, if we use ".", then that uses the "current"/"inherited" (I'm not
> > > sure of the correct terminology) color, but that doesn't seem to be an
> > > option in the combo box. Is there any way to use "." currently? I can
> > > edit the .lyx file with a text file and it seems to work well except
> > > that I get the following terminal warnings, as expected:
> > > 
> > >    ColorSet::getFromLaTeXName: Unknown color "."
> > > 
> > > Scott
> > 
> > While playing around with boxes, I came across the tcolorbox package. Do
> > you happen to know whether that is currently directly supported by LyX?
> 
> "git grep" tells me that it is implemented by the tcolorbox module.

Indeed using tcolorbox might suit my needs better. I might look into
using that. In any case, I worked on a patch for fcolorbox.

Scott
From b00260ebb2e5b5b84ac49a132e59f56582e0a9cd Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Thu, 7 Apr 2022 22:02:33 -0400
Subject: [PATCH] fcolorbox: allow to inherit font for frame and bg

Inserting '.' in LaTeX for the color means to inherit the font.

This design is consistent with the Text Properties dialog
(see GuiCharacter.cpp).
---
 src/frontends/qt/GuiBox.cpp |  1 +
 src/insets/InsetBox.cpp     | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt/GuiBox.cpp b/src/frontends/qt/GuiBox.cpp
index bda71a68ef..7871265988 100644
--- a/src/frontends/qt/GuiBox.cpp
+++ b/src/frontends/qt/GuiBox.cpp
@@ -164,6 +164,7 @@ void GuiBox::fillComboColor(QComboBox * combo, bool const is_none)
 	combo->clear();
 	QPixmap coloritem(32, 32);
 	QColor color;
+	combo->addItem(qt_("Default"), "inherit");
 	// frameColorCO cannot be uncolored
 	if (is_none)
 		combo->addItem(toqstr(translateIfPossible(lcolor.getGUIName(Color_none))),
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp
index c04bd1e927..40ac40eea0 100644
--- a/src/insets/InsetBox.cpp
+++ b/src/insets/InsetBox.cpp
@@ -430,8 +430,14 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
 			os << "{\\fboxsep " << from_ascii(separation_string);
 		if (!params_.inner_box && !width_string.empty()) {
 			if (params_.framecolor != "black" || params_.backgroundcolor != "none") {
-				os << maybeBeginL << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}{";
-				os << "\\makebox";
+				os << maybeBeginL << "\\fcolorbox{"
+				   << (params_.framecolor == "inherit" ? "." :
+				       params_.framecolor)
+				   << "}{"
+				   << (params_.backgroundcolor == "inherit" ? "." :
+				       params_.backgroundcolor)
+				   << "}{"
+				   << "\\makebox";
 				needEndL = !maybeBeginL.empty();
 			} else
 				os << "\\framebox";
@@ -449,7 +455,13 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
 				os << "[" << params_.hor_pos << "]";
 		} else {
 			if (params_.framecolor != "black" || params_.backgroundcolor != "none") {
-				os << maybeBeginL << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}";
+				os << maybeBeginL << "\\fcolorbox{"
+				   << (params_.framecolor == "inherit" ? "." :
+				       params_.framecolor)
+				   << "}{"
+				   << (params_.backgroundcolor == "inherit" ? "." :
+				       params_.backgroundcolor)
+				   << "}";
 				needEndL = !maybeBeginL.empty();
 			} else {
 				if (!cprotect.empty() && contains(runparams.active_chars, '^')) {
-- 
2.32.0

Attachment: signature.asc
Description: PGP signature

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to