sd theme: allow setting color effects in the chardlg
Which means not only the 12 colors from the theme are offered (which comes from the current master page), but also lighter/darker variants. And once these are selected, their theme index and luminance modulation / offset is also remembered. This means if you pick light blue and later change accent1 from blue to orange, you get light orange out of the box. Change-Id: Ia83b8971ad894d02ed4ec5ca914684fc9cf9a677 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127211 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -94,7 +94,8 @@ class Test(UITestCase):
|
||||
paletteSelector = floatWindow.getChild("palette_listbox")
|
||||
select_by_text(paletteSelector, "Theme colors")
|
||||
colorSet = floatWindow.getChild("colorset")
|
||||
colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": "4"}))
|
||||
# 4 would be accent1, +12 is the first from the effect variants.
|
||||
colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": "16"}))
|
||||
|
||||
# Then make sure the doc model has the correct color theme index:
|
||||
drawPage = component.getDrawPages().getByIndex(0)
|
||||
@@ -109,6 +110,14 @@ class Test(UITestCase):
|
||||
# i.e. no theme index was set, instead of accent1 (index into the above color scheme).
|
||||
self.assertEqual(portion.CharColorTheme, 4)
|
||||
|
||||
# Then make sure that '80% lighter' is lum-mod=2000 and lum-off=8000:
|
||||
# Without the accompanying fix in place, this test would have failed with:
|
||||
# AssertionError: 10000 != 2000
|
||||
# i.e. the effects where not applied, luminancen modulation was the default instead of a
|
||||
# custom value.
|
||||
self.assertEqual(portion.CharColorLumMod, 2000)
|
||||
self.assertEqual(portion.CharColorLumOff, 8000)
|
||||
|
||||
def testSvxCharEffectsPageWriter(self):
|
||||
# Start Writer.
|
||||
with self.ui_test.create_doc_in_start_center("writer") as component:
|
||||
|
@@ -1601,6 +1601,8 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
|
||||
{
|
||||
// The color was picked from the theme palette, remember its index.
|
||||
aItem.SetThemeIndex(aSelectedColor.m_nThemeIndex);
|
||||
aItem.SetLumMod(aSelectedColor.m_nLumMod);
|
||||
aItem.SetLumOff(aSelectedColor.m_nLumOff);
|
||||
}
|
||||
|
||||
rSet.Put(aItem);
|
||||
|
@@ -1523,6 +1523,10 @@ void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
|
||||
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(ss.str().c_str()));
|
||||
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("theme-index"),
|
||||
BAD_CAST(OString::number(maThemeIndex).getStr()));
|
||||
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("lum-mod"),
|
||||
BAD_CAST(OString::number(mnLumMod).getStr()));
|
||||
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("lum-off"),
|
||||
BAD_CAST(OString::number(mnLumOff).getStr()));
|
||||
|
||||
OUString aStr;
|
||||
IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
|
||||
|
@@ -83,8 +83,12 @@ public:
|
||||
maTintShade = nTintOrShade;
|
||||
}
|
||||
|
||||
void SetLumMod(sal_Int16 nLumMod) { mnLumMod = nLumMod; }
|
||||
|
||||
sal_Int16 GetLumMod() const { return mnLumMod; }
|
||||
|
||||
void SetLumOff(sal_Int16 nLumOff) { mnLumOff = nLumOff; }
|
||||
|
||||
sal_Int16 GetLumOff() const { return mnLumOff; }
|
||||
|
||||
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
|
||||
|
@@ -39,6 +39,8 @@ struct SVXCORE_DLLPUBLIC NamedThemedColor
|
||||
Color m_aColor;
|
||||
OUString m_aName;
|
||||
sal_Int16 m_nThemeIndex = -1;
|
||||
sal_Int16 m_nLumMod = 10000;
|
||||
sal_Int16 m_nLumOff = 0;
|
||||
|
||||
static NamedThemedColor FromNamedColor(const NamedColor& rNamedColor);
|
||||
|
||||
|
@@ -76,6 +76,9 @@ public:
|
||||
|
||||
bool IsThemePaletteSelected() const;
|
||||
|
||||
static void GetThemeIndexLumModOff(sal_uInt16 nItemId, sal_Int16& rThemeIndex,
|
||||
sal_Int16& rLumMod, sal_Int16& rLumOff);
|
||||
|
||||
static void DispatchColorCommand(const OUString& aCommand, const svx::NamedThemedColor& rColor);
|
||||
};
|
||||
|
||||
|
@@ -1132,6 +1132,11 @@
|
||||
#define RID_SVXSTR_THEME_COLOR10 NC_("RID_SVXSTR_THEME_COLOR10", "Accent 6")
|
||||
#define RID_SVXSTR_THEME_COLOR11 NC_("RID_SVXSTR_THEME_COLOR11", "Hyperlink")
|
||||
#define RID_SVXSTR_THEME_COLOR12 NC_("RID_SVXSTR_THEME_COLOR12", "Followed Hyperlink")
|
||||
#define RID_SVXSTR_THEME_EFFECT1 NC_("RID_SVXSTR_THEME_EFFECT1", "%1, 80% Lighter")
|
||||
#define RID_SVXSTR_THEME_EFFECT2 NC_("RID_SVXSTR_THEME_EFFECT2", "%1, 60% Lighter")
|
||||
#define RID_SVXSTR_THEME_EFFECT3 NC_("RID_SVXSTR_THEME_EFFECT3", "%1, 40% Lighter")
|
||||
#define RID_SVXSTR_THEME_EFFECT4 NC_("RID_SVXSTR_THEME_EFFECT4", "%1, 25% Darker")
|
||||
#define RID_SVXSTR_THEME_EFFECT5 NC_("RID_SVXSTR_THEME_EFFECT5", "%1, 50% Darker")
|
||||
|
||||
#define RID_SVX_EXTRUSION_BAR NC_("RID_SVX_EXTRUSION_BAR", "Extrusion")
|
||||
#define RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF NC_("RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF", "Apply Extrusion On/Off")
|
||||
|
@@ -43,6 +43,17 @@
|
||||
|
||||
#include <palettes.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
// Luminance modulation for the 6 effect presets.
|
||||
// 10000 is the default.
|
||||
sal_Int16 g_aLumMods[] = { 10000, 2000, 4000, 6000, 7500, 5000 };
|
||||
|
||||
// Luminance offset for the 6 effect presets.
|
||||
// 0 is the default.
|
||||
sal_Int16 g_aLumOffs[] = { 0, 8000, 6000, 4000, 0, 0 };
|
||||
}
|
||||
|
||||
PaletteManager::PaletteManager() :
|
||||
mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()),
|
||||
mnNumOfPalettes(3),
|
||||
@@ -131,6 +142,17 @@ bool PaletteManager::IsThemePaletteSelected() const
|
||||
return mnCurrentPalette == mnNumOfPalettes - 2;
|
||||
}
|
||||
|
||||
void PaletteManager::GetThemeIndexLumModOff(sal_uInt16 nItemId, sal_Int16& rThemeIndex,
|
||||
sal_Int16& rLumMod, sal_Int16& rLumOff)
|
||||
{
|
||||
// Each column is the same color with different effects.
|
||||
rThemeIndex = nItemId % 12;
|
||||
|
||||
// Each row is the same effect with different colors.
|
||||
rLumMod = g_aLumMods[nItemId / 12];
|
||||
rLumOff = g_aLumOffs[nItemId / 12];
|
||||
}
|
||||
|
||||
void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
|
||||
{
|
||||
if( mnCurrentPalette == 0)
|
||||
@@ -156,7 +178,13 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
|
||||
rColorSet.Clear();
|
||||
if (aColors.size() >= 12)
|
||||
{
|
||||
std::vector<OUString> aNames = {
|
||||
std::vector<OUString> aEffectNames = {
|
||||
SvxResId(RID_SVXSTR_THEME_EFFECT1), SvxResId(RID_SVXSTR_THEME_EFFECT2),
|
||||
SvxResId(RID_SVXSTR_THEME_EFFECT3), SvxResId(RID_SVXSTR_THEME_EFFECT4),
|
||||
SvxResId(RID_SVXSTR_THEME_EFFECT5),
|
||||
};
|
||||
|
||||
std::vector<OUString> aColorNames = {
|
||||
SvxResId(RID_SVXSTR_THEME_COLOR1), SvxResId(RID_SVXSTR_THEME_COLOR2),
|
||||
SvxResId(RID_SVXSTR_THEME_COLOR3), SvxResId(RID_SVXSTR_THEME_COLOR4),
|
||||
SvxResId(RID_SVXSTR_THEME_COLOR5), SvxResId(RID_SVXSTR_THEME_COLOR6),
|
||||
@@ -164,9 +192,27 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
|
||||
SvxResId(RID_SVXSTR_THEME_COLOR9), SvxResId(RID_SVXSTR_THEME_COLOR10),
|
||||
SvxResId(RID_SVXSTR_THEME_COLOR11), SvxResId(RID_SVXSTR_THEME_COLOR12),
|
||||
};
|
||||
for (int i = 0; i < 12; ++i)
|
||||
|
||||
sal_uInt16 nItemId = 0;
|
||||
// Each row is one effect type (no effect + each type).
|
||||
for (size_t nEffect = 0; nEffect < aEffectNames.size() + 1; ++nEffect)
|
||||
{
|
||||
rColorSet.InsertItem(i, aColors[i], aNames[i]);
|
||||
// Each column is one color type.
|
||||
for (size_t nColor = 0; nColor < aColorNames.size(); ++nColor)
|
||||
{
|
||||
Color aColor = aColors[nColor];
|
||||
aColor.ApplyLumModOff(g_aLumMods[nEffect], g_aLumOffs[nEffect]);
|
||||
OUString aColorName;
|
||||
if (nEffect == 0)
|
||||
{
|
||||
aColorName = aColorNames[nColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
aColorName = aEffectNames[nEffect - 1].replaceAll("%1", aColorNames[nColor]);
|
||||
}
|
||||
rColorSet.InsertItem(nItemId++, aColor, aColorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1972,7 +1972,9 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void)
|
||||
auto aNamedThemedColor = svx::NamedThemedColor::FromNamedColor(aNamedColor);
|
||||
if (mxPaletteManager->IsThemePaletteSelected())
|
||||
{
|
||||
aNamedThemedColor.m_nThemeIndex = pColorSet->GetSelectedItemId();
|
||||
PaletteManager::GetThemeIndexLumModOff(
|
||||
pColorSet->GetSelectedItemId(), aNamedThemedColor.m_nThemeIndex,
|
||||
aNamedThemedColor.m_nLumMod, aNamedThemedColor.m_nLumOff);
|
||||
}
|
||||
aColorSelectFunction(sCommand, aNamedThemedColor);
|
||||
}
|
||||
|
Reference in New Issue
Block a user