mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Merge branch '3.5'
This commit is contained in:
commit
28f743c9f4
2 changed files with 133 additions and 78 deletions
|
@ -9,7 +9,8 @@ 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 {
|
Item
|
||||||
|
{
|
||||||
id: sliderRoot
|
id: sliderRoot
|
||||||
|
|
||||||
// handle properties
|
// handle properties
|
||||||
|
@ -41,39 +42,47 @@ Item {
|
||||||
property bool layersVisible: true
|
property bool layersVisible: true
|
||||||
property bool manuallyChanged: true // Indicates whether the value was changed manually or during simulation
|
property bool manuallyChanged: true // Indicates whether the value was changed manually or during simulation
|
||||||
|
|
||||||
function getUpperValueFromSliderHandle() {
|
function getUpperValueFromSliderHandle()
|
||||||
|
{
|
||||||
return upperHandle.getValue()
|
return upperHandle.getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpperValue(value) {
|
function setUpperValue(value)
|
||||||
|
{
|
||||||
upperHandle.setValue(value)
|
upperHandle.setValue(value)
|
||||||
updateRangeHandle()
|
updateRangeHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLowerValueFromSliderHandle() {
|
function getLowerValueFromSliderHandle()
|
||||||
|
{
|
||||||
return lowerHandle.getValue()
|
return lowerHandle.getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLowerValue(value) {
|
function setLowerValue(value)
|
||||||
|
{
|
||||||
lowerHandle.setValue(value)
|
lowerHandle.setValue(value)
|
||||||
updateRangeHandle()
|
updateRangeHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRangeHandle() {
|
function updateRangeHandle()
|
||||||
|
{
|
||||||
rangeHandle.height = lowerHandle.y - (upperHandle.y + upperHandle.height)
|
rangeHandle.height = lowerHandle.y - (upperHandle.y + upperHandle.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the active handle to show only one label at a time
|
// set the active handle to show only one label at a time
|
||||||
function setActiveHandle(handle) {
|
function setActiveHandle(handle)
|
||||||
|
{
|
||||||
activeHandle = handle
|
activeHandle = handle
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeValue(value) {
|
function normalizeValue(value)
|
||||||
|
{
|
||||||
return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue)
|
return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// slider track
|
// slider track
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: track
|
id: track
|
||||||
|
|
||||||
width: sliderRoot.trackThickness
|
width: sliderRoot.trackThickness
|
||||||
|
@ -87,7 +96,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range handle
|
// Range handle
|
||||||
Item {
|
Item
|
||||||
|
{
|
||||||
id: rangeHandle
|
id: rangeHandle
|
||||||
|
|
||||||
y: upperHandle.y + upperHandle.height
|
y: upperHandle.y + upperHandle.height
|
||||||
|
@ -97,7 +107,8 @@ Item {
|
||||||
visible: sliderRoot.layersVisible
|
visible: sliderRoot.layersVisible
|
||||||
|
|
||||||
// set the new value when dragging
|
// set the new value when dragging
|
||||||
function onHandleDragged() {
|
function onHandleDragged()
|
||||||
|
{
|
||||||
sliderRoot.manuallyChanged = true
|
sliderRoot.manuallyChanged = true
|
||||||
|
|
||||||
upperHandle.y = y - upperHandle.height
|
upperHandle.y = y - upperHandle.height
|
||||||
|
@ -111,7 +122,14 @@ Item {
|
||||||
UM.SimulationView.setMinimumLayer(lowerValue)
|
UM.SimulationView.setMinimumLayer(lowerValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setValue(value) {
|
function setValueManually(value)
|
||||||
|
{
|
||||||
|
sliderRoot.manuallyChanged = true
|
||||||
|
upperHandle.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue(value)
|
||||||
|
{
|
||||||
var range = sliderRoot.upperValue - sliderRoot.lowerValue
|
var range = sliderRoot.upperValue - sliderRoot.lowerValue
|
||||||
value = Math.min(value, sliderRoot.maximumValue)
|
value = Math.min(value, sliderRoot.maximumValue)
|
||||||
value = Math.max(value, sliderRoot.minimumValue + range)
|
value = Math.max(value, sliderRoot.minimumValue + range)
|
||||||
|
@ -120,17 +138,20 @@ Item {
|
||||||
UM.SimulationView.setMinimumLayer(value - range)
|
UM.SimulationView.setMinimumLayer(value - range)
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
width: sliderRoot.trackThickness - 2 * sliderRoot.trackBorderWidth
|
width: sliderRoot.trackThickness - 2 * sliderRoot.trackBorderWidth
|
||||||
height: parent.height + sliderRoot.handleSize
|
height: parent.height + sliderRoot.handleSize
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: sliderRoot.rangeHandleColor
|
color: sliderRoot.rangeHandleColor
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag
|
||||||
|
{
|
||||||
target: parent
|
target: parent
|
||||||
axis: Drag.YAxis
|
axis: Drag.YAxis
|
||||||
minimumY: upperHandle.height
|
minimumY: upperHandle.height
|
||||||
|
@ -141,7 +162,8 @@ Item {
|
||||||
onPressed: sliderRoot.setActiveHandle(rangeHandle)
|
onPressed: sliderRoot.setActiveHandle(rangeHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationSliderLabel {
|
SimulationSliderLabel
|
||||||
|
{
|
||||||
id: rangleHandleLabel
|
id: rangleHandleLabel
|
||||||
|
|
||||||
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
||||||
|
@ -154,12 +176,13 @@ Item {
|
||||||
maximumValue: sliderRoot.maximumValue
|
maximumValue: sliderRoot.maximumValue
|
||||||
value: sliderRoot.upperValue
|
value: sliderRoot.upperValue
|
||||||
busy: UM.SimulationView.busy
|
busy: UM.SimulationView.busy
|
||||||
setValue: rangeHandle.setValue // connect callback functions
|
setValue: rangeHandle.setValueManually // connect callback functions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upper handle
|
// Upper handle
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: upperHandle
|
id: upperHandle
|
||||||
|
|
||||||
y: sliderRoot.height - (sliderRoot.minimumRangeHandleSize + 2 * sliderRoot.handleSize)
|
y: sliderRoot.height - (sliderRoot.minimumRangeHandleSize + 2 * sliderRoot.handleSize)
|
||||||
|
@ -170,11 +193,13 @@ Item {
|
||||||
color: upperHandleLabel.activeFocus ? sliderRoot.handleActiveColor : sliderRoot.upperHandleColor
|
color: upperHandleLabel.activeFocus ? sliderRoot.handleActiveColor : sliderRoot.upperHandleColor
|
||||||
visible: sliderRoot.layersVisible
|
visible: sliderRoot.layersVisible
|
||||||
|
|
||||||
function onHandleDragged() {
|
function onHandleDragged()
|
||||||
|
{
|
||||||
sliderRoot.manuallyChanged = true
|
sliderRoot.manuallyChanged = true
|
||||||
|
|
||||||
// don't allow the lower handle to be heigher than the upper handle
|
// don't allow the lower handle to be heigher than the upper handle
|
||||||
if (lowerHandle.y - (y + height) < sliderRoot.minimumRangeHandleSize) {
|
if (lowerHandle.y - (y + height) < sliderRoot.minimumRangeHandleSize)
|
||||||
|
{
|
||||||
lowerHandle.y = y + height + sliderRoot.minimumRangeHandleSize
|
lowerHandle.y = y + height + sliderRoot.minimumRangeHandleSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,15 +211,23 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the upper value based on the slider position
|
// get the upper value based on the slider position
|
||||||
function getValue() {
|
function getValue()
|
||||||
|
{
|
||||||
var result = y / (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize))
|
var result = y / (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize))
|
||||||
result = sliderRoot.maximumValue + result * (sliderRoot.minimumValue - (sliderRoot.maximumValue - sliderRoot.minimumValue))
|
result = sliderRoot.maximumValue + result * (sliderRoot.minimumValue - (sliderRoot.maximumValue - sliderRoot.minimumValue))
|
||||||
result = sliderRoot.roundValues ? Math.round(result) : result
|
result = sliderRoot.roundValues ? Math.round(result) : result
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setValueManually(value)
|
||||||
|
{
|
||||||
|
sliderRoot.manuallyChanged = true
|
||||||
|
upperHandle.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
// set the slider position based on the upper value
|
// set the slider position based on the upper value
|
||||||
function setValue(value) {
|
function setValue(value)
|
||||||
|
{
|
||||||
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
||||||
value = sliderRoot.normalizeValue(value)
|
value = sliderRoot.normalizeValue(value)
|
||||||
|
|
||||||
|
@ -208,22 +241,16 @@ Item {
|
||||||
sliderRoot.updateRangeHandle()
|
sliderRoot.updateRangeHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onUpPressed:
|
Keys.onUpPressed: upperHandleLabel.setValue(upperHandleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
{
|
Keys.onDownPressed: upperHandleLabel.setValue(upperHandleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
sliderRoot.manuallyChanged = true
|
|
||||||
upperHandleLabel.setValue(upperHandleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
}
|
|
||||||
Keys.onDownPressed:
|
|
||||||
{
|
|
||||||
sliderRoot.manuallyChanged = true
|
|
||||||
upperHandleLabel.setValue(upperHandleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
// dragging
|
// dragging
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag
|
||||||
|
{
|
||||||
target: parent
|
target: parent
|
||||||
axis: Drag.YAxis
|
axis: Drag.YAxis
|
||||||
minimumY: 0
|
minimumY: 0
|
||||||
|
@ -231,13 +258,15 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChanged: parent.onHandleDragged()
|
onPositionChanged: parent.onHandleDragged()
|
||||||
onPressed: {
|
onPressed:
|
||||||
|
{
|
||||||
sliderRoot.setActiveHandle(upperHandle)
|
sliderRoot.setActiveHandle(upperHandle)
|
||||||
upperHandleLabel.forceActiveFocus()
|
upperHandleLabel.forceActiveFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationSliderLabel {
|
SimulationSliderLabel
|
||||||
|
{
|
||||||
id: upperHandleLabel
|
id: upperHandleLabel
|
||||||
|
|
||||||
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
||||||
|
@ -250,12 +279,13 @@ Item {
|
||||||
maximumValue: sliderRoot.maximumValue
|
maximumValue: sliderRoot.maximumValue
|
||||||
value: sliderRoot.upperValue
|
value: sliderRoot.upperValue
|
||||||
busy: UM.SimulationView.busy
|
busy: UM.SimulationView.busy
|
||||||
setValue: upperHandle.setValue // connect callback functions
|
setValue: upperHandle.setValueManually // connect callback functions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lower handle
|
// Lower handle
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: lowerHandle
|
id: lowerHandle
|
||||||
|
|
||||||
y: sliderRoot.height - sliderRoot.handleSize
|
y: sliderRoot.height - sliderRoot.handleSize
|
||||||
|
@ -267,11 +297,13 @@ Item {
|
||||||
|
|
||||||
visible: sliderRoot.layersVisible
|
visible: sliderRoot.layersVisible
|
||||||
|
|
||||||
function onHandleDragged() {
|
function onHandleDragged()
|
||||||
|
{
|
||||||
sliderRoot.manuallyChanged = true
|
sliderRoot.manuallyChanged = true
|
||||||
|
|
||||||
// don't allow the upper handle to be lower than the lower handle
|
// don't allow the upper handle to be lower than the lower handle
|
||||||
if (y - (upperHandle.y + upperHandle.height) < sliderRoot.minimumRangeHandleSize) {
|
if (y - (upperHandle.y + upperHandle.height) < sliderRoot.minimumRangeHandleSize)
|
||||||
|
{
|
||||||
upperHandle.y = y - (upperHandle.heigth + sliderRoot.minimumRangeHandleSize)
|
upperHandle.y = y - (upperHandle.heigth + sliderRoot.minimumRangeHandleSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,15 +315,24 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the lower value from the current slider position
|
// get the lower value from the current slider position
|
||||||
function getValue() {
|
function getValue()
|
||||||
|
{
|
||||||
var result = (y - (sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize)) / (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize));
|
var result = (y - (sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize)) / (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize));
|
||||||
result = sliderRoot.maximumValue - sliderRoot.minimumRange + result * (sliderRoot.minimumValue - (sliderRoot.maximumValue - sliderRoot.minimumRange))
|
result = sliderRoot.maximumValue - sliderRoot.minimumRange + result * (sliderRoot.minimumValue - (sliderRoot.maximumValue - sliderRoot.minimumRange))
|
||||||
result = sliderRoot.roundValues ? Math.round(result) : result
|
result = sliderRoot.roundValues ? Math.round(result) : result
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setValueManually(value)
|
||||||
|
{
|
||||||
|
sliderRoot.manuallyChanged = true
|
||||||
|
lowerHandle.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
// set the slider position based on the lower value
|
// set the slider position based on the lower value
|
||||||
function setValue(value) {
|
function setValue(value)
|
||||||
|
{
|
||||||
|
|
||||||
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
||||||
value = sliderRoot.normalizeValue(value)
|
value = sliderRoot.normalizeValue(value)
|
||||||
|
|
||||||
|
@ -309,10 +350,12 @@ Item {
|
||||||
Keys.onDownPressed: lowerHandleLabel.setValue(lowerHandleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
Keys.onDownPressed: lowerHandleLabel.setValue(lowerHandleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
|
|
||||||
// dragging
|
// dragging
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag
|
||||||
|
{
|
||||||
target: parent
|
target: parent
|
||||||
axis: Drag.YAxis
|
axis: Drag.YAxis
|
||||||
minimumY: upperHandle.height + sliderRoot.minimumRangeHandleSize
|
minimumY: upperHandle.height + sliderRoot.minimumRangeHandleSize
|
||||||
|
@ -320,13 +363,15 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChanged: parent.onHandleDragged()
|
onPositionChanged: parent.onHandleDragged()
|
||||||
onPressed: {
|
onPressed:
|
||||||
|
{
|
||||||
sliderRoot.setActiveHandle(lowerHandle)
|
sliderRoot.setActiveHandle(lowerHandle)
|
||||||
lowerHandleLabel.forceActiveFocus()
|
lowerHandleLabel.forceActiveFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationSliderLabel {
|
SimulationSliderLabel
|
||||||
|
{
|
||||||
id: lowerHandleLabel
|
id: lowerHandleLabel
|
||||||
|
|
||||||
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
||||||
|
@ -339,7 +384,7 @@ Item {
|
||||||
maximumValue: sliderRoot.maximumValue
|
maximumValue: sliderRoot.maximumValue
|
||||||
value: sliderRoot.lowerValue
|
value: sliderRoot.lowerValue
|
||||||
busy: UM.SimulationView.busy
|
busy: UM.SimulationView.busy
|
||||||
setValue: lowerHandle.setValue // connect callback functions
|
setValue: lowerHandle.setValueManually // connect callback functions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,8 @@ 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 {
|
Item
|
||||||
|
{
|
||||||
id: sliderRoot
|
id: sliderRoot
|
||||||
|
|
||||||
// handle properties
|
// handle properties
|
||||||
|
@ -36,25 +37,30 @@ Item {
|
||||||
property bool pathsVisible: true
|
property bool pathsVisible: true
|
||||||
property bool manuallyChanged: true // Indicates whether the value was changed manually or during simulation
|
property bool manuallyChanged: true // Indicates whether the value was changed manually or during simulation
|
||||||
|
|
||||||
function getHandleValueFromSliderHandle () {
|
function getHandleValueFromSliderHandle()
|
||||||
|
{
|
||||||
return handle.getValue()
|
return handle.getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
function setHandleValue (value) {
|
function setHandleValue(value)
|
||||||
|
{
|
||||||
handle.setValue(value)
|
handle.setValue(value)
|
||||||
updateRangeHandle()
|
updateRangeHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRangeHandle () {
|
function updateRangeHandle()
|
||||||
|
{
|
||||||
rangeHandle.width = handle.x - sliderRoot.handleSize
|
rangeHandle.width = handle.x - sliderRoot.handleSize
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeValue(value) {
|
function normalizeValue(value)
|
||||||
|
{
|
||||||
return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue)
|
return Math.min(Math.max(value, sliderRoot.minimumValue), sliderRoot.maximumValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// slider track
|
// slider track
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: track
|
id: track
|
||||||
|
|
||||||
width: sliderRoot.width - sliderRoot.handleSize
|
width: sliderRoot.width - sliderRoot.handleSize
|
||||||
|
@ -68,7 +74,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress indicator
|
// Progress indicator
|
||||||
Item {
|
Item
|
||||||
|
{
|
||||||
id: rangeHandle
|
id: rangeHandle
|
||||||
|
|
||||||
x: handle.width
|
x: handle.width
|
||||||
|
@ -77,7 +84,8 @@ Item {
|
||||||
anchors.verticalCenter: sliderRoot.verticalCenter
|
anchors.verticalCenter: sliderRoot.verticalCenter
|
||||||
visible: sliderRoot.pathsVisible
|
visible: sliderRoot.pathsVisible
|
||||||
|
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
height: sliderRoot.trackThickness - 2 * sliderRoot.trackBorderWidth
|
height: sliderRoot.trackThickness - 2 * sliderRoot.trackBorderWidth
|
||||||
width: parent.width + sliderRoot.handleSize
|
width: parent.width + sliderRoot.handleSize
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -86,7 +94,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle
|
// Handle
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: handle
|
id: handle
|
||||||
|
|
||||||
x: sliderRoot.handleSize
|
x: sliderRoot.handleSize
|
||||||
|
@ -97,7 +106,8 @@ Item {
|
||||||
color: handleLabel.activeFocus ? sliderRoot.handleActiveColor : sliderRoot.handleColor
|
color: handleLabel.activeFocus ? sliderRoot.handleActiveColor : sliderRoot.handleColor
|
||||||
visible: sliderRoot.pathsVisible
|
visible: sliderRoot.pathsVisible
|
||||||
|
|
||||||
function onHandleDragged () {
|
function onHandleDragged()
|
||||||
|
{
|
||||||
sliderRoot.manuallyChanged = true
|
sliderRoot.manuallyChanged = true
|
||||||
|
|
||||||
// update the range handle
|
// update the range handle
|
||||||
|
@ -108,15 +118,23 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the value based on the slider position
|
// get the value based on the slider position
|
||||||
function getValue () {
|
function getValue()
|
||||||
|
{
|
||||||
var result = x / (sliderRoot.width - sliderRoot.handleSize)
|
var result = x / (sliderRoot.width - sliderRoot.handleSize)
|
||||||
result = result * sliderRoot.maximumValue
|
result = result * sliderRoot.maximumValue
|
||||||
result = sliderRoot.roundValues ? Math.round(result) : result
|
result = sliderRoot.roundValues ? Math.round(result) : result
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setValueManually(value)
|
||||||
|
{
|
||||||
|
sliderRoot.manuallyChanged = true
|
||||||
|
handle.setValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
// set the slider position based on the value
|
// set the slider position based on the value
|
||||||
function setValue (value) {
|
function setValue(value)
|
||||||
|
{
|
||||||
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
// Normalize values between range, since using arrow keys will create out-of-the-range values
|
||||||
value = sliderRoot.normalizeValue(value)
|
value = sliderRoot.normalizeValue(value)
|
||||||
|
|
||||||
|
@ -130,35 +148,27 @@ Item {
|
||||||
sliderRoot.updateRangeHandle()
|
sliderRoot.updateRangeHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onRightPressed:
|
Keys.onRightPressed: handleLabel.setValue(handleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
{
|
Keys.onLeftPressed: handleLabel.setValue(handleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
||||||
sliderRoot.manuallyChanged = true
|
|
||||||
handleLabel.setValue(handleLabel.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
}
|
|
||||||
Keys.onLeftPressed:
|
|
||||||
{
|
|
||||||
sliderRoot.manuallyChanged = true
|
|
||||||
handleLabel.setValue(handleLabel.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
// dragging
|
// dragging
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag
|
||||||
|
{
|
||||||
target: parent
|
target: parent
|
||||||
axis: Drag.XAxis
|
axis: Drag.XAxis
|
||||||
minimumX: 0
|
minimumX: 0
|
||||||
maximumX: sliderRoot.width - sliderRoot.handleSize
|
maximumX: sliderRoot.width - sliderRoot.handleSize
|
||||||
}
|
}
|
||||||
onPressed: {
|
onPressed: handleLabel.forceActiveFocus()
|
||||||
handleLabel.forceActiveFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: parent.onHandleDragged()
|
onPositionChanged: parent.onHandleDragged()
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationSliderLabel {
|
SimulationSliderLabel
|
||||||
|
{
|
||||||
id: handleLabel
|
id: handleLabel
|
||||||
|
|
||||||
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
height: sliderRoot.handleSize + UM.Theme.getSize("default_margin").height
|
||||||
|
@ -172,7 +182,7 @@ Item {
|
||||||
maximumValue: sliderRoot.maximumValue
|
maximumValue: sliderRoot.maximumValue
|
||||||
value: sliderRoot.handleValue
|
value: sliderRoot.handleValue
|
||||||
busy: UM.SimulationView.busy
|
busy: UM.SimulationView.busy
|
||||||
setValue: handle.setValue // connect callback functions
|
setValue: handle.setValueManually // connect callback functions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue