summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-03-10 21:23:06 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-03-10 22:57:54 +0100
commit100ea3038b033b6b168860e203e893ae8f67b9c1 (patch)
treec9a80ef02a661acf509b1e7018fa19ea837b8452
parent8ff3e9a418a6f154d3ecb2df669fbd70361ae0c0 (diff)
widget theme: draw slider button from svg, left and right track
Change-Id: Iaba4a67845699d795c719d0259e93bb6c72df470 Reviewed-on: https://gerrit.libreoffice.org/69015 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--vcl/Package_theme_definitions.mk1
-rw-r--r--vcl/source/gdi/FileDefinitionWidgetDraw.cxx40
-rw-r--r--vcl/uiconfig/theme_definitions/definition.xml20
-rw-r--r--vcl/uiconfig/theme_definitions/slider-button.svgx3
4 files changed, 52 insertions, 12 deletions
diff --git a/vcl/Package_theme_definitions.mk b/vcl/Package_theme_definitions.mk
index d9cc421fe794..143152d7327a 100644
--- a/vcl/Package_theme_definitions.mk
+++ b/vcl/Package_theme_definitions.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th
combobox-disabled.svgx \
arrow-up.svgx \
arrow-down.svgx \
+ slider-button.svgx \
))
# vim: set noet sw=4 ts=4:
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index b557021f4601..b51d98b2c073 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -529,17 +529,35 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break;
case ControlType::Slider:
{
- bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
+ const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
+ long nThumbX = pSliderValue->maThumbRect.Left();
+ long nThumbY = pSliderValue->maThumbRect.Top();
+ long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1;
+ long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1;
- if (bOK)
+ if (ePart == ControlPart::TrackHorzArea)
+ {
+ long nCenterX = nThumbX + nThumbWidth / 2;
+
+ bOK = resolveDefinition(eType, ControlPart::TrackHorzLeft, eState, rValue, nX, nY,
+ nCenterX - nX, nHeight);
+ if (bOK)
+ bOK = resolveDefinition(eType, ControlPart::TrackHorzRight, eState, rValue,
+ nCenterX, nY, nX + nWidth - nCenterX, nHeight);
+ }
+ else if (ePart == ControlPart::TrackVertArea)
{
- const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
+ long nCenterY = nThumbY + nThumbHeight / 2;
- long nThumbX = pSliderValue->maThumbRect.Left();
- long nThumbY = pSliderValue->maThumbRect.Top();
- long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1;
- long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1;
+ bOK = resolveDefinition(eType, ControlPart::TrackVertUpper, eState, rValue, nX, nY,
+ nWidth, nCenterY - nY);
+ if (bOK)
+ bOK = resolveDefinition(eType, ControlPart::TrackVertLower, eState, rValue, nY,
+ nCenterY, nWidth, nY + nHeight - nCenterY);
+ }
+ if (bOK)
+ {
bOK = resolveDefinition(eType, ControlPart::Button,
eState | pSliderValue->mnThumbState, rValue, nThumbX,
nThumbY, nThumbWidth, nThumbHeight);
@@ -791,6 +809,14 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
}
}
break;
+ case ControlType::Slider:
+ if (ePart == ControlPart::ThumbHorz || ePart == ControlPart::ThumbVert)
+ {
+ rNativeContentRegion = tools::Rectangle(aLocation, Size(28, 28));
+ rNativeBoundingRegion = rNativeContentRegion;
+ return true;
+ }
+ break;
default:
break;
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index bdb1e700715b..23a19de392d5 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -270,17 +270,27 @@
<slider>
<part value="Button">
<state>
- <circ stroke="#AAAAAA" fill="#FFFFFF" stroke-width="1" rx="7" ry="7"/>
+ <image source="slider-button.svgx" />
</state>
</part>
- <part value="TrackHorzArea">
+ <part value="TrackHorzLeft">
+ <state>
+ <line stroke="#007AFF" stroke-width="6" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
+ </state>
+ </part>
+ <part value="TrackHorzRight">
<state>
- <line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
+ <line stroke="#8e8e93" stroke-width="6" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
</state>
</part>
- <part value="TrackVertArea">
+ <part value="TrackVertUpper">
+ <state>
+ <line stroke="#007AFF" stroke-width="6" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
+ </state>
+ </part>
+ <part value="TrackVertLower">
<state>
- <line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
+ <line stroke="#8e8e93" stroke-width="6" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
</state>
</part>
</slider>
diff --git a/vcl/uiconfig/theme_definitions/slider-button.svgx b/vcl/uiconfig/theme_definitions/slider-button.svgx
new file mode 100644
index 000000000000..66772c7521e6
--- /dev/null
+++ b/vcl/uiconfig/theme_definitions/slider-button.svgx
@@ -0,0 +1,3 @@
+<svg version="1.1" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg">
+ <rect x="2" y="2" width="24" height="24" rx="12" ry="12" fill="#fff" stroke="#8e8e93" stroke-width=".92308"/>
+</svg>