[Libreoffice-commits] core.git: vcl/source vcl/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 13:51:04 UTC 2019


 vcl/source/gdi/FileDefinitionWidgetDraw.cxx   |   46 ++++++++++++++++++++++++++
 vcl/source/gdi/WidgetDefinitionReader.cxx     |   11 ++----
 vcl/uiconfig/theme_definitions/definition.xml |   18 ++++++++++
 3 files changed, 69 insertions(+), 6 deletions(-)

New commits:
commit 5a226c977633dc77a0a92b5196c75f3863bf1a3d
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Feb 19 14:05:02 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Mar 5 14:50:35 2019 +0100

    Draw basic slider from the theme definition
    
    Change-Id: I5ccd6c2e743324cee2a030e55425df4791e12e2f
    Reviewed-on: https://gerrit.libreoffice.org/68719
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 1e7c8928f0f1..bb6756bf1b9c 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -76,7 +76,9 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr
         case ControlType::TabHeader:
         case ControlType::TabBody:
         case ControlType::Scrollbar:
+            return false;
         case ControlType::Slider:
+            return true;
         case ControlType::Fixedline:
         case ControlType::Toolbar:
         case ControlType::Menubar:
@@ -375,7 +377,51 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
         case ControlType::TabPane:
         case ControlType::TabBody:
         case ControlType::Scrollbar:
+            break;
         case ControlType::Slider:
+        {
+            {
+                std::shared_ptr<WidgetDefinitionPart> pPart
+                    = m_aWidgetDefinition.getDefinition(eType, ePart);
+                if (pPart)
+                {
+                    auto aStates = pPart->getStates(eState, rValue);
+                    if (!aStates.empty())
+                    {
+                        std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
+                        {
+                            munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
+                                              nHeight);
+                            bOK = true;
+                        }
+                    }
+                }
+            }
+            if (bOK)
+            {
+                const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
+
+                std::shared_ptr<WidgetDefinitionPart> pPart
+                    = m_aWidgetDefinition.getDefinition(eType, ControlPart::Button);
+                if (pPart)
+                {
+                    auto aStates = pPart->getStates(eState | pSliderValue->mnThumbState, rValue);
+                    if (!aStates.empty())
+                    {
+                        std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
+                        {
+                            munchDrawCommands(pState->mpDrawCommands, m_rGraphics,
+                                              pSliderValue->maThumbRect.Left(),
+                                              pSliderValue->maThumbRect.Top(),
+                                              pSliderValue->maThumbRect.GetWidth() - 1,
+                                              pSliderValue->maThumbRect.GetHeight() - 1);
+                            bOK = true;
+                        }
+                    }
+                }
+            }
+        }
+        break;
         case ControlType::Fixedline:
         case ControlType::Toolbar:
         case ControlType::Menubar:
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index 799b3dda6187..9e4ed46f6f36 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -132,12 +132,11 @@ ControlPart xmlStringToControlPart(OString const& sPart)
 
 bool getControlTypeForXmlString(OString const& rString, ControlType& reType)
 {
-    static std::unordered_map<OString, ControlType> aPartMap = {
-        { "pushbutton", ControlType::Pushbutton }, { "radiobutton", ControlType::Radiobutton },
-        { "checkbox", ControlType::Checkbox },     { "combobox", ControlType::Combobox },
-        { "editbox", ControlType::Editbox },       { "scrollbar", ControlType::Scrollbar },
-        { "spinbox", ControlType::Spinbox },
-    };
+    static std::unordered_map<OString, ControlType> aPartMap
+        = { { "pushbutton", ControlType::Pushbutton }, { "radiobutton", ControlType::Radiobutton },
+            { "checkbox", ControlType::Checkbox },     { "combobox", ControlType::Combobox },
+            { "editbox", ControlType::Editbox },       { "scrollbar", ControlType::Scrollbar },
+            { "spinbox", ControlType::Spinbox },       { "slider", ControlType::Slider } };
 
     auto const& rIterator = aPartMap.find(rString);
     if (rIterator != aPartMap.end())
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index dca6e0e8963b..1286ea7fb8c9 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -140,4 +140,22 @@
         </part>
     </editbox>
 
+    <slider>
+        <part value="Button">
+            <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+                <circ stroke="#AAAAAA" fill="#FFFFFF" stroke-width="1" rx="7" ry="7"/>
+            </state>
+        </part>
+        <part value="TrackHorzArea">
+            <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+                <line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
+            </state>
+        </part>
+        <part value="TrackVertArea">
+            <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+                <line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
+            </state>
+        </part>
+    </slider>
+
 </widgets>


More information about the Libreoffice-commits mailing list