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.
This commit is contained in:
Ghostkeeper 2018-12-06 12:07:03 +01:00
parent 48e15daf64
commit f1fec2f280
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -28,10 +28,25 @@ Column
{ {
id: container id: container
width: parent.width 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 contentHeight: configurationList.height
clip: true 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 ButtonGroup
{ {
buttons: configurationList.children buttons: configurationList.children
@ -41,7 +56,7 @@ Column
{ {
id: configurationList id: configurationList
spacing: Math.round(UM.Theme.getSize("default_margin").height / 2) 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 contentHeight: childrenRect.height
height: childrenRect.height height: childrenRect.height