Don't show the background if there are less than 2 extruders to show in the Toolbar

It caused a very tiny rectangle if the printer has only 1 extruder.

Contributes to CURA-5984.
This commit is contained in:
Diego Prado Gesto 2018-12-04 09:19:08 +01:00
parent c1f5c00a7e
commit 57a852a15a

View File

@ -115,6 +115,7 @@ Item
} }
radius: UM.Theme.getSize("default_radius").width radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("lining") color: UM.Theme.getColor("lining")
visible: extrudersModel.items.length > 1
} }
Column Column
@ -131,8 +132,7 @@ Item
id: extruders id: extruders
width: childrenRect.width width: childrenRect.width
height: childrenRect.height height: childrenRect.height
property var _model: Cura.ExtrudersModel { id: extrudersModel } model: extrudersModel.items.length > 1 ? extrudersModel : 0
model: _model.items.length > 1 ? _model : 0
delegate: ExtruderButton delegate: ExtruderButton
{ {
@ -144,13 +144,18 @@ Item
} }
} }
Cura.ExtrudersModel
{
id: extrudersModel
}
UM.PointingRectangle UM.PointingRectangle
{ {
id: panelBorder; id: panelBorder
anchors.left: parent.right; anchors.left: parent.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width; anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: base.top; anchors.top: base.top
anchors.topMargin: base.activeY anchors.topMargin: base.activeY
z: buttons.z - 1 z: buttons.z - 1
@ -161,14 +166,14 @@ Item
{ {
if (panel.item && panel.width > 0) if (panel.item && panel.width > 0)
{ {
return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width); return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
} }
else else
{ {
return 0; return 0;
} }
} }
height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0; height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0
opacity: panel.item && panel.width > 0 ? 1 : 0 opacity: panel.item && panel.width > 0 ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } } Behavior on opacity { NumberAnimation { duration: 100 } }
@ -186,11 +191,11 @@ Item
{ {
id: panel id: panel
x: UM.Theme.getSize("default_margin").width; x: UM.Theme.getSize("default_margin").width
y: UM.Theme.getSize("default_margin").height; y: UM.Theme.getSize("default_margin").height
source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "" source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : ""
enabled: UM.Controller.toolsEnabled; enabled: UM.Controller.toolsEnabled
} }
} }