Define the look and feel of the view selector button. Adjust the sizes.

This commit is contained in:
Diego Prado Gesto 2018-11-25 20:13:56 +01:00
parent 68c96a2577
commit c5d0ed2651
2 changed files with 35 additions and 9 deletions

View file

@ -15,7 +15,7 @@ Cura.ExpandableComponent
property bool isPrinterConnected: Cura.MachineManager.printerConnected property bool isPrinterConnected: Cura.MachineManager.printerConnected
property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
popupPadding: 0 popupPadding: UM.Theme.getSize("default_lining").width
popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
@ -90,8 +90,7 @@ Cura.ExpandableComponent
MachineSelectorList MachineSelectorList
{ {
// Can't use parent.width since the parent is the flickable component and not the ScrollView // Can't use parent.width since the parent is the flickable component and not the ScrollView
width: scroll.width - 2 * UM.Theme.getSize("default_lining").width width: scroll.width
x: UM.Theme.getSize("default_lining").width
property real maximumHeight: UM.Theme.getSize("machine_selector_widget_content").height - buttonRow.height property real maximumHeight: UM.Theme.getSize("machine_selector_widget_content").height - buttonRow.height
onHeightChanged: onHeightChanged:

View file

@ -11,6 +11,8 @@ Cura.ExpandableComponent
{ {
id: viewSelector id: viewSelector
popupPadding: UM.Theme.getSize("default_lining").width
popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
property var viewModel: UM.ViewModel { } property var viewModel: UM.ViewModel { }
@ -71,25 +73,51 @@ Cura.ExpandableComponent
popupItem: Column popupItem: Column
{ {
id: viewSelectorPopup id: viewSelectorPopup
width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width width: viewSelector.width - 2 * viewSelector.popupPadding
// For some reason the height/width of the column gets set to 0 if this is not set... // For some reason the height/width of the column gets set to 0 if this is not set...
Component.onCompleted: Component.onCompleted:
{ {
height = implicitHeight height = implicitHeight
width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width width = viewSelector.width - 2 * viewSelector.popupPadding
} }
Repeater Repeater
{ {
id: viewsList id: viewsList
model: viewSelector.viewModel model: viewSelector.viewModel
RoundButton
delegate: Button
{ {
text: name id: viewsSelectorButton
radius: UM.Theme.getSize("default_radius").width text: model.name
width: parent.width
height: UM.Theme.getSize("action_button").height
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
checkable: true checkable: true
checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false
contentItem: Label
{
id: buttonText
text: viewsSelectorButton.text
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("action_button")
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle
{
id: backgroundRect
color: viewsSelectorButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent"
radius: UM.Theme.getSize("action_button_radius").width
border.width: UM.Theme.getSize("default_lining").width
border.color: viewsSelectorButton.checked ? UM.Theme.getColor("primary") : "transparent"
}
onClicked: onClicked:
{ {
viewSelector.togglePopup() viewSelector.togglePopup()
@ -97,6 +125,5 @@ Cura.ExpandableComponent
} }
} }
} }
} }
} }