From f1fec2f28082661e58b6fb0824521d69409bb4fb Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 6 Dec 2018 12:07:03 +0100 Subject: [PATCH] Theme the scroll bar We need to make this a reusable component at some point, I think. This is the first time we're using the QtQuick2 version of ScrollView. Contributes to issue CURA-5876. --- .../ConfigurationListView.qml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml index d07337f9c5..e7936b69d2 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml @@ -28,10 +28,25 @@ Column { id: container width: parent.width - height: Math.round(Math.min(configurationList.height, 350 * screenScaleFactor)) + readonly property int maximumHeight: 350 * screenScaleFactor + height: Math.round(Math.min(configurationList.height, maximumHeight)) contentHeight: configurationList.height clip: true + ScrollBar.vertical.policy: (configurationList.height > maximumHeight) ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff //The AsNeeded policy also hides it when the cursor is away, and we don't want that. + ScrollBar.vertical.background: Rectangle + { + implicitWidth: UM.Theme.getSize("scrollbar").width + radius: width / 2 + color: UM.Theme.getColor("scrollbar_background") + } + ScrollBar.vertical.contentItem: Rectangle + { + implicitWidth: UM.Theme.getSize("scrollbar").width + radius: width / 2 + color: UM.Theme.getColor(parent.pressed ? "scrollbar_handle_down" : parent.hovered ? "scrollbar_handle_hover" : "scrollbar_handle") + } + ButtonGroup { buttons: configurationList.children @@ -41,7 +56,7 @@ Column { id: configurationList spacing: Math.round(UM.Theme.getSize("default_margin").height / 2) - width: container.width + width: container.width - ((height > container.maximumHeight) ? container.ScrollBar.vertical.background.width : 0) //Make room for scroll bar if there is any. contentHeight: childrenRect.height height: childrenRect.height