Kaydet (Commit) 4bcf4c0b authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Update drawing of spinbox from definition

Use SVG to describe the left, right spin button and the entire
spinbox widget.

Change-Id: I082ee08942fa3fa4145fd7bf53fc2cfc9fc06fd2
Reviewed-on: https://gerrit.libreoffice.org/68818
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit cddf072a)
üst 7906eb24
...@@ -25,6 +25,7 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th ...@@ -25,6 +25,7 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th
tick-on-disabled.svgx \ tick-on-disabled.svgx \
spinbox-left.svgx \ spinbox-left.svgx \
spinbox-right.svgx \ spinbox-right.svgx \
spinbox-entire.svgx \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -565,46 +565,88 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( ...@@ -565,46 +565,88 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/, ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/,
tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion) tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
{ {
Point aLocation(rBoundingControlRegion.TopLeft());
switch (eType) switch (eType)
{ {
case ControlType::Spinbox: case ControlType::Spinbox:
{ {
Size aButtonSize(32, 32); Size aButtonSize(44, 26);
Point aLocation(rBoundingControlRegion.TopLeft()); OString sOrientation = "decrease-edit-increase";
if (ePart == ControlPart::ButtonUp) if (sOrientation == "decrease-edit-increase")
{
rNativeContentRegion = tools::Rectangle(
Point(aLocation.X() + rBoundingControlRegion.GetWidth() - aButtonSize.Width(),
aLocation.Y()),
aButtonSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::ButtonDown)
{ {
rNativeContentRegion if (ePart == ControlPart::ButtonUp)
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth() {
- (2 * aButtonSize.Width()), rNativeContentRegion
aLocation.Y()), = tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
aButtonSize); - aButtonSize.Width(),
rNativeBoundingRegion = rNativeContentRegion; aLocation.Y()),
return true; aButtonSize);
} rNativeBoundingRegion = rNativeContentRegion;
else if (ePart == ControlPart::SubEdit) return true;
{ }
rNativeContentRegion = tools::Rectangle( else if (ePart == ControlPart::ButtonDown)
aLocation, Size(rBoundingControlRegion.GetWidth() - (2 * aButtonSize.Width()), {
aButtonSize.Height())); rNativeContentRegion = tools::Rectangle(aLocation, aButtonSize);
rNativeBoundingRegion = rNativeContentRegion; rNativeBoundingRegion = rNativeContentRegion;
return true; return true;
}
else if (ePart == ControlPart::SubEdit)
{
Point aPoint(aLocation.X() + aButtonSize.getWidth(), aLocation.Y());
Size aSize(rBoundingControlRegion.GetWidth() - (2 * aButtonSize.Width()),
aButtonSize.Height());
rNativeContentRegion = tools::Rectangle(aPoint, aSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::Entire)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
} }
else if (ePart == ControlPart::Entire) else
{ {
rNativeContentRegion = tools::Rectangle( if (ePart == ControlPart::ButtonUp)
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height())); {
rNativeBoundingRegion = rNativeContentRegion; rNativeContentRegion
return true; = tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- aButtonSize.Width(),
aLocation.Y()),
aButtonSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::ButtonDown)
{
rNativeContentRegion
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- (2 * aButtonSize.Width()),
aLocation.Y()),
aButtonSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::SubEdit)
{
rNativeContentRegion
= tools::Rectangle(aLocation, Size(rBoundingControlRegion.GetWidth()
- (2 * aButtonSize.Width()),
aButtonSize.Height()));
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::Entire)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
} }
} }
break; break;
......
...@@ -173,22 +173,17 @@ ...@@ -173,22 +173,17 @@
<spinbox> <spinbox>
<part value="Entire"> <part value="Entire">
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="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"/> <external source="spinbox-entire.svgx" />
</state> </state>
</part> </part>
<part value="ButtonDown"> <part value="ButtonDown">
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="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"/> <external source="spinbox-left.svgx" />
<line stroke="#007AFF" stroke-width="2" x1="0.4" y1="0.5" x2="0.6" y2="0.5"/>
<!-- <image source="spinbox-left.svgx" /> -->
</state> </state>
</part> </part>
<part value="ButtonUp"> <part value="ButtonUp">
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="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"/> <external source="spinbox-right.svgx" />
<line stroke="#007AFF" stroke-width="2" x1="0.4" y1="0.5" x2="0.6" y2="0.5"/>
<line stroke="#007AFF" stroke-width="2" x1="0.5" y1="0.4" x2="0.5" y2="0.6"/>
<!-- <image source="spinbox-right.svgx" /> -->
</state> </state>
</part> </part>
</spinbox> </spinbox>
......
<svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg">
<rect x=".5" y=".5" width="43" height="25" rx="2" ry="2" fill="#fff" stroke="#007aff"/>
</svg>
<svg version="1.1" width="44px" height="26px" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg"> <svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg">
<path d="m43 1.001v24h-40c-1.21 5.9e-5 -2-0.9039-2-2v-20c0-1.164 0.8606-2 2-2 13.33 0.03661 40 0 40 0z" fill="#fff" stroke="#007aff" stroke-width="2"/> <path d="m43.5 0.5007v25h-40.95c-1.239 6.1e-5 -2.048-0.9415-2.048-2.083v-20.83c0-1.212 0.8811-2.083 2.048-2.083 13.65 0.03813 40.95 0 40.95 0z" fill="#fff" stroke="#007aff"/>
<rect x="18.5" y="12.25" width="7" height="1.5" color="#bebebe" fill="#007aff"/> <rect x="17" y="12" width="10" height="2" color="#bebebe" fill="#007aff"/>
</svg> </svg>
<svg version="1.1" width="44px" height="26px" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg"> <svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg">
<path d="m40.84 24.99-39.84-0.002673v-23.99l39.84-0.00267c1.195-8.299e-5 2.156 0.9296 2.156 2.084v19.83c0 1.155-0.9616 2.088-2.156 2.084z" fill="#fff" stroke="#007aff" stroke-width="2"/> <path d="m41.29 25.49-40.79-0.002785v-24.99l40.79-0.002781c1.224-8.635e-5 2.208 0.9683 2.208 2.171v20.66c0 1.203-0.9846 2.175-2.208 2.171z" fill="none" stroke="#007aff"/>
<path d="m21.27 9.428v2.857h-2.915v1.429h2.915v2.857h1.458v-2.857h2.915v-1.429h-2.915v-2.857z" color="#bebebe" fill="#007aff"/> <rect x="17" y="12" width="10" height="2" fill="#007aff"/>
<rect x="21" y="8" width="2" height="10" fill="#007aff"/>
</svg> </svg>
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