[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
Wed Mar 6 20:00:17 UTC 2019


 vcl/Package_theme_definitions.mk                         |    1 
 vcl/inc/widgetdraw/WidgetDefinition.hxx                  |    8 -
 vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx |   12 -
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx              |  108 ++++++++++-----
 vcl/source/gdi/WidgetDefinition.cxx                      |   29 +++-
 vcl/source/gdi/WidgetDefinitionReader.cxx                |    6 
 vcl/uiconfig/theme_definitions/definition.xml            |   11 -
 vcl/uiconfig/theme_definitions/spinbox-entire.svgx       |    3 
 vcl/uiconfig/theme_definitions/spinbox-left.svgx         |    6 
 vcl/uiconfig/theme_definitions/spinbox-right.svgx        |    7 
 10 files changed, 133 insertions(+), 58 deletions(-)

New commits:
commit cddf072a62208d2514f97ba5c0d3577d7d88b8de
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 3 10:13:35 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Mar 6 20:59:59 2019 +0100

    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: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/Package_theme_definitions.mk b/vcl/Package_theme_definitions.mk
index e28ae0911733..282a07a47df4 100644
--- a/vcl/Package_theme_definitions.mk
+++ b/vcl/Package_theme_definitions.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_Package_add_files,vcl_theme_definitions,$(LIBO_SHARE_FOLDER)/th
 	tick-on-disabled.svgx \
 	spinbox-left.svgx \
 	spinbox-right.svgx \
+	spinbox-entire.svgx \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 4160a2a0ada4..804bddb527fe 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -565,46 +565,88 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
     ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/,
     tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
 {
+    Point aLocation(rBoundingControlRegion.TopLeft());
+
     switch (eType)
     {
         case ControlType::Spinbox:
         {
-            Size aButtonSize(32, 32);
-            Point aLocation(rBoundingControlRegion.TopLeft());
+            Size aButtonSize(44, 26);
+            OString sOrientation = "decrease-edit-increase";
 
-            if (ePart == ControlPart::ButtonUp)
-            {
-                rNativeContentRegion = tools::Rectangle(
-                    Point(aLocation.X() + rBoundingControlRegion.GetWidth() - aButtonSize.Width(),
-                          aLocation.Y()),
-                    aButtonSize);
-                rNativeBoundingRegion = rNativeContentRegion;
-                return true;
-            }
-            else if (ePart == ControlPart::ButtonDown)
+            if (sOrientation == "decrease-edit-increase")
             {
-                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;
+                if (ePart == ControlPart::ButtonUp)
+                {
+                    rNativeContentRegion
+                        = tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
+                                                     - aButtonSize.Width(),
+                                                 aLocation.Y()),
+                                           aButtonSize);
+                    rNativeBoundingRegion = rNativeContentRegion;
+                    return true;
+                }
+                else if (ePart == ControlPart::ButtonDown)
+                {
+                    rNativeContentRegion = tools::Rectangle(aLocation, aButtonSize);
+                    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());
+                    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(
-                    aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
-                rNativeBoundingRegion = rNativeContentRegion;
-                return true;
+                if (ePart == ControlPart::ButtonUp)
+                {
+                    rNativeContentRegion
+                        = 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;
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index ddfe9cdff99d..a44ab10134e7 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -173,22 +173,17 @@
     <spinbox>
         <part value="Entire">
             <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>
         </part>
         <part value="ButtonDown">
             <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"/>
-                <line stroke="#007AFF" stroke-width="2" x1="0.4" y1="0.5" x2="0.6" y2="0.5"/>
-                <!-- <image source="spinbox-left.svgx" /> -->
+                <external source="spinbox-left.svgx" />
             </state>
         </part>
         <part value="ButtonUp">
             <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"/>
-                <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" /> -->
+                <external source="spinbox-right.svgx" />
             </state>
         </part>
     </spinbox>
diff --git a/vcl/uiconfig/theme_definitions/spinbox-entire.svgx b/vcl/uiconfig/theme_definitions/spinbox-entire.svgx
new file mode 100644
index 000000000000..24a3b12c2d58
--- /dev/null
+++ b/vcl/uiconfig/theme_definitions/spinbox-entire.svgx
@@ -0,0 +1,3 @@
+<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>
diff --git a/vcl/uiconfig/theme_definitions/spinbox-left.svgx b/vcl/uiconfig/theme_definitions/spinbox-left.svgx
index 3f98280a106b..aff42a99fbc0 100644
--- a/vcl/uiconfig/theme_definitions/spinbox-left.svgx
+++ b/vcl/uiconfig/theme_definitions/spinbox-left.svgx
@@ -1,4 +1,4 @@
-<svg version="1.1" width="44px" height="26px" 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"/>
- <rect x="18.5" y="12.25" width="7" height="1.5" color="#bebebe" fill="#007aff"/>
+<svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg">
+ <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="17" y="12" width="10" height="2" color="#bebebe" fill="#007aff"/>
 </svg>
diff --git a/vcl/uiconfig/theme_definitions/spinbox-right.svgx b/vcl/uiconfig/theme_definitions/spinbox-right.svgx
index 07ce83c388db..dec02f432aaf 100644
--- a/vcl/uiconfig/theme_definitions/spinbox-right.svgx
+++ b/vcl/uiconfig/theme_definitions/spinbox-right.svgx
@@ -1,4 +1,5 @@
-<svg version="1.1" width="44px" height="26px" 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="m21.27 9.428v2.857h-2.915v1.429h2.915v2.857h1.458v-2.857h2.915v-1.429h-2.915v-2.857z" color="#bebebe" fill="#007aff"/>
+<svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg">
+ <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"/>
+ <rect x="17" y="12" width="10" height="2" fill="#007aff"/>
+ <rect x="21" y="8" width="2" height="10" fill="#007aff"/>
 </svg>
commit fd57cdfc772713c9d7ccd4544063deedf744c633
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 3 10:00:05 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Mar 6 20:59:48 2019 +0100

    Support first, last tab item for the widget definition
    
    Add "extra" parameter for the widget definition states with the
    default set to "any". For tab item, the extra parameter can be
    "first", "last", "middle" and "first_last" (only one). This is
    needed to draw first and last tab item differently.
    
    Change-Id: I46b6897b485b4df94ab6fe9521925c3715eaa24e
    Reviewed-on: https://gerrit.libreoffice.org/68817
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 50aaed65ff2e..0ee545122ea9 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -172,10 +172,12 @@ public:
     OString msDefault;
     OString msSelected;
     OString msButtonValue;
+    OString msExtra;
 
     WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
                           OString const& sRollover, OString const& sDefault,
-                          OString const& sSelected, OString const& sButtonValue);
+                          OString const& sSelected, OString const& sButtonValue,
+                          OString const& sExtra);
 
     std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
 
@@ -194,8 +196,8 @@ public:
 class VCL_DLLPUBLIC WidgetDefinitionPart
 {
 public:
-    std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
-                                                                  ImplControlValue const& rValue);
+    std::vector<std::shared_ptr<WidgetDefinitionState>>
+    getStates(ControlType eType, 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 24713e9795b3..20b3270267dd 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -56,11 +56,11 @@ void WidgetDefinitionReaderTest::testRead()
 
     // Pushbutton
     {
+        ControlState eState
+            = ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER;
         std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
             = aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire)
-                  ->getStates(ControlState::DEFAULT | ControlState::ENABLED
-                                  | ControlState::ROLLOVER,
-                              ImplControlValue());
+                  ->getStates(ControlType::Pushbutton, eState, ImplControlValue());
 
         CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
 
@@ -74,7 +74,8 @@ void WidgetDefinitionReaderTest::testRead()
     {
         std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
             = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
-                  ->getStates(ControlState::NONE, ImplControlValue(ButtonValue::On));
+                  ->getStates(ControlType::Radiobutton, ControlState::NONE,
+                              ImplControlValue(ButtonValue::On));
         CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
         CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
     }
@@ -82,7 +83,8 @@ void WidgetDefinitionReaderTest::testRead()
     {
         std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
             = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
-                  ->getStates(ControlState::NONE, ImplControlValue(ButtonValue::Off));
+                  ->getStates(ControlType::Radiobutton, 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 c1e15bc9d9c9..4160a2a0ada4 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -368,7 +368,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart
     auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ePart);
     if (pPart)
     {
-        auto const& aStates = pPart->getStates(eState, rValue);
+        auto const& aStates = pPart->getStates(eType, eState, rValue);
         if (!aStates.empty())
         {
             // use last defined state
diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx
index f861b9efb302..25eba80ecb13 100644
--- a/vcl/source/gdi/WidgetDefinition.cxx
+++ b/vcl/source/gdi/WidgetDefinition.cxx
@@ -26,7 +26,8 @@ std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getDefinition(ControlTyp
 }
 
 std::vector<std::shared_ptr<WidgetDefinitionState>>
-WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rValue)
+WidgetDefinitionPart::getStates(ControlType eType, ControlState eState,
+                                ImplControlValue const& rValue)
 {
     std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
 
@@ -64,7 +65,30 @@ WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rVa
         if (state->msButtonValue != "any"
             && !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On)
                  || (state->msButtonValue == "false" && eButtonValue != ButtonValue::On)))
+        {
             bAdd = false;
+        }
+
+        if (eType == ControlType::TabItem)
+        {
+            OString sExtra;
+
+            auto const& rTabItemValue = static_cast<TabitemValue const&>(rValue);
+
+            if (rTabItemValue.isFirst() && rTabItemValue.isLast())
+                sExtra = "first_last";
+            else if (rTabItemValue.isFirst())
+                sExtra = "first";
+            else if (rTabItemValue.isLast())
+                sExtra = "last";
+            else
+                sExtra = "middle";
+
+            if (state->msExtra != "any" && state->msExtra != sExtra)
+            {
+                bAdd = false;
+            }
+        }
 
         if (bAdd)
             aStatesToAdd.push_back(state);
@@ -76,7 +100,7 @@ WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rVa
 WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused,
                                              OString const& sPressed, OString const& sRollover,
                                              OString const& sDefault, OString const& sSelected,
-                                             OString const& sButtonValue)
+                                             OString const& sButtonValue, OString const& sExtra)
     : msEnabled(sEnabled)
     , msFocused(sFocused)
     , msPressed(sPressed)
@@ -84,6 +108,7 @@ WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString co
     , msDefault(sDefault)
     , msSelected(sSelected)
     , msButtonValue(sButtonValue)
+    , msExtra(sExtra)
 {
 }
 
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index cf361d8793ed..8a7270e718f1 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -315,9 +315,13 @@ void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
             OString sDefault = rWalker.attribute("default");
             OString sSelected = rWalker.attribute("selected");
             OString sButtonValue = rWalker.attribute("button-value");
+            OString sExtra = rWalker.attribute("extra");
+            if (sExtra.isEmpty())
+                sExtra = "any";
 
             std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(
-                sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue);
+                sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue, sExtra);
+
             rpPart->maStates.push_back(pState);
             readDrawingDefinition(rWalker, pState);
         }


More information about the Libreoffice-commits mailing list