Add scrollview to material list

CURA-6867
This commit is contained in:
Joey de l'Arago 2022-12-20 17:45:28 +01:00
parent 7174861bba
commit d4679515b6

View File

@ -244,6 +244,8 @@ Cura.MenuItem
height: materialColorsList.height + padding * 2
onOpened:
{
// This will be resolved before opening the popup if directly assigned to the properties
// This forces these values to update whenever a popup is opened
var popupHeight = model.colors.count * UM.Theme.getSize("menu").height
var parentGlobalY = parent.mapToItem(null, 0, 0).y
var overflowY = (parentGlobalY + popupHeight) - mainWindow.height
@ -252,6 +254,10 @@ Cura.MenuItem
var parentGlobalX = materialTypesList.mapToItem(null, 0, 0).x
var overflowX = (parentGlobalX + parent.width + colorPopup.width) - mainWindow.width
x = overflowX > 0 ? parent.width - overflowX : parent.width
var popupHeight = model.colors.count * UM.Theme.getSize("menu").height
scrollView.height = popupHeight > mainWindow.height ? mainWindow.height: popupHeight
colorPopup.height = popupHeight > mainWindow.height ? mainWindow.height: popupHeight
}
property int itemHovered: 0
@ -263,11 +269,27 @@ Cura.MenuItem
border.color: UM.Theme.getColor("lining")
border.width: UM.Theme.getSize("default_lining").width
}
ScrollView
{
id: scrollView
width: UM.Theme.getSize("menu").width + scrollbar.width
height: parent.height
clip: true
ScrollBar.vertical: UM.ScrollBar
{
id: scrollbar
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
}
Column
{
id: materialColorsList
property var brandColors: model.colors
width: UM.Theme.getSize("menu").width
height: parent.height
spacing: 0
Repeater
@ -277,12 +299,14 @@ Cura.MenuItem
delegate: Rectangle
{
height: UM.Theme.getSize("menu").height
width: UM.Theme.getSize("menu").width
width: parent.width
color: materialColorButton.containsMouse ? UM.Theme.getColor("background_2") : UM.Theme.getColor("background_1")
// color: materialColorButton.containsMouse ? UM.Theme.getColor("background_2") : UM.Theme.getColor("background_1")
Item
Rectangle
{
height: parent.height
width: parent.width
opacity: materialBrandMenu.enabled ? 1 : 0.5
anchors.fill: parent
@ -346,4 +370,5 @@ Cura.MenuItem
}
}
}
}
}