summaryrefslogtreecommitdiff
path: root/svx/source/tbxctrls
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-21 08:51:56 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-12-21 10:59:36 +0100
commit4f140ebac1f971d72f5bb59ee23a3fe248c4d16e (patch)
tree78401e35dc42a0479b99ee6deb4cd392ed987c42 /svx/source/tbxctrls
parentd6fa091a75eaf665ec734a56ef1e10b72bc603dd (diff)
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
Diffstat (limited to 'svx/source/tbxctrls')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx52
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx4
2 files changed, 52 insertions, 4 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 4ed6d3059187..c9ca2a3f70ab 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -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);
+ }
}
}
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 9fe859e96a48..5a09dfef037e 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -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);
}