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:
committed by
Tomaž Vajngerl
parent
0b25b7a8b2
commit
723ad50fff
@@ -196,6 +196,12 @@ public:
|
|||||||
class VCL_DLLPUBLIC WidgetDefinitionPart
|
class VCL_DLLPUBLIC WidgetDefinitionPart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
sal_Int32 mnWidth;
|
||||||
|
sal_Int32 mnHeight;
|
||||||
|
sal_Int32 mnMarginWidth;
|
||||||
|
sal_Int32 mnMarginHeight;
|
||||||
|
OString msOrientation;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<WidgetDefinitionState>>
|
std::vector<std::shared_ptr<WidgetDefinitionState>>
|
||||||
getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue);
|
getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue);
|
||||||
|
|
||||||
|
@@ -113,7 +113,6 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr
|
|||||||
return false;
|
return false;
|
||||||
case ControlType::WindowBackground:
|
case ControlType::WindowBackground:
|
||||||
case ControlType::Frame:
|
case ControlType::Frame:
|
||||||
return true;
|
|
||||||
case ControlType::ListNode:
|
case ControlType::ListNode:
|
||||||
case ControlType::ListNet:
|
case ControlType::ListNet:
|
||||||
case ControlType::ListHeader:
|
case ControlType::ListHeader:
|
||||||
@@ -571,40 +570,52 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
|
|||||||
{
|
{
|
||||||
case ControlType::Spinbox:
|
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";
|
OString sOrientation = "decrease-edit-increase";
|
||||||
|
|
||||||
if (sOrientation == "decrease-edit-increase")
|
if (sOrientation == "decrease-edit-increase")
|
||||||
{
|
{
|
||||||
if (ePart == ControlPart::ButtonUp)
|
if (ePart == ControlPart::ButtonUp)
|
||||||
{
|
{
|
||||||
rNativeContentRegion
|
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
|
||||||
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
|
- aButtonSizeUp.Width(),
|
||||||
- aButtonSize.Width(),
|
aLocation.Y());
|
||||||
aLocation.Y()),
|
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
|
||||||
aButtonSize);
|
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::ButtonDown)
|
else if (ePart == ControlPart::ButtonDown)
|
||||||
{
|
{
|
||||||
rNativeContentRegion = tools::Rectangle(aLocation, aButtonSize);
|
rNativeContentRegion = tools::Rectangle(aLocation, aButtonSizeDown);
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::SubEdit)
|
else if (ePart == ControlPart::SubEdit)
|
||||||
{
|
{
|
||||||
Point aPoint(aLocation.X() + aButtonSize.getWidth(), aLocation.Y());
|
Point aPoint(aLocation.X() + aButtonSizeDown.Width(), aLocation.Y());
|
||||||
Size aSize(rBoundingControlRegion.GetWidth() - (2 * aButtonSize.Width()),
|
Size aSize(rBoundingControlRegion.GetWidth()
|
||||||
aButtonSize.Height());
|
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
|
||||||
|
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
|
||||||
rNativeContentRegion = tools::Rectangle(aPoint, aSize);
|
rNativeContentRegion = tools::Rectangle(aPoint, aSize);
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::Entire)
|
else if (ePart == ControlPart::Entire)
|
||||||
{
|
{
|
||||||
rNativeContentRegion = tools::Rectangle(
|
Size aSize(rBoundingControlRegion.GetWidth(),
|
||||||
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
|
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
|
||||||
|
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -613,37 +624,36 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
|
|||||||
{
|
{
|
||||||
if (ePart == ControlPart::ButtonUp)
|
if (ePart == ControlPart::ButtonUp)
|
||||||
{
|
{
|
||||||
rNativeContentRegion
|
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
|
||||||
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
|
- aButtonSizeUp.Width(),
|
||||||
- aButtonSize.Width(),
|
aLocation.Y());
|
||||||
aLocation.Y()),
|
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
|
||||||
aButtonSize);
|
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::ButtonDown)
|
else if (ePart == ControlPart::ButtonDown)
|
||||||
{
|
{
|
||||||
rNativeContentRegion
|
Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
|
||||||
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
|
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
|
||||||
- (2 * aButtonSize.Width()),
|
aLocation.Y());
|
||||||
aLocation.Y()),
|
rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeDown);
|
||||||
aButtonSize);
|
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::SubEdit)
|
else if (ePart == ControlPart::SubEdit)
|
||||||
{
|
{
|
||||||
rNativeContentRegion
|
Size aSize(rBoundingControlRegion.GetWidth()
|
||||||
= tools::Rectangle(aLocation, Size(rBoundingControlRegion.GetWidth()
|
- (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
|
||||||
- (2 * aButtonSize.Width()),
|
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
|
||||||
aButtonSize.Height()));
|
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (ePart == ControlPart::Entire)
|
else if (ePart == ControlPart::Entire)
|
||||||
{
|
{
|
||||||
rNativeContentRegion = tools::Rectangle(
|
Size aSize(rBoundingControlRegion.GetWidth(),
|
||||||
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
|
std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
|
||||||
|
rNativeContentRegion = tools::Rectangle(aLocation, aSize);
|
||||||
rNativeBoundingRegion = rNativeContentRegion;
|
rNativeBoundingRegion = rNativeContentRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -651,16 +661,35 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ControlType::Checkbox:
|
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;
|
return true;
|
||||||
|
}
|
||||||
case ControlType::Radiobutton:
|
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;
|
return true;
|
||||||
|
}
|
||||||
case ControlType::TabItem:
|
case ControlType::TabItem:
|
||||||
{
|
{
|
||||||
rNativeBoundingRegion = tools::Rectangle(rBoundingControlRegion.TopLeft(),
|
auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire);
|
||||||
Size(rBoundingControlRegion.GetWidth() + 20,
|
if (!pPart)
|
||||||
rBoundingControlRegion.GetHeight() + 6));
|
return false;
|
||||||
|
|
||||||
|
rNativeBoundingRegion = tools::Rectangle(
|
||||||
|
rBoundingControlRegion.TopLeft(),
|
||||||
|
Size(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth,
|
||||||
|
rBoundingControlRegion.GetHeight() + pPart->mnMarginHeight));
|
||||||
rNativeContentRegion = rNativeBoundingRegion;
|
rNativeContentRegion = rNativeBoundingRegion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -298,7 +298,37 @@ void WidgetDefinitionReader::readDefinition(tools::XmlWalker& rWalker,
|
|||||||
{
|
{
|
||||||
OString sPart = rWalker.attribute("value");
|
OString sPart = rWalker.attribute("value");
|
||||||
ControlPart ePart = xmlStringToControlPart(sPart);
|
ControlPart ePart = xmlStringToControlPart(sPart);
|
||||||
|
|
||||||
std::shared_ptr<WidgetDefinitionPart> pPart = std::make_shared<WidgetDefinitionPart>();
|
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);
|
rWidgetDefinition.maDefinitions.emplace(ControlTypeAndPart(eType, ePart), pPart);
|
||||||
readPart(rWalker, pPart);
|
readPart(rWalker, pPart);
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@
|
|||||||
</pushbutton>
|
</pushbutton>
|
||||||
|
|
||||||
<radiobutton>
|
<radiobutton>
|
||||||
<part value="Entire">
|
<part value="Entire" width="32" height="32">
|
||||||
<state enabled="true" pressed="false" button-value="true">
|
<state enabled="true" pressed="false" button-value="true">
|
||||||
<image source="tick-on.svgx" />
|
<image source="tick-on.svgx" />
|
||||||
</state>
|
</state>
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
</radiobutton>
|
</radiobutton>
|
||||||
|
|
||||||
<checkbox>
|
<checkbox>
|
||||||
<part value="Entire">
|
<part value="Entire" width="44" height="26">
|
||||||
<state enabled="true" pressed="false" button-value="true">
|
<state enabled="true" pressed="false" button-value="true">
|
||||||
<image source="switch-on.svgx" />
|
<image source="switch-on.svgx" />
|
||||||
</state>
|
</state>
|
||||||
@@ -191,12 +191,12 @@
|
|||||||
<external source="spinbox-entire.svgx" />
|
<external source="spinbox-entire.svgx" />
|
||||||
</state>
|
</state>
|
||||||
</part>
|
</part>
|
||||||
<part value="ButtonDown">
|
<part value="ButtonDown" width="44" height="26">
|
||||||
<state>
|
<state>
|
||||||
<external source="spinbox-left.svgx" />
|
<external source="spinbox-left.svgx" />
|
||||||
</state>
|
</state>
|
||||||
</part>
|
</part>
|
||||||
<part value="ButtonUp">
|
<part value="ButtonUp" width="44" height="26">
|
||||||
<state>
|
<state>
|
||||||
<external source="spinbox-right.svgx" />
|
<external source="spinbox-right.svgx" />
|
||||||
</state>
|
</state>
|
||||||
@@ -286,7 +286,7 @@
|
|||||||
</progress>
|
</progress>
|
||||||
|
|
||||||
<tabitem>
|
<tabitem>
|
||||||
<part value="Entire">
|
<part value="Entire" margin-width="20" margin-height="6">
|
||||||
<state selected="false" extra="first">
|
<state selected="false" extra="first">
|
||||||
<external source="tabitem-first.svgx" />
|
<external source="tabitem-first.svgx" />
|
||||||
</state>
|
</state>
|
||||||
|
Reference in New Issue
Block a user