mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Introduce default box frame color (#12921)
This better aligns with dark mode
This commit is contained in:
parent
46a62573c3
commit
087f6bce71
@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
|
|||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
2023-09-29 Jürgen Spitzmüller <spitz@lyx.org>
|
||||||
|
* Format incremented to 620: Add InsetBox "default" framecolor ("foreground"
|
||||||
|
rather than "black" in GUI). This aligns better with dark mode.
|
||||||
|
|
||||||
2023-09-06 Richard Kimberly Heck <rikiheck@lyx.org>
|
2023-09-06 Richard Kimberly Heck <rikiheck@lyx.org>
|
||||||
* Format incremented to 619: New document header \use_formatted_ref
|
* Format incremented to 619: New document header \use_formatted_ref
|
||||||
for workarea display purposes only.
|
for workarea display purposes only.
|
||||||
|
@ -5554,6 +5554,21 @@ def revert_formatted_refs(document):
|
|||||||
del document.header[i]
|
del document.header[i]
|
||||||
|
|
||||||
|
|
||||||
|
def revert_box_fcolor(document):
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token(document.body, '\\begin_inset Box Boxed', i+1)
|
||||||
|
if i == -1:
|
||||||
|
break
|
||||||
|
j = find_end_of_inset(document.body, i)
|
||||||
|
if j == -1:
|
||||||
|
document.warning("Malformed LyX document: Can't find end of framed box inset at line %d" % i)
|
||||||
|
continue
|
||||||
|
k = find_token(document.body, 'framecolor "default"', i, j)
|
||||||
|
if k != -1:
|
||||||
|
document.body[k] = 'framecolor "black"'
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -5634,11 +5649,13 @@ convert = [
|
|||||||
[616, [convert_empty_macro]],
|
[616, [convert_empty_macro]],
|
||||||
[617, [convert_cov_options]],
|
[617, [convert_cov_options]],
|
||||||
[618, []],
|
[618, []],
|
||||||
[619, []]
|
[619, []],
|
||||||
|
[620, []]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
revert = [[618, [revert_formatted_refs]],
|
revert = [[619, [revert_box_fcolor]],
|
||||||
|
[618, [revert_formatted_refs]],
|
||||||
[617, [revert_hequotes]],
|
[617, [revert_hequotes]],
|
||||||
[616, [revert_expreambles,revert_exarg2,revert_linggloss2,revert_cov_options]],
|
[616, [revert_expreambles,revert_exarg2,revert_linggloss2,revert_cov_options]],
|
||||||
[615, [revert_empty_macro]],
|
[615, [revert_empty_macro]],
|
||||||
|
@ -133,6 +133,8 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
|||||||
connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
||||||
connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
connect(frameColorCO, SIGNAL(currentIndexChanged(int)),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
connect(backgroundColorCO, SIGNAL(currentIndexChanged(int)),
|
connect(backgroundColorCO, SIGNAL(currentIndexChanged(int)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
|
||||||
@ -159,15 +161,17 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBox::fillComboColor(QComboBox * combo, bool const is_none)
|
void GuiBox::fillComboColor(QComboBox * combo, bool const is_background)
|
||||||
{
|
{
|
||||||
combo->clear();
|
combo->clear();
|
||||||
QPixmap coloritem(32, 32);
|
QPixmap coloritem(32, 32);
|
||||||
QColor color;
|
QColor color;
|
||||||
// frameColorCO cannot be uncolored
|
// condition on the two possible types
|
||||||
if (is_none)
|
if (is_background)
|
||||||
combo->addItem(toqstr(translateIfPossible(lcolor.getGUIName(Color_none))),
|
combo->addItem(toqstr(translateIfPossible(lcolor.getGUIName(Color_none))),
|
||||||
toqstr(lcolor.getLaTeXName(Color_none)));
|
toqstr(lcolor.getLaTeXName(Color_none)));
|
||||||
|
else
|
||||||
|
combo->addItem(qt_("Default"), toqstr("default"));
|
||||||
QList<ColorCode>::const_iterator cit = color_codes_.begin();
|
QList<ColorCode>::const_iterator cit = color_codes_.begin();
|
||||||
for (; cit != color_codes_.end(); ++cit) {
|
for (; cit != color_codes_.end(); ++cit) {
|
||||||
QString const latexname = toqstr(lcolor.getLaTeXName(*cit));
|
QString const latexname = toqstr(lcolor.getLaTeXName(*cit));
|
||||||
@ -215,32 +219,6 @@ void GuiBox::on_typeCO_activated(int index)
|
|||||||
widthCB->setChecked(itype != "none");
|
widthCB->setChecked(itype != "none");
|
||||||
pagebreakCB->setChecked(false);
|
pagebreakCB->setChecked(false);
|
||||||
}
|
}
|
||||||
// assure that the frame color is black for frameless boxes to
|
|
||||||
// provide the color "none"
|
|
||||||
int const b = frameColorCO->findData("black");
|
|
||||||
if (frameless && frameColorCO->currentIndex() != b)
|
|
||||||
frameColorCO->setCurrentIndex(b);
|
|
||||||
changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiBox::on_frameColorCO_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
// if there is a non-black frame color the background cannot be uncolored
|
|
||||||
// therefore remove the entry "none" in this case
|
|
||||||
int const n = backgroundColorCO->findData("none");
|
|
||||||
if (index != frameColorCO->findData("black")) {
|
|
||||||
if (n != -1) {
|
|
||||||
if (backgroundColorCO->currentIndex() == n)
|
|
||||||
backgroundColorCO->setCurrentIndex(
|
|
||||||
backgroundColorCO->findData("white"));
|
|
||||||
backgroundColorCO->removeItem(n);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (n == -1)
|
|
||||||
backgroundColorCO->insertItem(0, toqstr(translateIfPossible((lcolor.getGUIName(Color_none)))),
|
|
||||||
toqstr(lcolor.getLaTeXName(Color_none)));
|
|
||||||
}
|
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +464,7 @@ docstring GuiBox::dialogToParams() const
|
|||||||
params.framecolor =
|
params.framecolor =
|
||||||
fromqstr(frameColorCO->itemData(frameColorCO->currentIndex()).toString());
|
fromqstr(frameColorCO->itemData(frameColorCO->currentIndex()).toString());
|
||||||
else
|
else
|
||||||
params.framecolor = "black";
|
params.framecolor = "foreground";
|
||||||
if (backgroundColorCO->isEnabled())
|
if (backgroundColorCO->isEnabled())
|
||||||
params.backgroundcolor =
|
params.backgroundcolor =
|
||||||
fromqstr(backgroundColorCO->itemData(backgroundColorCO->currentIndex()).toString());
|
fromqstr(backgroundColorCO->itemData(backgroundColorCO->currentIndex()).toString());
|
||||||
|
@ -30,7 +30,6 @@ public:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void on_innerBoxCO_activated(int);
|
void on_innerBoxCO_activated(int);
|
||||||
void on_typeCO_activated(int);
|
void on_typeCO_activated(int);
|
||||||
void on_frameColorCO_currentIndexChanged(int);
|
|
||||||
void initDialog();
|
void initDialog();
|
||||||
void on_widthCB_stateChanged(int state);
|
void on_widthCB_stateChanged(int state);
|
||||||
void on_heightCB_stateChanged(int state);
|
void on_heightCB_stateChanged(int state);
|
||||||
@ -48,7 +47,7 @@ private:
|
|||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// Fill the color combos
|
/// Fill the color combos
|
||||||
void fillComboColor(QComboBox * combo, bool const is_none);
|
void fillComboColor(QComboBox * combo, bool const is_background);
|
||||||
/// add and remove special lengths
|
/// add and remove special lengths
|
||||||
void setSpecial(bool ibox);
|
void setSpecial(bool ibox);
|
||||||
/// only show valid inner box items
|
/// only show valid inner box items
|
||||||
|
@ -165,7 +165,7 @@ void InsetBox::setButtonLabel()
|
|||||||
|
|
||||||
// set the frame color for the inset if the type is Boxed
|
// set the frame color for the inset if the type is Boxed
|
||||||
if (btype == Boxed)
|
if (btype == Boxed)
|
||||||
setFrameColor(lcolor.getFromLaTeXName(params_.framecolor));
|
setFrameColor(lcolor.getFromLaTeXName(getFrameColor(true)));
|
||||||
else
|
else
|
||||||
setFrameColor(Color_collapsibleframe);
|
setFrameColor(Color_collapsibleframe);
|
||||||
}
|
}
|
||||||
@ -429,8 +429,8 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
if (separation_string != defaultSep && thickness_string == defaultThick)
|
if (separation_string != defaultSep && thickness_string == defaultThick)
|
||||||
os << "{\\fboxsep " << from_ascii(separation_string);
|
os << "{\\fboxsep " << from_ascii(separation_string);
|
||||||
if (!params_.inner_box && !width_string.empty()) {
|
if (!params_.inner_box && !width_string.empty()) {
|
||||||
if (params_.framecolor != "black" || params_.backgroundcolor != "none") {
|
if (params_.framecolor != "default" || params_.backgroundcolor != "none") {
|
||||||
os << maybeBeginL << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}{";
|
os << maybeBeginL << "\\fcolorbox{" << getFrameColor() << "}{" << getBackgroundColor() << "}{";
|
||||||
os << "\\makebox";
|
os << "\\makebox";
|
||||||
needEndL = !maybeBeginL.empty();
|
needEndL = !maybeBeginL.empty();
|
||||||
} else
|
} else
|
||||||
@ -448,8 +448,8 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
if (params_.hor_pos != 'c')
|
if (params_.hor_pos != 'c')
|
||||||
os << "[" << params_.hor_pos << "]";
|
os << "[" << params_.hor_pos << "]";
|
||||||
} else {
|
} else {
|
||||||
if (params_.framecolor != "black" || params_.backgroundcolor != "none") {
|
if (params_.framecolor != "default" || params_.backgroundcolor != "none") {
|
||||||
os << maybeBeginL << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}";
|
os << maybeBeginL << "\\fcolorbox{" << getFrameColor() << "}{" << getBackgroundColor() << "}";
|
||||||
needEndL = !maybeBeginL.empty();
|
needEndL = !maybeBeginL.empty();
|
||||||
} else {
|
} else {
|
||||||
if (!cprotect.empty() && contains(runparams.active_chars, '^')) {
|
if (!cprotect.empty() && contains(runparams.active_chars, '^')) {
|
||||||
@ -616,7 +616,7 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
case Boxed:
|
case Boxed:
|
||||||
os << "}";
|
os << "}";
|
||||||
if (!params_.inner_box && !width_string.empty()
|
if (!params_.inner_box && !width_string.empty()
|
||||||
&& (params_.framecolor != "black" || params_.backgroundcolor != "none"))
|
&& (params_.framecolor != "default" || params_.backgroundcolor != "none"))
|
||||||
os << "}";
|
os << "}";
|
||||||
if (separation_string != defaultSep || thickness_string != defaultThick)
|
if (separation_string != defaultSep || thickness_string != defaultThick)
|
||||||
os << "}";
|
os << "}";
|
||||||
@ -809,7 +809,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
|
|||||||
break;
|
break;
|
||||||
case Boxed:
|
case Boxed:
|
||||||
features.require("calc");
|
features.require("calc");
|
||||||
if (params_.framecolor != "black" || params_.backgroundcolor != "none")
|
if (getFrameColor() != "black" || getBackgroundColor() != "white")
|
||||||
features.require("xcolor");
|
features.require("xcolor");
|
||||||
break;
|
break;
|
||||||
case ovalbox:
|
case ovalbox:
|
||||||
@ -874,6 +874,22 @@ void InsetBox::string2params(string const & in, InsetBoxParams & params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const InsetBox::getFrameColor(bool const gui) const
|
||||||
|
{
|
||||||
|
if (params_.framecolor == "default")
|
||||||
|
return gui ? "foreground" : "black";
|
||||||
|
return params_.framecolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const InsetBox::getBackgroundColor() const
|
||||||
|
{
|
||||||
|
if (params_.backgroundcolor == "none")
|
||||||
|
return "white";
|
||||||
|
return params_.backgroundcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// InsetBoxParams
|
// InsetBoxParams
|
||||||
@ -895,7 +911,7 @@ InsetBoxParams::InsetBoxParams(string const & label)
|
|||||||
thickness(Length(defaultThick)),
|
thickness(Length(defaultThick)),
|
||||||
separation(Length(defaultSep)),
|
separation(Length(defaultSep)),
|
||||||
shadowsize(Length(defaultShadow)),
|
shadowsize(Length(defaultShadow)),
|
||||||
framecolor("black"),
|
framecolor("default"),
|
||||||
backgroundcolor("none")
|
backgroundcolor("none")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -163,6 +163,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
/// used by the constructors
|
/// used by the constructors
|
||||||
void init();
|
void init();
|
||||||
|
///
|
||||||
|
std::string const getFrameColor(bool const gui = false) const;
|
||||||
|
///
|
||||||
|
std::string const getBackgroundColor() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
friend class InsetBoxParams;
|
friend class InsetBoxParams;
|
||||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
#define LYX_FORMAT_LYX 619 // rikiheck: formatted ref
|
#define LYX_FORMAT_LYX 620 // spitz: default box frame color
|
||||||
#define LYX_FORMAT_TEX2LYX 619
|
#define LYX_FORMAT_TEX2LYX 620
|
||||||
|
|
||||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user