diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-11-23 22:09:50 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-05-17 10:47:31 +0200 |
commit | 6527b24f173894e1fca93d8bd5a11adf5cf7d9be (patch) | |
tree | b6cdeca31cc62e1ce0c965d66a76e1bf8b671f4a | |
parent | 867ada12e77c4ae42c202f064d84b35c19b64f8d (diff) |
widget theme: add additional settings to the theme definition
Change-Id: Ib50ebadf73979068d3595f09de113aa8745eccb9
Reviewed-on: https://gerrit.libreoffice.org/83591
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | vcl/inc/widgetdraw/WidgetDefinition.hxx | 7 | ||||
-rw-r--r-- | vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx | 9 | ||||
-rw-r--r-- | vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml | 7 | ||||
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 44 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 7 |
5 files changed, 65 insertions, 9 deletions
diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx index 50a853a6c1a6..a1406e1c743f 100644 --- a/vcl/inc/widgetdraw/WidgetDefinition.hxx +++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx @@ -204,7 +204,14 @@ public: class VCL_DLLPUBLIC WidgetDefinitionSettings { public: + OString msNoActiveTabTextRaise; OString msCenteredTabs; + OString msListBoxEntryMargin; + OString msDefaultFontSize; + OString msTitleHeight; + OString msFloatTitleHeight; + OString msListBoxPreviewDefaultLogicWidth; + OString msListBoxPreviewDefaultLogicHeight; }; class VCL_DLLPUBLIC WidgetDefinitionStyle diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx index cd7945fba82c..d5d0167b70e7 100644 --- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx +++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx @@ -56,7 +56,16 @@ void WidgetDefinitionReaderTest::testReadSettings() vcl::WidgetDefinition aDefinition; vcl::WidgetDefinitionReader aReader(getFullUrl("definitionSettings3.xml"), getFullUrl("")); CPPUNIT_ASSERT(aReader.read(aDefinition)); + CPPUNIT_ASSERT_EQUAL(OString("true"), aDefinition.mpSettings->msNoActiveTabTextRaise); CPPUNIT_ASSERT_EQUAL(OString("false"), aDefinition.mpSettings->msCenteredTabs); + CPPUNIT_ASSERT_EQUAL(OString("0"), aDefinition.mpSettings->msListBoxEntryMargin); + CPPUNIT_ASSERT_EQUAL(OString("10"), aDefinition.mpSettings->msDefaultFontSize); + CPPUNIT_ASSERT_EQUAL(OString("16"), aDefinition.mpSettings->msTitleHeight); + CPPUNIT_ASSERT_EQUAL(OString("12"), aDefinition.mpSettings->msFloatTitleHeight); + CPPUNIT_ASSERT_EQUAL(OString("15"), + aDefinition.mpSettings->msListBoxPreviewDefaultLogicWidth); + CPPUNIT_ASSERT_EQUAL(OString("7"), + aDefinition.mpSettings->msListBoxPreviewDefaultLogicHeight); } } diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml index 20541b2a219e..9ad88dd54569 100644 --- a/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml +++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml @@ -1,6 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <widgets> <settings> + <noActiveTabTextRaise value="true"/> <centeredTabs value="false"/> + <listBoxEntryMargin value="0"/> + <defaultFontSize value="10"/> + <titleHeight value="16"/> + <floatTitleHeight value="12"/> + <listBoxPreviewDefaultLogicWidth value="15"/> + <listBoxPreviewDefaultLogicHeight value="7"/> </settings> </widgets> diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 580f3783143b..f24b1970887e 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -30,6 +30,7 @@ #include <comphelper/seqstream.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/lok.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/graphic/SvgTools.hpp> #include <basegfx/DrawCommands.hxx> @@ -85,6 +86,15 @@ std::shared_ptr<WidgetDefinition> const& getWidgetDefinitionForTheme(OUString co return spDefinition; } +int getSettingValueInteger(OString const& rValue, int nDefault) +{ + if (rValue.isEmpty()) + return nDefault; + if (!comphelper::string::isdigitAsciiString(rValue)) + return nDefault; + return rValue.toInt32(); +} + bool getSettingValueBool(OString const& rValue, bool bDefault) { if (rValue.isEmpty()) @@ -109,16 +119,21 @@ FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics) if (m_pWidgetDefinition) { + auto& pSettings = m_pWidgetDefinition->mpSettings; + ImplSVData* pSVData = ImplGetSVData(); pSVData->maNWFData.mbNoFocusRects = true; pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; - pSVData->maNWFData.mbNoActiveTabTextRaise = true; - pSVData->maNWFData.mbCenteredTabs - = getSettingValueBool(m_pWidgetDefinition->mpSettings->msCenteredTabs, true); + pSVData->maNWFData.mbNoActiveTabTextRaise + = getSettingValueBool(pSettings->msNoActiveTabTextRaise, true); + pSVData->maNWFData.mbCenteredTabs = getSettingValueBool(pSettings->msCenteredTabs, true); pSVData->maNWFData.mbProgressNeedsErase = true; pSVData->maNWFData.mnStatusBarLowerRightOffset = 10; pSVData->maNWFData.mbCanDrawWidgetAnySize = true; - pSVData->maNWFData.mnListBoxEntryMargin = 20; + + int nDefaultListboxEntryMargin = pSVData->maNWFData.mnListBoxEntryMargin; + pSVData->maNWFData.mnListBoxEntryMargin + = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin); m_bIsActive = true; } @@ -951,7 +966,7 @@ bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings) { StyleSettings aStyleSet = rSettings.GetStyleSettings(); - auto pDefinitionStyle = m_pWidgetDefinition->mpStyle; + auto& pDefinitionStyle = m_pWidgetDefinition->mpStyle; aStyleSet.SetFaceColor(pDefinitionStyle->maFaceColor); aStyleSet.SetCheckedColor(pDefinitionStyle->maCheckedColor); @@ -1007,7 +1022,10 @@ bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings) aStyleSet.SetToolTextColor(pDefinitionStyle->maToolTextColor); aStyleSet.SetFontColor(pDefinitionStyle->maFontColor); - vcl::Font aFont(FAMILY_SWISS, Size(0, 10)); + auto& pSettings = m_pWidgetDefinition->mpSettings; + + int nFontSize = getSettingValueInteger(pSettings->msDefaultFontSize, 10); + vcl::Font aFont(FAMILY_SWISS, Size(0, nFontSize)); aFont.SetCharSet(osl_getThreadTextEncoding()); aFont.SetWeight(WEIGHT_NORMAL); aFont.SetFamilyName("Liberation Sans"); @@ -1027,9 +1045,17 @@ bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings) aStyleSet.SetFloatTitleFont(aFont); aStyleSet.SetTitleFont(aFont); - aStyleSet.SetTitleHeight(16); - aStyleSet.SetFloatTitleHeight(12); - aStyleSet.SetListBoxPreviewDefaultLogicSize(Size(16, 16)); + int nTitleHeight = getSettingValueInteger(pSettings->msTitleHeight, aStyleSet.GetTitleHeight()); + aStyleSet.SetTitleHeight(nTitleHeight); + + int nFloatTitleHeight + = getSettingValueInteger(pSettings->msFloatTitleHeight, aStyleSet.GetFloatTitleHeight()); + aStyleSet.SetFloatTitleHeight(nFloatTitleHeight); + + int nLogicWidth = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicWidth, + 15); // See vcl/source/app/settings.cxx + int nLogicHeight = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicHeight, 7); + aStyleSet.SetListBoxPreviewDefaultLogicSize(Size(nLogicWidth, nLogicHeight)); rSettings.SetStyleSettings(aStyleSet); diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index b78a269b147b..85ce583142c0 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -425,7 +425,14 @@ bool WidgetDefinitionReader::read(WidgetDefinition& rWidgetDefinition) auto pSettings = std::make_shared<WidgetDefinitionSettings>(); std::unordered_map<OString, OString*> aSettingMap = { + { "noActiveTabTextRaise", &pSettings->msNoActiveTabTextRaise }, { "centeredTabs", &pSettings->msCenteredTabs }, + { "listBoxEntryMargin", &pSettings->msListBoxEntryMargin }, + { "defaultFontSize", &pSettings->msDefaultFontSize }, + { "titleHeight", &pSettings->msTitleHeight }, + { "floatTitleHeight", &pSettings->msFloatTitleHeight }, + { "listBoxPreviewDefaultLogicWidth", &pSettings->msListBoxPreviewDefaultLogicWidth }, + { "listBoxPreviewDefaultLogicHeight", &pSettings->msListBoxPreviewDefaultLogicHeight }, }; rWidgetDefinition.mpSettings = pSettings; |