diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-02-19 14:05:02 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-05 14:50:35 +0100 |
commit | 5a226c977633dc77a0a92b5196c75f3863bf1a3d (patch) | |
tree | 9a33a3fdde4b63e8873618ac8db45932d568fe44 | |
parent | 4b6e00f08afb2968a1a5731729fc266b0e708ab2 (diff) |
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@gmail.com>
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 46 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 11 | ||||
-rw-r--r-- | vcl/uiconfig/theme_definitions/definition.xml | 18 |
3 files changed, 69 insertions, 6 deletions
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> |