mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
continue layer slider labels - CURA-4412
This commit is contained in:
parent
ee0dabd837
commit
5740af04bb
2 changed files with 77 additions and 86 deletions
|
@ -186,8 +186,8 @@ Item {
|
||||||
|
|
||||||
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
||||||
// width is calculated automatically from the input field width
|
// width is calculated automatically from the input field width
|
||||||
x: (sliderRoot.width / 2 - (parent.width / 2)) - width
|
x: parent.x - width // align with slider handle
|
||||||
y: Math.floor(parent.y + parent.height / 2 - height / 2)
|
y: parent.anchors.top - height // align with slider? handle
|
||||||
target: Qt.point(sliderRoot.width, parent.y + parent.height / 2)
|
target: Qt.point(sliderRoot.width, parent.y + parent.height / 2)
|
||||||
visible: sliderRoot.layersVisible
|
visible: sliderRoot.layersVisible
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import QtQuick.Controls.Styles 1.1
|
||||||
import UM 1.0 as UM
|
import UM 1.0 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
Item {
|
UM.PointingRectangle {
|
||||||
id: sliderLabelRoot
|
id: sliderLabelRoot
|
||||||
|
|
||||||
// custom properties
|
// custom properties
|
||||||
|
@ -19,92 +19,83 @@ Item {
|
||||||
property var setValue // Function
|
property var setValue // Function
|
||||||
property bool busy: false
|
property bool busy: false
|
||||||
|
|
||||||
x: parent.x
|
target: sliderLabelRoot.target
|
||||||
y: parent.y
|
arrowSize: UM.Theme.getSize("default_arrow").width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
width: valueLabel.width + UM.Theme.getSize("default_margin").width
|
||||||
|
|
||||||
|
color: UM.Theme.getColor("tool_panel_background")
|
||||||
|
borderColor: UM.Theme.getColor("lining")
|
||||||
|
borderWidth: UM.Theme.getSize("default_lining").width
|
||||||
|
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
UM.PointingRectangle {
|
Behavior on height {
|
||||||
x: sliderLabelRoot.x
|
NumberAnimation {
|
||||||
y: sliderLabelRoot.y
|
duration: 50
|
||||||
target: sliderLabelRoot.target
|
|
||||||
arrowSize: UM.Theme.getSize("default_arrow").width
|
|
||||||
height: sliderLabelRoot.height
|
|
||||||
width: valueLabel.width + UM.Theme.getSize("default_margin").width
|
|
||||||
|
|
||||||
color: UM.Theme.getColor("tool_panel_background")
|
|
||||||
borderColor: UM.Theme.getColor("lining")
|
|
||||||
borderWidth: UM.Theme.getSize("default_lining").width
|
|
||||||
|
|
||||||
visible: sliderLabelRoot.visible
|
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 50
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// catch all mouse events so they're not handled by underlying 3D scene
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: valueLabel
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
leftMargin: UM.Theme.getSize("default_margin").width / 2
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
width: Math.max(UM.Theme.getSize("line").width * sliderLabelRoot.maximumValue.length + 2 * screenScaleFactor, 20 * screenScaleFactor)
|
|
||||||
|
|
||||||
text: sliderLabelRoot.value + 1 // the current handle value, add 1 because layers is an array
|
|
||||||
horizontalAlignment: TextInput.AlignRight
|
|
||||||
|
|
||||||
style: TextFieldStyle {
|
|
||||||
textColor: UM.Theme.getColor("setting_control_text")
|
|
||||||
font: UM.Theme.getFont("default")
|
|
||||||
background: Item { }
|
|
||||||
}
|
|
||||||
|
|
||||||
onEditingFinished: {
|
|
||||||
|
|
||||||
// Ensure that the cursor is at the first position. On some systems the text isn't fully visible
|
|
||||||
// Seems to have to do something with different dpi densities that QML doesn't quite handle.
|
|
||||||
// Another option would be to increase the size even further, but that gives pretty ugly results.
|
|
||||||
cursorPosition = 0
|
|
||||||
|
|
||||||
if (valueLabel.text != "") {
|
|
||||||
// -1 because we need to convert back to an array structure
|
|
||||||
sliderLabelRoot.setValue(parseInt(valueLabel.text) - 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
validator: IntValidator {
|
|
||||||
bottom: 1
|
|
||||||
top: sliderLabelRoot.maximumValue + 1 // +1 because actual layers is an array
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onUpPressed: sliderLabelRoot.setValue(sliderLabelRoot.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
Keys.onDownPressed: sliderLabelRoot.setValue(sliderLabelRoot.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
BusyIndicator {
|
|
||||||
id: busyIndicator
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
left: parent.right
|
|
||||||
leftMargin: UM.Theme.getSize("default_margin").width / 2
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
width: sliderLabelRoot.height
|
|
||||||
height: width
|
|
||||||
|
|
||||||
visible: sliderLabelRoot.busy
|
|
||||||
running: sliderLabelRoot.busy
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// catch all mouse events so they're not handled by underlying 3D scene
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: valueLabel
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: UM.Theme.getSize("default_margin").width / 2
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
width: Math.max(UM.Theme.getSize("line").width * sliderLabelRoot.maximumValue.length + 2 * screenScaleFactor, 20 * screenScaleFactor)
|
||||||
|
|
||||||
|
text: sliderLabelRoot.value + 1 // the current handle value, add 1 because layers is an array
|
||||||
|
horizontalAlignment: TextInput.AlignRight
|
||||||
|
|
||||||
|
style: TextFieldStyle {
|
||||||
|
textColor: UM.Theme.getColor("setting_control_text")
|
||||||
|
font: UM.Theme.getFont("default")
|
||||||
|
background: Item { }
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
|
||||||
|
// Ensure that the cursor is at the first position. On some systems the text isn't fully visible
|
||||||
|
// Seems to have to do something with different dpi densities that QML doesn't quite handle.
|
||||||
|
// Another option would be to increase the size even further, but that gives pretty ugly results.
|
||||||
|
cursorPosition = 0
|
||||||
|
|
||||||
|
if (valueLabel.text != "") {
|
||||||
|
// -1 because we need to convert back to an array structure
|
||||||
|
sliderLabelRoot.setValue(parseInt(valueLabel.text) - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validator: IntValidator {
|
||||||
|
bottom: 1
|
||||||
|
top: sliderLabelRoot.maximumValue + 1 // +1 because actual layers is an array
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onUpPressed: sliderLabelRoot.setValue(sliderLabelRoot.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
|
Keys.onDownPressed: sliderLabelRoot.setValue(sliderLabelRoot.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
BusyIndicator {
|
||||||
|
id: busyIndicator
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.right
|
||||||
|
leftMargin: UM.Theme.getSize("default_margin").width / 2
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
width: sliderLabelRoot.height
|
||||||
|
height: width
|
||||||
|
|
||||||
|
visible: sliderLabelRoot.busy
|
||||||
|
running: sliderLabelRoot.busy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue