summaryrefslogtreecommitdiff
path: root/indra/llui/llmultislider.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-02-25 18:59:43 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-02-25 20:13:05 +0200
commitdb2c32285b95d3517ebcd1dbf84faa2872ab6428 (patch)
tree7d09897627402abd6c6ebe694941eaf8f81e598f /indra/llui/llmultislider.cpp
parentd16a79fc4c5d5af016db6c97efc3a7b2d08f62ce (diff)
SL-12591 Fixed slider value comparison
Diffstat (limited to 'indra/llui/llmultislider.cpp')
-rw-r--r--indra/llui/llmultislider.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp
index fbe0d3f065..acfe4a0cba 100644
--- a/indra/llui/llmultislider.cpp
+++ b/indra/llui/llmultislider.cpp
@@ -149,6 +149,16 @@ LLMultiSlider::~LLMultiSlider()
delete mMouseUpSignal;
}
+F32 LLMultiSlider::getNearestIncrement(F32 value) const
+{
+ value = llclamp(value, mMinValue, mMaxValue);
+
+ // Round to nearest increment (bias towards rounding down)
+ value -= mMinValue;
+ value += mIncrement / 2.0001f;
+ value -= fmod(value, mIncrement);
+ return mMinValue + value;
+}
void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event)
{
@@ -157,13 +167,7 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from
return;
}
- value = llclamp( value, mMinValue, mMaxValue );
-
- // Round to nearest increment (bias towards rounding down)
- value -= mMinValue;
- value += mIncrement/2.0001f;
- value -= fmod(value, mIncrement);
- F32 newValue = mMinValue + value;
+ F32 newValue = getNearestIncrement(value);
// now, make sure no overlap
// if we want that