Add width, height and margin parameters for widget part def.

For some control parts we need to provide the size or redefine
the size. Previously this was hardcoded, but this adds new
attriburtes for widget part definition:
- width, height: defines size for buttons in spinbox, the size of
  the checkbox or radiobutton
- margin-width, margin-height: increases the size (margin) of
  tab items by the specified amount

Change-Id: Ieea69b92ad21adc4f4954e7555f4d59348f5dea8
Reviewed-on: https://gerrit.libreoffice.org/68829
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2019-03-04 10:05:36 +01:00
committed by Tomaž Vajngerl
parent 0b25b7a8b2
commit 723ad50fff
4 changed files with 104 additions and 39 deletions

View File

@@ -196,6 +196,12 @@ public:
class VCL_DLLPUBLIC WidgetDefinitionPart
{
public:
sal_Int32 mnWidth;
sal_Int32 mnHeight;
sal_Int32 mnMarginWidth;
sal_Int32 mnMarginHeight;
OString msOrientation;
std::vector<std::shared_ptr<WidgetDefinitionState>>
getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue);

View File

@@ -113,7 +113,6 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr
return false;
case ControlType::WindowBackground:
case ControlType::Frame:
return true;
case ControlType::ListNode:
case ControlType::ListNet:
case ControlType::ListHeader:
@@ -571,40 +570,52 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
{
case ControlType::Spinbox:
{
Size aButtonSize(44, 26);
auto const& pButtonUpPart
= m_aWidgetDefinition.getDefinition(eType, ControlPart::ButtonUp);
if (!pButtonUpPart)
return false;
Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight);
auto const& pButtonDownPart
= m_aWidgetDefinition.getDefinition(eType, ControlPart::ButtonDown);
if (!pButtonDownPart)
return false;
Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight);
OString sOrientation = "decrease-edit-increase";
if (sOrientation == "decrease-edit-increase")
{
if (ePart == ControlPart::ButtonUp)
{
rNativeContentRegion
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- aButtonSize.Width(),
aLocation.Y()),
aButtonSize);
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
- aButtonSizeUp.Width(),
aLocation.Y());
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::ButtonDown)
{
rNativeContentRegion = tools::Rectangle(aLocation, aButtonSize);
rNativeContentRegion = tools::Rectangle(aLocation, aButtonSizeDown);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::SubEdit)
{
Point aPoint(aLocation.X() + aButtonSize.getWidth(), aLocation.Y());
Size aSize(rBoundingControlRegion.GetWidth() - (2 * aButtonSize.Width()),
aButtonSize.Height());
Point aPoint(aLocation.X() + aButtonSizeDown.Width(), aLocation.Y());
Size aSize(rBoundingControlRegion.GetWidth()
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
rNativeContentRegion = tools::Rectangle(aPoint, aSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::Entire)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
Size aSize(rBoundingControlRegion.GetWidth(),
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
@@ -613,37 +624,36 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
{
if (ePart == ControlPart::ButtonUp)
{
rNativeContentRegion
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- aButtonSize.Width(),
aLocation.Y()),
aButtonSize);
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
- aButtonSizeUp.Width(),
aLocation.Y());
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::ButtonDown)
{
rNativeContentRegion
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- (2 * aButtonSize.Width()),
aLocation.Y()),
aButtonSize);
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
aLocation.Y());
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeDown);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::SubEdit)
{
rNativeContentRegion
= tools::Rectangle(aLocation, Size(rBoundingControlRegion.GetWidth()
- (2 * aButtonSize.Width()),
aButtonSize.Height()));
Size aSize(rBoundingControlRegion.GetWidth()
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::Entire)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
Size aSize(rBoundingControlRegion.GetWidth(),
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
@@ -651,16 +661,35 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
}
break;
case ControlType::Checkbox:
rNativeContentRegion = tools::Rectangle(Point(), Size(44, 26));
{
auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire);
if (!pPart)
return false;
Size aSize(pPart->mnWidth, pPart->mnHeight);
rNativeContentRegion = tools::Rectangle(Point(), aSize);
return true;
}
case ControlType::Radiobutton:
rNativeContentRegion = tools::Rectangle(Point(), Size(32, 32));
{
auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire);
if (!pPart)
return false;
Size aSize(pPart->mnWidth, pPart->mnHeight);
rNativeContentRegion = tools::Rectangle(Point(), aSize);
return true;
}
case ControlType::TabItem:
{
rNativeBoundingRegion = tools::Rectangle(rBoundingControlRegion.TopLeft(),
Size(rBoundingControlRegion.GetWidth() + 20,
rBoundingControlRegion.GetHeight() + 6));
auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire);
if (!pPart)
return false;
rNativeBoundingRegion = tools::Rectangle(
rBoundingControlRegion.TopLeft(),
Size(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth,
rBoundingControlRegion.GetHeight() + pPart->mnMarginHeight));
rNativeContentRegion = rNativeBoundingRegion;
return true;
}

View File

@@ -298,7 +298,37 @@ void WidgetDefinitionReader::readDefinition(tools::XmlWalker& rWalker,
{
OString sPart = rWalker.attribute("value");
ControlPart ePart = xmlStringToControlPart(sPart);
std::shared_ptr<WidgetDefinitionPart> pPart = std::make_shared<WidgetDefinitionPart>();
OString sWidth = rWalker.attribute("width");
if (!sWidth.isEmpty())
{
sal_Int32 nWidth = sWidth.isEmpty() ? 0 : sWidth.toInt32();
pPart->mnWidth = nWidth;
}
OString sHeight = rWalker.attribute("height");
if (!sHeight.isEmpty())
{
sal_Int32 nHeight = sHeight.isEmpty() ? 0 : sHeight.toInt32();
pPart->mnHeight = nHeight;
}
OString sMarginHeight = rWalker.attribute("margin-height");
if (!sMarginHeight.isEmpty())
{
sal_Int32 nMarginHeight = sMarginHeight.isEmpty() ? 0 : sMarginHeight.toInt32();
pPart->mnMarginHeight = nMarginHeight;
}
OString sMarginWidth = rWalker.attribute("margin-width");
if (!sMarginWidth.isEmpty())
{
sal_Int32 nMarginWidth = sMarginWidth.isEmpty() ? 0 : sMarginWidth.toInt32();
pPart->mnMarginWidth = nMarginWidth;
}
rWidgetDefinition.maDefinitions.emplace(ControlTypeAndPart(eType, ePart), pPart);
readPart(rWalker, pPart);
}

View File

@@ -77,7 +77,7 @@
</pushbutton>
<radiobutton>
<part value="Entire">
<part value="Entire" width="32" height="32">
<state enabled="true" pressed="false" button-value="true">
<image source="tick-on.svgx" />
</state>
@@ -100,7 +100,7 @@
</radiobutton>
<checkbox>
<part value="Entire">
<part value="Entire" width="44" height="26">
<state enabled="true" pressed="false" button-value="true">
<image source="switch-on.svgx" />
</state>
@@ -191,12 +191,12 @@
<external source="spinbox-entire.svgx" />
</state>
</part>
<part value="ButtonDown">
<part value="ButtonDown" width="44" height="26">
<state>
<external source="spinbox-left.svgx" />
</state>
</part>
<part value="ButtonUp">
<part value="ButtonUp" width="44" height="26">
<state>
<external source="spinbox-right.svgx" />
</state>
@@ -286,7 +286,7 @@
</progress>
<tabitem>
<part value="Entire">
<part value="Entire" margin-width="20" margin-height="6">
<state selected="false" extra="first">
<external source="tabitem-first.svgx" />
</state>