mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Fix scrollbar for object selector
This commit is contained in:
parent
549eb21a5a
commit
cc65bc8213
2 changed files with 27 additions and 39 deletions
|
@ -447,7 +447,6 @@ UM.MainWindow
|
||||||
target: Cura.Actions.addProfile
|
target: Cura.Actions.addProfile
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
|
|
||||||
preferences.show();
|
preferences.show();
|
||||||
preferences.setPage(4);
|
preferences.setPage(4);
|
||||||
// Create a new profile after a very short delay so the preference page has time to initiate
|
// Create a new profile after a very short delay so the preference page has time to initiate
|
||||||
|
|
|
@ -78,7 +78,7 @@ Item
|
||||||
id: contents
|
id: contents
|
||||||
width: parent.width
|
width: parent.width
|
||||||
visible: objectSelector.opened
|
visible: objectSelector.opened
|
||||||
height: visible ? scroll.height : 0
|
height: visible ? listView.height : 0
|
||||||
color: UM.Theme.getColor("main_background")
|
color: UM.Theme.getColor("main_background")
|
||||||
border.width: UM.Theme.getSize("default_lining").width
|
border.width: UM.Theme.getSize("default_lining").width
|
||||||
border.color: UM.Theme.getColor("lining")
|
border.color: UM.Theme.getColor("lining")
|
||||||
|
@ -87,50 +87,39 @@ Item
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
ScrollView
|
ListView
|
||||||
{
|
{
|
||||||
id: scroll
|
id: listView
|
||||||
width: parent.width
|
|
||||||
clip: true
|
clip: true
|
||||||
padding: UM.Theme.getSize("default_lining").width
|
anchors
|
||||||
|
|
||||||
contentItem: ListView
|
|
||||||
{
|
{
|
||||||
id: listView
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
margins: UM.Theme.getSize("default_lining").width
|
||||||
|
}
|
||||||
|
|
||||||
// Can't use parent.width since the parent is the flickable component and not the ScrollView
|
ScrollBar.vertical: ScrollBar
|
||||||
width: scroll.width - scroll.leftPadding - scroll.rightPadding
|
{
|
||||||
property real maximumHeight: UM.Theme.getSize("objects_menu_size").height
|
hoverEnabled: true
|
||||||
|
}
|
||||||
|
|
||||||
// We use an extra property here, since we only want to to be informed about the content size changes.
|
property real maximumHeight: UM.Theme.getSize("objects_menu_size").height
|
||||||
onContentHeightChanged:
|
|
||||||
|
height: Math.min(contentHeight, maximumHeight)
|
||||||
|
|
||||||
|
model: Cura.ObjectsModel {}
|
||||||
|
|
||||||
|
delegate: ObjectItemButton
|
||||||
|
{
|
||||||
|
id: modelButton
|
||||||
|
Binding
|
||||||
{
|
{
|
||||||
// It can sometimes happen that (due to animations / updates) the contentHeight is -1.
|
target: modelButton
|
||||||
// This can cause a bunch of updates to trigger oneother, leading to a weird loop.
|
property: "checked"
|
||||||
if(contentHeight >= 0)
|
value: model.selected
|
||||||
{
|
|
||||||
scroll.height = Math.min(contentHeight, maximumHeight) + scroll.topPadding + scroll.bottomPadding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted:
|
|
||||||
{
|
|
||||||
scroll.height = Math.min(contentHeight, maximumHeight) + scroll.topPadding + scroll.bottomPadding
|
|
||||||
}
|
|
||||||
model: Cura.ObjectsModel {}
|
|
||||||
|
|
||||||
delegate: ObjectItemButton
|
|
||||||
{
|
|
||||||
id: modelButton
|
|
||||||
Binding
|
|
||||||
{
|
|
||||||
target: modelButton
|
|
||||||
property: "checked"
|
|
||||||
value: model.selected
|
|
||||||
}
|
|
||||||
text: model.name
|
|
||||||
width: listView.width
|
|
||||||
}
|
}
|
||||||
|
text: model.name
|
||||||
|
width: listView.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue