Kaydet (Commit) 8ff3e9a4 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

widget theme: draw listheader button and arrow

Also adds support for signaling if arrow points up or down, which
is signaled through extra attribute.

Change-Id: I5a87cdb31e18150495df521bf925c7b983e2313a
Reviewed-on: https://gerrit.libreoffice.org/69013
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 3ae8b930
...@@ -45,6 +45,8 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th ...@@ -45,6 +45,8 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th
scrollbar-vertical.svgx \ scrollbar-vertical.svgx \
combobox.svgx \ combobox.svgx \
combobox-disabled.svgx \ combobox-disabled.svgx \
arrow-up.svgx \
arrow-down.svgx \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -202,8 +202,10 @@ public: ...@@ -202,8 +202,10 @@ public:
sal_Int32 mnMarginHeight; sal_Int32 mnMarginHeight;
OString msOrientation; OString msOrientation;
std::vector<std::shared_ptr<WidgetDefinitionState>> std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlType eType,
getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue); ControlPart ePart,
ControlState eState,
ImplControlValue const& rValue);
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates; std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
}; };
......
...@@ -57,7 +57,8 @@ void WidgetDefinitionReaderTest::testRead() ...@@ -57,7 +57,8 @@ void WidgetDefinitionReaderTest::testRead()
= ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER; = ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER;
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire) = aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire)
->getStates(ControlType::Pushbutton, eState, ImplControlValue()); ->getStates(ControlType::Pushbutton, ControlPart::Entire, eState,
ImplControlValue());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size()); CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
...@@ -71,7 +72,7 @@ void WidgetDefinitionReaderTest::testRead() ...@@ -71,7 +72,7 @@ void WidgetDefinitionReaderTest::testRead()
{ {
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire) = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
->getStates(ControlType::Radiobutton, ControlState::NONE, ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
ImplControlValue(ButtonValue::On)); ImplControlValue(ButtonValue::On));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size()); CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
...@@ -80,7 +81,7 @@ void WidgetDefinitionReaderTest::testRead() ...@@ -80,7 +81,7 @@ void WidgetDefinitionReaderTest::testRead()
{ {
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire) = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
->getStates(ControlType::Radiobutton, ControlState::NONE, ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
ImplControlValue(ButtonValue::Off)); ImplControlValue(ButtonValue::Off));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size());
......
...@@ -402,7 +402,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart ...@@ -402,7 +402,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart
auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart); auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart);
if (pPart) if (pPart)
{ {
auto const& aStates = pPart->getStates(eType, eState, rValue); auto const& aStates = pPart->getStates(eType, ePart, eState, rValue);
if (!aStates.empty()) if (!aStates.empty())
{ {
// use last defined state // use last defined state
......
...@@ -26,7 +26,7 @@ std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getDefinition(ControlTyp ...@@ -26,7 +26,7 @@ std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getDefinition(ControlTyp
} }
std::vector<std::shared_ptr<WidgetDefinitionState>> std::vector<std::shared_ptr<WidgetDefinitionState>>
WidgetDefinitionPart::getStates(ControlType eType, ControlState eState, WidgetDefinitionPart::getStates(ControlType eType, ControlPart ePart, ControlState eState,
ImplControlValue const& rValue) ImplControlValue const& rValue)
{ {
std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd; std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
...@@ -69,26 +69,43 @@ WidgetDefinitionPart::getStates(ControlType eType, ControlState eState, ...@@ -69,26 +69,43 @@ WidgetDefinitionPart::getStates(ControlType eType, ControlState eState,
bAdd = false; bAdd = false;
} }
if (eType == ControlType::TabItem) OString sExtra = "any";
{
OString sExtra;
auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
if (rTabItemValue.isLeftAligned() && rTabItemValue.isRightAligned()
&& rTabItemValue.isFirst() && rTabItemValue.isLast())
sExtra = "first_last";
else if (rTabItemValue.isLeftAligned() || rTabItemValue.isFirst())
sExtra = "first";
else if (rTabItemValue.isRightAligned() || rTabItemValue.isLast())
sExtra = "last";
else
sExtra = "middle";
if (state->msExtra != "any" && state->msExtra != sExtra) switch (eType)
{
case ControlType::TabItem:
{
auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
if (rTabItemValue.isLeftAligned() && rTabItemValue.isRightAligned()
&& rTabItemValue.isFirst() && rTabItemValue.isLast())
sExtra = "first_last";
else if (rTabItemValue.isLeftAligned() || rTabItemValue.isFirst())
sExtra = "first";
else if (rTabItemValue.isRightAligned() || rTabItemValue.isLast())
sExtra = "last";
else
sExtra = "middle";
}
break;
case ControlType::ListHeader:
{ {
bAdd = false; if (ePart == ControlPart::Arrow)
{
if (rValue.getNumericVal() == 1)
sExtra = "down";
else
sExtra = "up";
}
} }
break;
default:
break;
}
if (state->msExtra != "any" && state->msExtra != sExtra)
{
bAdd = false;
} }
if (bAdd) if (bAdd)
......
<svg version="1.1" viewBox="0 0 11 20" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(245.46 49.566)">
<path d="m-242.75-44.074h5.5903l-2.7951 8z" fill="#007aff" stroke="#007aff"/>
</g>
</svg>
<svg version="1.1" viewBox="0 0 11 20" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(245.46 49.566)">
<path d="m-242.75-35.066h5.5903l-2.7951-7.9855z" fill="#007aff" stroke="#007aff"/>
</g>
</svg>
...@@ -432,6 +432,19 @@ ...@@ -432,6 +432,19 @@
</listnet> </listnet>
<listheader> <listheader>
<part value="Button">
<state>
<rect stroke="#8e8e93" fill="#f4f5f5" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="Arrow">
<state extra="up">
<image source="arrow-up.svgx"/>
</state>
<state extra="down">
<image source="arrow-down.svgx"/>
</state>
</part>
</listheader> </listheader>
</widgets> </widgets>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment