[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/Package_theme_definitions.mk vcl/qa vcl/source vcl/uiconfig
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Mar 10 21:58:11 UTC 2019
vcl/Package_theme_definitions.mk | 3
vcl/inc/widgetdraw/WidgetDefinition.hxx | 6 +
vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx | 7 +
vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 42 +++++++++--
vcl/source/gdi/WidgetDefinition.cxx | 53 +++++++++------
vcl/uiconfig/theme_definitions/arrow-down.svgx | 5 +
vcl/uiconfig/theme_definitions/arrow-up.svgx | 5 +
vcl/uiconfig/theme_definitions/definition.xml | 33 +++++++--
vcl/uiconfig/theme_definitions/slider-button.svgx | 3
9 files changed, 121 insertions(+), 36 deletions(-)
New commits:
commit 100ea3038b033b6b168860e203e893ae8f67b9c1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 10 21:23:06 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Mar 10 22:57:54 2019 +0100
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 at gmail.com>
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>
commit 8ff3e9a418a6f154d3ecb2df669fbd70361ae0c0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 10 19:55:42 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Mar 10 22:57:48 2019 +0100
widget theme: draw listheader button and arrow
Also adds support for signaling if arrow points up or down, which
is signaled through extra attribute.
Change-Id: I5a87cdb31e18150495df521bf925c7b983e2313a
Reviewed-on: https://gerrit.libreoffice.org/69013
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/Package_theme_definitions.mk b/vcl/Package_theme_definitions.mk
index 0ca04e765039..d9cc421fe794 100644
--- a/vcl/Package_theme_definitions.mk
+++ b/vcl/Package_theme_definitions.mk
@@ -45,6 +45,8 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th
scrollbar-vertical.svgx \
combobox.svgx \
combobox-disabled.svgx \
+ arrow-up.svgx \
+ arrow-down.svgx \
))
# vim: set noet sw=4 ts=4:
diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 7e1505c8daae..77baf0922cd8 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -202,8 +202,10 @@ public:
sal_Int32 mnMarginHeight;
OString msOrientation;
- std::vector<std::shared_ptr<WidgetDefinitionState>>
- getStates(ControlType eType, ControlState eState, ImplControlValue const& rValue);
+ std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlType eType,
+ ControlPart ePart,
+ ControlState eState,
+ ImplControlValue const& rValue);
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
};
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
index c56379cc70c7..75dc559067fc 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -57,7 +57,8 @@ void WidgetDefinitionReaderTest::testRead()
= ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER;
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire)
- ->getStates(ControlType::Pushbutton, eState, ImplControlValue());
+ ->getStates(ControlType::Pushbutton, ControlPart::Entire, eState,
+ ImplControlValue());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
@@ -71,7 +72,7 @@ void WidgetDefinitionReaderTest::testRead()
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
- ->getStates(ControlType::Radiobutton, ControlState::NONE,
+ ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
ImplControlValue(ButtonValue::On));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
@@ -80,7 +81,7 @@ void WidgetDefinitionReaderTest::testRead()
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
- ->getStates(ControlType::Radiobutton, ControlState::NONE,
+ ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
ImplControlValue(ButtonValue::Off));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size());
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 9085753dbf25..b557021f4601 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -402,7 +402,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart
auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart);
if (pPart)
{
- auto const& aStates = pPart->getStates(eType, eState, rValue);
+ auto const& aStates = pPart->getStates(eType, ePart, eState, rValue);
if (!aStates.empty())
{
// use last defined state
diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx
index 5d316298da37..668fe74bf403 100644
--- a/vcl/source/gdi/WidgetDefinition.cxx
+++ b/vcl/source/gdi/WidgetDefinition.cxx
@@ -26,7 +26,7 @@ std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getDefinition(ControlTyp
}
std::vector<std::shared_ptr<WidgetDefinitionState>>
-WidgetDefinitionPart::getStates(ControlType eType, ControlState eState,
+WidgetDefinitionPart::getStates(ControlType eType, ControlPart ePart, ControlState eState,
ImplControlValue const& rValue)
{
std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
@@ -69,26 +69,43 @@ WidgetDefinitionPart::getStates(ControlType eType, ControlState eState,
bAdd = false;
}
- if (eType == ControlType::TabItem)
- {
- OString sExtra;
-
- auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
-
- if (rTabItemValue.isLeftAligned() && rTabItemValue.isRightAligned()
- && rTabItemValue.isFirst() && rTabItemValue.isLast())
- sExtra = "first_last";
- else if (rTabItemValue.isLeftAligned() || rTabItemValue.isFirst())
- sExtra = "first";
- else if (rTabItemValue.isRightAligned() || rTabItemValue.isLast())
- sExtra = "last";
- else
- sExtra = "middle";
+ OString sExtra = "any";
- if (state->msExtra != "any" && state->msExtra != sExtra)
+ switch (eType)
+ {
+ case ControlType::TabItem:
+ {
+ auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
+
+ if (rTabItemValue.isLeftAligned() && rTabItemValue.isRightAligned()
+ && rTabItemValue.isFirst() && rTabItemValue.isLast())
+ sExtra = "first_last";
+ else if (rTabItemValue.isLeftAligned() || rTabItemValue.isFirst())
+ sExtra = "first";
+ else if (rTabItemValue.isRightAligned() || rTabItemValue.isLast())
+ sExtra = "last";
+ else
+ sExtra = "middle";
+ }
+ break;
+ case ControlType::ListHeader:
{
- bAdd = false;
+ if (ePart == ControlPart::Arrow)
+ {
+ if (rValue.getNumericVal() == 1)
+ sExtra = "down";
+ else
+ sExtra = "up";
+ }
}
+ break;
+ default:
+ break;
+ }
+
+ if (state->msExtra != "any" && state->msExtra != sExtra)
+ {
+ bAdd = false;
}
if (bAdd)
diff --git a/vcl/uiconfig/theme_definitions/arrow-down.svgx b/vcl/uiconfig/theme_definitions/arrow-down.svgx
new file mode 100644
index 000000000000..032df3df64b9
--- /dev/null
+++ b/vcl/uiconfig/theme_definitions/arrow-down.svgx
@@ -0,0 +1,5 @@
+<svg version="1.1" viewBox="0 0 11 20" xmlns="http://www.w3.org/2000/svg">
+ <g transform="translate(245.46 49.566)">
+ <path d="m-242.75-44.074h5.5903l-2.7951 8z" fill="#007aff" stroke="#007aff"/>
+ </g>
+</svg>
diff --git a/vcl/uiconfig/theme_definitions/arrow-up.svgx b/vcl/uiconfig/theme_definitions/arrow-up.svgx
new file mode 100644
index 000000000000..524906f31018
--- /dev/null
+++ b/vcl/uiconfig/theme_definitions/arrow-up.svgx
@@ -0,0 +1,5 @@
+<svg version="1.1" viewBox="0 0 11 20" xmlns="http://www.w3.org/2000/svg">
+ <g transform="translate(245.46 49.566)">
+ <path d="m-242.75-35.066h5.5903l-2.7951-7.9855z" fill="#007aff" stroke="#007aff"/>
+ </g>
+</svg>
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index 848f0e600d89..bdb1e700715b 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -432,6 +432,19 @@
</listnet>
<listheader>
+ <part value="Button">
+ <state>
+ <rect stroke="#8e8e93" fill="#f4f5f5" stroke-width="1" rx="1" ry="1"/>
+ </state>
+ </part>
+ <part value="Arrow">
+ <state extra="up">
+ <image source="arrow-up.svgx"/>
+ </state>
+ <state extra="down">
+ <image source="arrow-down.svgx"/>
+ </state>
+ </part>
</listheader>
</widgets>
More information about the Libreoffice-commits
mailing list