Index: sources/gui/qml/components/Slider.qml =================================================================== diff -u -r0f28ae04f739c859dc850a9baa430c62251629d6 -r51c8036de03623725353aad8e913b32804e93b5e --- sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 0f28ae04f739c859dc850a9baa430c62251629d6) +++ sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 51c8036de03623725353aad8e913b32804e93b5e) @@ -38,7 +38,7 @@ property alias handler : _handler property alias handlerColor : _handler.color - property bool handlerVisible : _handler.visible + property bool handlerVisible : _handler.visible property alias diameter : _handler.diameter @@ -61,11 +61,6 @@ color = Colors.createTreatmentInactive handlerColor = Colors.createTreatmentInactive } - - if (active !== isActive) { - isActive = active; - activeChanged() - } } onIsActiveChanged: { @@ -77,8 +72,10 @@ } onValueChanged: { - // update the displayed value to the attentive snapped value - _root.displayedValue = (Math.round(_root.value / step) * step).toFixed(decimal) + if ( _root.isActive ) { + // update the displayed value to the attentive snapped value + _root.displayedValue = (Math.round(_root.value / step) * step).toFixed(decimal) + } } height : Variables.progressbarHeight @@ -117,6 +114,7 @@ function update(vValue) { _root.value = vValue + console.log("UPDATING value " + vValue) } function calculateValue(x, isSnappingToTicks) { @@ -205,6 +203,25 @@ } } + function updateHandleValue(vCurrentPositionX) + { + // Passing false for snapping to get exact value in respect to x + let newCurrentValue = calculateValue(vCurrentPositionX, false) + + // Check the cursor's current value to determine if the cursor had moved + // Do not avoid type coercion, it will produce undesired results + if(newCurrentValue != _progressRect.previousSliderValue) { + // The cursor did move + if(stepSnapOnRelease) { + // check for snapping state to save an iteration of recalculation if snap is off + newCurrentValue = calculateValue(vCurrentPositionX, stepSnapOnRelease) + } + + // Update the slider's value since the cursor did move + update(newCurrentValue) + } + } + onDragged: { // On position change / dragging, the value is updated based on value calculated // Need to account for the extended touch areas @@ -214,39 +231,28 @@ } onPressed : { - // On a pressed state, calculate and store the value of current x position - // Need to account for the extended touch areas - let adjustedXPosition = vMouseEvent.x - _progressRect.leftRightTouchMargin + if ( !isActive) { + // If the slider is not yet active, calculate and store the value of current x position + // Need to account for the extended touch areas + let adjustedXPosition = vMouseEvent.x - _progressRect.leftRightTouchMargin - // Passing false for snapping to get exact value in respect to x - let newCurrentValue = calculateValue(adjustedXPosition, false) - _progressRect.previousSliderValue = newCurrentValue + // Passing false for snapping to get exact value in respect to x + let newCurrentValue = calculateValue(adjustedXPosition, false) + _progressRect.previousSliderValue = newCurrentValue + } else { + // Need to account for the extended touch areas + updateHandleValue(vMouseEvent.x - _progressRect.leftRightTouchMargin) + } } onReleased: { - // Check the cursor's current value to determine if the cursor had moved // Need to account for the extended touch areas - let adjustedXPosition = vMouseEvent.x - _progressRect.leftRightTouchMargin - - // Passing false for snapping to get exact value in respect to x - let newCurrentValue = calculateValue(adjustedXPosition, false) - - // Do not avoid type coercion, it will produce undesired results - if(newCurrentValue != _progressRect.previousSliderValue) { - // The cursor did move - if(stepSnapOnRelease) { - // check for snapping state to save an iteration of recalculation if snap is off - newCurrentValue = calculateValue(vMouseEvent.x - _progressRect.leftRightTouchMargin, stepSnapOnRelease) - } - - // Update the slider's value since the cursor did move - update(newCurrentValue) - } - + updateHandleValue(vMouseEvent.x - _progressRect.leftRightTouchMargin) } Rectangle { id: _handler - property real diameter : Variables.progressbarHandler + property bool handleSelected : false + property real diameter : Variables.progressbarHandler anchors.verticalCenter : parent.verticalCenter anchors.horizontalCenter: _progressRect.right