diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-01-23 00:58:23 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-04 12:30:50 +0100 |
commit | b07a71e09a129e37131574c7247be80c5fd112a8 (patch) | |
tree | 7537ebcfc9b251f306f13dffebfbdf7410f5172a /vcl | |
parent | 2e77a44ea1ea810b598907bffeba0e7ac3a93161 (diff) |
Add support for button-value to correctly draw the radiobutton
Change-Id: I392289f0ab284aec2ed0fb039a03fb93bf0b4aad
Reviewed-on: https://gerrit.libreoffice.org/68654
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 16 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 24 | ||||
-rw-r--r-- | vcl/uiconfig/theme_definitions/definition.xml | 9 |
4 files changed, 37 insertions, 18 deletions
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx index e88ebac924be..01deaee91eb6 100644 --- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx +++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx @@ -78,10 +78,11 @@ public: OString msRollover; OString msDefault; OString msSelected; + OString msButtonValue; WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed, OString const& sRollover, OString const& sDefault, - OString const& sSelected); + OString const& sSelected, OString const& sButtonValue); std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands; @@ -94,7 +95,8 @@ public: class VCL_DLLPUBLIC WidgetDefinition { public: - std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState); + std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState, + ImplControlValue const& rValue); std::vector<std::shared_ptr<WidgetDefinitionState>> maStates; }; diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 55f556349a78..2ada75fa7477 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -141,7 +141,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ePart, const tools::Rectangle& rControlRegion, ControlState eState, - const ImplControlValue& /*rValue*/, + const ImplControlValue& rValue, const OUString& /*aCaptions*/) { bool bOldAA = m_rGraphics.getAntiAliasB2DDraw(); @@ -166,11 +166,15 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart = m_WidgetDefinitionReader.getPushButtonDefinition(ePart); if (pDefinition) { - std::shared_ptr<WidgetDefinitionState> pState - = pDefinition->getStates(eState).back(); + auto aStates = pDefinition->getStates(eState, rValue); + if (!aStates.empty()) { - munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); - bOK = true; + std::shared_ptr<WidgetDefinitionState> pState = aStates.back(); + { + munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, + nHeight); + bOK = true; + } } } } @@ -182,7 +186,7 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart if (pDefinition) { std::shared_ptr<WidgetDefinitionState> pState - = pDefinition->getStates(eState).back(); + = pDefinition->getStates(eState, rValue).back(); { munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); bOK = true; diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index 85276e3a35e8..edab7b75ae4a 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -140,10 +140,12 @@ void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker) OString sRollover = rWalker.attribute("rollover"); OString sDefault = rWalker.attribute("default"); OString sSelected = rWalker.attribute("selected"); + OString sButtonValue = rWalker.attribute("button-value"); std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(sEnabled, sFocused, sPressed, - sRollover, sDefault, sSelected); + sRollover, sDefault, sSelected, + sButtonValue); pPart->maStates.push_back(pState); readDrawingDefinition(rWalker, pState); } @@ -177,10 +179,12 @@ void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker) OString sRollover = rWalker.attribute("rollover"); OString sDefault = rWalker.attribute("default"); OString sSelected = rWalker.attribute("selected"); - + OString sButtonValue = rWalker.attribute("button-value"); + sButtonValue = sButtonValue.isEmpty() ? "any" : sButtonValue; std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(sEnabled, sFocused, sPressed, - sRollover, sDefault, sSelected); + sRollover, sDefault, sSelected, + sButtonValue); pPart->maStates.push_back(pState); readDrawingDefinition(rWalker, pState); } @@ -396,7 +400,8 @@ WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart) return std::shared_ptr<WidgetDefinition>(); } -std::vector<std::shared_ptr<WidgetDefinitionState>> WidgetDefinition::getStates(ControlState eState) +std::vector<std::shared_ptr<WidgetDefinitionState>> +WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue) { std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd; @@ -429,6 +434,13 @@ std::vector<std::shared_ptr<WidgetDefinitionState>> WidgetDefinition::getStates( || (state->msSelected == "false" && !(eState & ControlState::SELECTED)))) bAdd = false; + ButtonValue eButtonValue = rValue.getTristateVal(); + + if (state->msButtonValue != "any" + && !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On) + || (state->msButtonValue == "false" && eButtonValue != ButtonValue::On))) + bAdd = false; + if (bAdd) aStatesToAdd.push_back(state); } @@ -438,13 +450,15 @@ std::vector<std::shared_ptr<WidgetDefinitionState>> WidgetDefinition::getStates( WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed, OString const& sRollover, - OString const& sDefault, OString const& sSelected) + OString const& sDefault, OString const& sSelected, + OString const& sButtonValue) : msEnabled(sEnabled) , msFocused(sFocused) , msPressed(sPressed) , msRollover(sRollover) , msDefault(sDefault) , msSelected(sSelected) + , msButtonValue(sButtonValue) { } diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml index 9ee8838fa705..ac4718d10953 100644 --- a/vcl/uiconfig/theme_definitions/definition.xml +++ b/vcl/uiconfig/theme_definitions/definition.xml @@ -56,11 +56,11 @@ <pushbutton> <part value="Entire"> - <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any"> <rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="5" ry="5" margin="0"/> </state> - <state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any"> + <state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any" button-value="any"> <rect stroke="#007AFF" fill="#007AFF" stroke-width="1" rx="5" ry="5" margin="0"/> </state> </part> @@ -68,11 +68,10 @@ <radiobutton> <part value="Entire"> - <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false"> <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/> - <circ stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/> </state> - <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true"> <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/> <circ stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/> </state> |