[Libreoffice-commits] core.git: vcl/inc vcl/source vcl/uiconfig
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 4 11:31:14 UTC 2019
vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 6 ++++--
vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 16 ++++++++++------
vcl/source/gdi/WidgetDefinitionReader.cxx | 24 +++++++++++++++++++-----
vcl/uiconfig/theme_definitions/definition.xml | 9 ++++-----
4 files changed, 37 insertions(+), 18 deletions(-)
New commits:
commit b07a71e09a129e37131574c7247be80c5fd112a8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Jan 23 00:58:23 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Mar 4 12:30:50 2019 +0100
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 at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
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>
More information about the Libreoffice-commits
mailing list