summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llmultislider.cpp18
-rw-r--r--indra/llui/llmultislider.h4
-rw-r--r--indra/llui/llmultisliderctrl.h1
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp9
4 files changed, 24 insertions, 8 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
diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h
index 20c3437ec4..99a78d6e09 100644
--- a/indra/llui/llmultislider.h
+++ b/indra/llui/llmultislider.h
@@ -77,6 +77,10 @@ protected:
friend class LLUICtrlFactory;
public:
virtual ~LLMultiSlider();
+
+ // Multi-slider rounds values to nearest increments (bias towards rounding down)
+ F32 getNearestIncrement(F32 value) const;
+
void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
F32 getSliderValue(const std::string& name) const;
F32 getSliderValueFromPos(S32 xpos, S32 ypos) const;
diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h
index e16737b3c7..adb28676ec 100644
--- a/indra/llui/llmultisliderctrl.h
+++ b/indra/llui/llmultisliderctrl.h
@@ -107,6 +107,7 @@ public:
void setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);}
void setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);}
+ F32 getNearestIncrement(F32 value) const { return mMultiSlider->getNearestIncrement(value); }
F32 getSliderValueFromPos(S32 x, S32 y) const { return mMultiSlider->getSliderValueFromPos(x, y); }
LLRect getSliderThumbRect(const std::string &name) const { return mMultiSlider->getSliderThumbRect(name); }
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 2c10835fb0..f57a54163d 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -991,13 +991,20 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data)
}
else
{
- if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod)
+ // slider rounds values to nearest increments, changes can be substanntial (half increment)
+ if (abs(mFramesSlider->getNearestIncrement((*it).second.mFrame) - sliderpos) < F_APPROXIMATELY_ZERO)
+ {
+ // same value
+ mFramesSlider->setCurSliderValue((*it).second.mFrame);
+ }
+ else if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod)
{
(*it).second.mFrame = sliderpos;
setDirtyFlag();
}
else
{
+ // same value, wrong track, no such value, no mod
mFramesSlider->setCurSliderValue((*it).second.mFrame);
}