mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Allow open file button to resize depending on content items
This re-links the widths, heights and paddings such that we can later change the width of the button depending on its contents. However there is a complication: Buttons automatically change the size of the contents based on the size of the button minus its padding. So making the size of the button in turn depend on its contents causes a binding loop. To get around this binding loop, we need to manually calculate the size of the button, such that the size of the contents ends up exactly right. Contributes to issue CURA-8008.
This commit is contained in:
parent
920e220bdb
commit
ffa89bb1a1
1 changed files with 23 additions and 11 deletions
|
@ -77,24 +77,36 @@ Item
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
id: openFileButton
|
id: openFileButton
|
||||||
|
|
||||||
|
//Make the button square if the contents are.
|
||||||
|
leftPadding: topPadding
|
||||||
|
rightPadding: topPadding
|
||||||
|
bottomPadding: topPadding
|
||||||
|
|
||||||
height: UM.Theme.getSize("stage_menu").height
|
height: UM.Theme.getSize("stage_menu").height
|
||||||
width: UM.Theme.getSize("stage_menu").height
|
width: openFileIconContainer.width + leftPadding + rightPadding
|
||||||
onClicked: Cura.Actions.open.trigger()
|
onClicked: Cura.Actions.open.trigger()
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
contentItem: Item
|
contentItem: Row
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
Item
|
||||||
UM.RecolorImage
|
|
||||||
{
|
{
|
||||||
id: buttonIcon
|
id: openFileIconContainer
|
||||||
anchors.centerIn: parent
|
height: parent.height
|
||||||
source: UM.Theme.getIcon("Folder", "medium")
|
width: height //Square button.
|
||||||
width: UM.Theme.getSize("button_icon").width
|
|
||||||
height: UM.Theme.getSize("button_icon").height
|
|
||||||
color: UM.Theme.getColor("icon")
|
|
||||||
|
|
||||||
sourceSize.height: height
|
UM.RecolorImage
|
||||||
|
{
|
||||||
|
id: buttonIcon
|
||||||
|
anchors.centerIn: parent
|
||||||
|
source: UM.Theme.getIcon("Folder", "medium")
|
||||||
|
width: UM.Theme.getSize("button_icon").width
|
||||||
|
height: UM.Theme.getSize("button_icon").height
|
||||||
|
color: UM.Theme.getColor("icon")
|
||||||
|
|
||||||
|
sourceSize.height: height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue