From 6581d0b31869a4aea3bca27dcbaaaf0b2abddf3e Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 22 Apr 2015 17:45:13 +0900 Subject: Modify tint/shade for theme colors, different shades for headings Change-Id: I6e6fbcb64f14c1abe07902c4dd53ef154aae29f7 --- sw/source/uibase/sidebar/ThemePanel.cxx | 98 ++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index c6577b1b8d04..75bace967b7f 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -65,15 +67,19 @@ class ColorVariable public: long mnIndex; Color maColor; + sal_Int16 mnTintShade; ColorVariable() + : mnIndex(-1) + , maColor() + , mnTintShade() {} - ColorVariable(long nIndex) + ColorVariable(long nIndex, sal_Int16 nTintShade = 0) : mnIndex(nIndex) , maColor() + , mnTintShade(nTintShade) {} - }; class StyleRedefinition @@ -95,14 +101,30 @@ public: Color getColor(ColorSet& rColorSet) { + Color aColor; if (maVariable.mnIndex > -1) { - return rColorSet.maColors[maVariable.mnIndex]; + aColor.SetColor(rColorSet.maColors[maVariable.mnIndex].GetColor()); + if (maVariable.mnTintShade < 0) + { + double fFactor = std::abs(maVariable.mnTintShade) / 10000.0; + aColor.SetRed(MinMax(aColor.GetRed() + (fFactor * (255.0 - aColor.GetRed())), 0, 255)); + aColor.SetGreen(MinMax(aColor.GetGreen() + (fFactor * (255.0 - aColor.GetGreen())), 0, 255)); + aColor.SetBlue(MinMax(aColor.GetBlue() + (fFactor * (255.0 - aColor.GetBlue())), 0, 255)); + } + else if (maVariable.mnTintShade > 0) + { + double fFactor = 1.0 - std::abs(maVariable.mnTintShade) / 10000.0; + aColor.SetRed(MinMax(aColor.GetRed() * fFactor, 0, 255)); + aColor.SetGreen(MinMax(aColor.GetGreen() * fFactor, 0, 255)); + aColor.SetBlue(MinMax(aColor.GetBlue() * fFactor, 0, 255)); + } } else { - return maVariable.maColor; + aColor.SetColor(maVariable.maColor.GetColor()); } + return aColor; } }; @@ -139,9 +161,65 @@ StyleSet setupThemes() { StyleSet aSet("Default"); - StyleRedefinition aRedefinition("Heading"); - aRedefinition.setColorVariable(ColorVariable(0)); - aSet.add(aRedefinition); + { + StyleRedefinition aRedefinition("Heading 1"); + aRedefinition.setColorVariable(ColorVariable(0, 4000)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 2"); + aRedefinition.setColorVariable(ColorVariable(0, 2500)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 3"); + aRedefinition.setColorVariable(ColorVariable(0, 1000)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 4"); + aRedefinition.setColorVariable(ColorVariable(0)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 5"); + aRedefinition.setColorVariable(ColorVariable(0, -500)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 6"); + aRedefinition.setColorVariable(ColorVariable(0, -1000)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 7"); + aRedefinition.setColorVariable(ColorVariable(0, -1500)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 8"); + aRedefinition.setColorVariable(ColorVariable(0, -2000)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 9"); + aRedefinition.setColorVariable(ColorVariable(0, -2500)); + aSet.add(aRedefinition); + } + + { + StyleRedefinition aRedefinition("Heading 10"); + aRedefinition.setColorVariable(ColorVariable(0, -3000)); + aSet.add(aRedefinition); + } return aSet; } @@ -298,6 +376,12 @@ std::vector initColorSets() aColorSet.maColors[0] = Color(0x00, 0x00, 0xa4); aColorSets.push_back(aColorSet); } + { + ColorSet aColorSet; + aColorSet.maName = "Sky"; + aColorSet.maColors[0] = Color(0x72, 0x9f, 0xcf); + aColorSets.push_back(aColorSet); + } return aColorSets; } -- cgit v1.2.3