Index: sources/gui/qml/components/RangeSlider.qml =================================================================== diff -u -r533c771015857845302bcbc58b411ecef2d6ec79 -r8cc93f0b7db1cd820a8774320611dd55cfbee16e --- sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision 533c771015857845302bcbc58b411ecef2d6ec79) +++ sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision 8cc93f0b7db1cd820a8774320611dd55cfbee16e) @@ -58,6 +58,9 @@ property alias color : _rangeRect.color ///< the within range sliding color property alias bgColor : _root.color ///< the out of range sliding color + property bool minAdjusted : false ///< first time user adjustment happens + property bool maxAdjusted : false ///< first time user adjustment happens + /// root attributes clip : false @@ -69,18 +72,27 @@ /// real-time bound change should effect the current set value onMinimumChanged: { - if (minValue < minimum ) - minValue = minimum - if (maxValue < minimum ) - maxValue = minimum + if ( minValueLowerBound < minimum ) { minValueLowerBound = minimum } + if ( maxValueLowerBound < minimum ) { maxValueLowerBound = minimum } } onMaximumChanged: { - if (minValue > maximum ) - minValue = maximum - if (maxValue > maximum ) - maxValue = maximum + if ( minValueUpperBound > maximum ) { minValueUpperBound = maximum } + if ( maxValueUpperBound > maximum ) { maxValueUpperBound = maximum } } + onMinValueLowerBoundChanged: { + if ( minValue < minValueLowerBound ) { minValue = minValueLowerBound } + } + onMinValueUpperBoundChanged: { + if ( minValue > minValueUpperBound ) { minValue = minValueUpperBound } + } + onMaxValueLowerBoundChanged: { + if ( maxValue < maxValueLowerBound ) { maxValue = maxValueLowerBound } + } + onMaxValueUpperBoundChanged: { + if ( maxValue > maxValueUpperBound ) { maxValue = maxValueUpperBound } + } + /// Lable of the minimum of range minText { visible : true @@ -140,53 +152,52 @@ /// \param x : mouse x position. function setBound(x) { var value = setValue(x) - console.debug( maxValue - minValue, minValue, value, maxValue ) + // console.debug( maxValue - minValue, minValue, value, maxValue ) if ( maxValue - minValue <= gapValue ) { // max correction if the values get too close together less than defined gap - if ( curHandler === RangeSlider.HandlerOption.Max ) { - maxValue = minValue + gapValue - } + if ( curHandler === RangeSlider.HandlerOption.Max ) maxValue = minValue + gapValue // min correction if the values get too close together less than defined gap - if ( curHandler === RangeSlider.HandlerOption.Min ) { - minValue = maxValue - gapValue - } + if ( curHandler === RangeSlider.HandlerOption.Min ) minValue = maxValue - gapValue // while value is between min and max do nothing and let the value gets out of the bound and then apply value. - if ( minValue <= value && value <= maxValue ) { - return - } + if ( minValue <= value && value <= maxValue ) return } var minDiff = Math.abs(minValue - value) var maxDiff = Math.abs(maxValue - value) if ( minDiff === maxDiff ) { - if ( curHandler === RangeSlider.HandlerOption.Max ) { - if ( value < maxValueLowerBound ) { maxValue = maxValueLowerBound; return } - if ( value > maxValueUpperBound ) { maxValue = maxValueUpperBound; return } - maxValue = value - } - else { - curHandler = RangeSlider.HandlerOption.Min - if ( value < minValueLowerBound ) { minValue = minValueLowerBound; return } - if ( value > minValueUpperBound ) { minValue = minValueUpperBound; return } - minValue = value - } + if ( curHandler === RangeSlider.HandlerOption.Max ) checkLimitsMaxValueBounds(value) + else checkLimitsMinValueBounds(value) } else { - if ( minDiff < maxDiff ) { - curHandler = RangeSlider.HandlerOption.Min - if ( value < minValueLowerBound ) { minValue = minValueLowerBound; return } - if ( value > minValueUpperBound ) { minValue = minValueUpperBound; return } - minValue = value - } - else { - curHandler = RangeSlider.HandlerOption.Max - if ( value < maxValueLowerBound ) { maxValue = maxValueLowerBound; return } - if ( value > maxValueUpperBound ) { maxValue = maxValueUpperBound; return } - maxValue = value - } + if ( minDiff < maxDiff ) checkLimitsMinValueBounds(value) + else checkLimitsMaxValueBounds(value) } } + function checkLimitsMinValueBounds( vValue ) { + curHandler = RangeSlider.HandlerOption.Min + if ( vValue < minValueLowerBound ) { minValue = minValueLowerBound; return } + if ( vValue > minValueUpperBound ) { minValue = minValueUpperBound; return } + setMinvalue(vValue) + } + + function checkLimitsMaxValueBounds( vValue ) { + curHandler = RangeSlider.HandlerOption.Max + if ( vValue < maxValueLowerBound ) { maxValue = maxValueLowerBound; return } + if ( vValue > maxValueUpperBound ) { maxValue = maxValueUpperBound; return } + setMaxValue(vValue) + } + + function setMinvalue(vValue) { + minAdjusted = true + minValue = vValue + } + + function setMaxValue(vValue) { + maxAdjusted = true + maxValue = vValue + } + /// The main range rectangle bar RangeRect { id: _rangeRect property alias lowerBound : _rangeRect.minimum