Make SimulationViewMenuComponent also use the ExpandableComponent

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-13 15:57:00 +01:00
parent deb5fd1926
commit 785c2661a2
3 changed files with 20 additions and 64 deletions

View file

@ -78,7 +78,7 @@ Item
property var buttonTarget: Qt.point(viewModeButton.x + Math.round(viewModeButton.width / 2), viewModeButton.y + Math.round(viewModeButton.height / 2)) property var buttonTarget: Qt.point(viewModeButton.x + Math.round(viewModeButton.width / 2), viewModeButton.y + Math.round(viewModeButton.height / 2))
height: childrenRect.height height: parent.height
width: childrenRect.width width: childrenRect.width
source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : "" source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""

View file

@ -10,19 +10,13 @@ import QtGraphicalEffects 1.0
import UM 1.0 as UM import UM 1.0 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
Rectangle
Cura.ExpandableComponent
{ {
id: base id: base
color: UM.Theme.getColor("tool_panel_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
width: UM.Theme.getSize("layerview_menu_size").width width: UM.Theme.getSize("layerview_menu_size").width
iconSource: UM.Theme.getIcon("pencil")
height: viewSettings.collapsed ? layerViewTypesLabel.height + 2 * UM.Theme.getSize("default_margin").height : childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
Behavior on height { NumberAnimation { duration: 100 } }
property var buttonTarget: property var buttonTarget:
{ {
@ -51,59 +45,21 @@ Rectangle
} }
} }
Label headerItem: Label
{ {
id: layerViewTypesLabel id: layerViewTypesLabel
text: catalog.i18nc("@label", "Color scheme") text: catalog.i18nc("@label", "Color scheme")
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default")
visible: !UM.SimulationView.compatibilityMode visible: !UM.SimulationView.compatibilityMode
color: UM.Theme.getColor("setting_control_text") color: UM.Theme.getColor("setting_control_text")
height: contentHeight height: base.height
anchors verticalAlignment: Text.AlignVCenter
{
top: parent.top
margins: UM.Theme.getSize("default_margin").height
right: collapseButton.left
left: parent.left
}
} }
Button popupItem: Column
{
id: collapseButton
anchors
{
top: parent.top
margins: UM.Theme.getSize("default_margin").width
right: parent.right
}
width: UM.Theme.getSize("standard_arrow").width
height: UM.Theme.getSize("standard_arrow").height
onClicked: viewSettings.collapsed = !viewSettings.collapsed
style: ButtonStyle
{
background: UM.RecolorImage
{
width: control.width
height: control.height
sourceSize.width: width
sourceSize.height: width
color: UM.Theme.getColor("setting_control_text")
source: viewSettings.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
}
label: Label{ }
}
}
Column
{ {
id: viewSettings id: viewSettings
property bool collapsed: false
property var extruder_opacities: UM.Preferences.getValue("layerview/extruder_opacities").split("|") property var extruder_opacities: UM.Preferences.getValue("layerview/extruder_opacities").split("|")
property bool show_travel_moves: UM.Preferences.getValue("layerview/show_travel_moves") property bool show_travel_moves: UM.Preferences.getValue("layerview/show_travel_moves")
property bool show_helpers: UM.Preferences.getValue("layerview/show_helpers") property bool show_helpers: UM.Preferences.getValue("layerview/show_helpers")
@ -118,19 +74,11 @@ Rectangle
property bool only_show_top_layers: UM.Preferences.getValue("view/only_show_top_layers") property bool only_show_top_layers: UM.Preferences.getValue("view/only_show_top_layers")
property int top_layer_count: UM.Preferences.getValue("view/top_layer_count") property int top_layer_count: UM.Preferences.getValue("view/top_layer_count")
anchors width: UM.Theme.getSize("layerview_menu_size").width
{ height: childrenRect.height
top: layerViewTypesLabel.bottom
left: parent.left
right: parent.right
margins: UM.Theme.getSize("default_margin").height
}
spacing: UM.Theme.getSize("layerview_row_spacing").height spacing: UM.Theme.getSize("layerview_row_spacing").height
visible: !collapsed
ListModel // matches SimulationView.py ListModel // matches SimulationView.py
{ {
id: layerViewTypes id: layerViewTypes

View file

@ -47,6 +47,14 @@ Item
popup.contentItem = popupItem popup.contentItem = popupItem
} }
Connections
{
// Since it could be that the popup is dynamically populated, we should also take these changes into account.
target: popupItem
onWidthChanged: popup.width = popupItem.width + 2 * popup.padding
onHeightChanged: popup.height = popupItem.height + 2 * popup.padding
}
implicitHeight: 100 implicitHeight: 100
implicitWidth: 400 implicitWidth: 400
Rectangle Rectangle