Support first, last tab item for the widget definition
Add "extra" parameter for the widget definition states with the default set to "any". For tab item, the extra parameter can be "first", "last", "middle" and "first_last" (only one). This is needed to draw first and last tab item differently. Change-Id: I46b6897b485b4df94ab6fe9521925c3715eaa24e Reviewed-on: https://gerrit.libreoffice.org/68817 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
7200b461e3
commit
fd57cdfc77
@@ -172,10 +172,12 @@ public:
|
||||
OString msDefault;
|
||||
OString msSelected;
|
||||
OString msButtonValue;
|
||||
OString msExtra;
|
||||
|
||||
WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
|
||||
OString const& sRollover, OString const& sDefault,
|
||||
OString const& sSelected, OString const& sButtonValue);
|
||||
OString const& sSelected, OString const& sButtonValue,
|
||||
OString const& sExtra);
|
||||
|
||||
std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
|
||||
|
||||
@@ -194,8 +196,8 @@ public:
|
||||
class VCL_DLLPUBLIC WidgetDefinitionPart
|
||||
{
|
||||
public:
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
|
||||
ImplControlValue const& rValue);
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>>
|
||||
getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue);
|
||||
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
|
||||
};
|
||||
|
@@ -56,11 +56,11 @@ void WidgetDefinitionReaderTest::testRead()
|
||||
|
||||
// Pushbutton
|
||||
{
|
||||
ControlState eState
|
||||
= ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER;
|
||||
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
|
||||
= aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire)
|
||||
->getStates(ControlState::DEFAULT | ControlState::ENABLED
|
||||
| ControlState::ROLLOVER,
|
||||
ImplControlValue());
|
||||
->getStates(ControlType::Pushbutton, eState, ImplControlValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
|
||||
|
||||
@@ -74,7 +74,8 @@ void WidgetDefinitionReaderTest::testRead()
|
||||
{
|
||||
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
|
||||
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
|
||||
->getStates(ControlState::NONE, ImplControlValue(ButtonValue::On));
|
||||
->getStates(ControlType::Radiobutton, ControlState::NONE,
|
||||
ImplControlValue(ButtonValue::On));
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
|
||||
}
|
||||
@@ -82,7 +83,8 @@ void WidgetDefinitionReaderTest::testRead()
|
||||
{
|
||||
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
|
||||
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
|
||||
->getStates(ControlState::NONE, ImplControlValue(ButtonValue::Off));
|
||||
->getStates(ControlType::Radiobutton, ControlState::NONE,
|
||||
ImplControlValue(ButtonValue::Off));
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size());
|
||||
}
|
||||
|
@@ -368,7 +368,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart
|
||||
auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ePart);
|
||||
if (pPart)
|
||||
{
|
||||
auto const& aStates = pPart->getStates(eState, rValue);
|
||||
auto const& aStates = pPart->getStates(eType, eState, rValue);
|
||||
if (!aStates.empty())
|
||||
{
|
||||
// use last defined state
|
||||
|
@@ -26,7 +26,8 @@ std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getDefinition(ControlTyp
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>>
|
||||
WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rValue)
|
||||
WidgetDefinitionPart::getStates(ControlType eType, ControlState eState,
|
||||
ImplControlValue const& rValue)
|
||||
{
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
|
||||
|
||||
@@ -64,7 +65,30 @@ WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rVa
|
||||
if (state->msButtonValue != "any"
|
||||
&& !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On)
|
||||
|| (state->msButtonValue == "false" && eButtonValue != ButtonValue::On)))
|
||||
{
|
||||
bAdd = false;
|
||||
}
|
||||
|
||||
if (eType == ControlType::TabItem)
|
||||
{
|
||||
OString sExtra;
|
||||
|
||||
auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
|
||||
|
||||
if (rTabItemValue.isFirst() && rTabItemValue.isLast())
|
||||
sExtra = "first_last";
|
||||
else if (rTabItemValue.isFirst())
|
||||
sExtra = "first";
|
||||
else if (rTabItemValue.isLast())
|
||||
sExtra = "last";
|
||||
else
|
||||
sExtra = "middle";
|
||||
|
||||
if (state->msExtra != "any" && state->msExtra != sExtra)
|
||||
{
|
||||
bAdd = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAdd)
|
||||
aStatesToAdd.push_back(state);
|
||||
@@ -76,7 +100,7 @@ WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rVa
|
||||
WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused,
|
||||
OString const& sPressed, OString const& sRollover,
|
||||
OString const& sDefault, OString const& sSelected,
|
||||
OString const& sButtonValue)
|
||||
OString const& sButtonValue, OString const& sExtra)
|
||||
: msEnabled(sEnabled)
|
||||
, msFocused(sFocused)
|
||||
, msPressed(sPressed)
|
||||
@@ -84,6 +108,7 @@ WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString co
|
||||
, msDefault(sDefault)
|
||||
, msSelected(sSelected)
|
||||
, msButtonValue(sButtonValue)
|
||||
, msExtra(sExtra)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -315,9 +315,13 @@ void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
|
||||
OString sDefault = rWalker.attribute("default");
|
||||
OString sSelected = rWalker.attribute("selected");
|
||||
OString sButtonValue = rWalker.attribute("button-value");
|
||||
OString sExtra = rWalker.attribute("extra");
|
||||
if (sExtra.isEmpty())
|
||||
sExtra = "any";
|
||||
|
||||
std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(
|
||||
sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue);
|
||||
sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue, sExtra);
|
||||
|
||||
rpPart->maStates.push_back(pState);
|
||||
readDrawingDefinition(rWalker, pState);
|
||||
}
|
||||
|
Reference in New Issue
Block a user