summaryrefslogtreecommitdiff
path: root/indra/newview/llscrollingpanelparam.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llscrollingpanelparam.cpp')
-rw-r--r--indra/newview/llscrollingpanelparam.cpp63
1 files changed, 44 insertions, 19 deletions
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index 76340a9ea8..833eaaf8ca 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -254,15 +254,19 @@ void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint )
// Make sure we're not taking the slider out of bounds
// (this is where some simple UI limits are stored)
- F32 new_percent = weightToSlider(new_weight);
- if (mSlider->getMinValue() < new_percent
- && new_percent < mSlider->getMaxValue())
+ F32 new_percent = weightToPercent(new_weight);
+ LLSliderCtrl* slider = getChild<LLSliderCtrl>("param slider");
+ if (slider)
{
- mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight);
- mWearable->writeToAvatar(gAgentAvatarp);
- gAgentAvatarp->updateVisualParams();
+ if (slider->getMinValue() < new_percent
+ && new_percent < slider->getMaxValue())
+ {
+ mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight);
+ mWearable->writeToAvatar(gAgentAvatarp);
+ gAgentAvatarp->updateVisualParams();
- mSlider->setValue( weightToSlider( new_weight ) );
+ slider->setValue( weightToPercent( new_weight ) );
+ }
}
}
}
@@ -283,13 +287,17 @@ void LLScrollingPanelParam::onHintMinMouseUp( void* userdata )
F32 range = self->mHintMax->getVisualParamWeight() - self->mHintMin->getVisualParamWeight();
// step a fraction in the negative directiona
F32 new_weight = current_weight - (range / 10.f);
- F32 new_percent = self->weightToSlider(new_weight);
- if (self->mSlider->getMinValue() < new_percent
- && new_percent < self->mSlider->getMaxValue())
+ F32 new_percent = self->weightToPercent(new_weight);
+ LLSliderCtrl* slider = self->getChild<LLSliderCtrl>("param slider");
+ if (slider)
{
- self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight);
- self->mWearable->writeToAvatar(gAgentAvatarp);
- self->mSlider->setValue( self->weightToSlider( new_weight ) );
+ if (slider->getMinValue() < new_percent
+ && new_percent < slider->getMaxValue())
+ {
+ self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight);
+ self->mWearable->writeToAvatar(gAgentAvatarp);
+ slider->setValue( self->weightToPercent( new_weight ) );
+ }
}
}
@@ -313,16 +321,33 @@ void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata )
F32 range = self->mHintMax->getVisualParamWeight() - self->mHintMin->getVisualParamWeight();
// step a fraction in the negative direction
F32 new_weight = current_weight + (range / 10.f);
- F32 new_percent = self->weightToSlider(new_weight);
- if (self->mSlider->getMinValue() < new_percent
- && new_percent < self->mSlider->getMaxValue())
+ F32 new_percent = self->weightToPercent(new_weight);
+ LLSliderCtrl* slider = self->getChild<LLSliderCtrl>("param slider");
+ if (slider)
{
- self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight);
- self->mWearable->writeToAvatar(gAgentAvatarp);
- self->mSlider->setValue( self->weightToSlider( new_weight ) );
+ if (slider->getMinValue() < new_percent
+ && new_percent < slider->getMaxValue())
+ {
+ self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight);
+ self->mWearable->writeToAvatar(gAgentAvatarp);
+ slider->setValue( self->weightToPercent( new_weight ) );
+ }
}
}
}
LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax );
}
+
+
+F32 LLScrollingPanelParam::weightToPercent( F32 weight )
+{
+ LLViewerVisualParam* param = mParam;
+ return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f;
+}
+
+F32 LLScrollingPanelParam::percentToWeight( F32 percent )
+{
+ LLViewerVisualParam* param = mParam;
+ return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight();
+}