diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-04-20 14:08:23 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-04-20 14:08:23 +0800 |
commit | 23a35d763bca645ce628d80ebd939c979590724c (patch) | |
tree | 434e8413c209d8a29fe93ed17ea2717817660a7e /indra/newview/llscrollingpanelparambase.cpp | |
parent | 1a4517e5af8f43433fc2547658615dce4073d9a3 (diff) | |
parent | 78174fc8658caeddfd8306ec19eb0e1c2975368e (diff) |
Merge tag '7.1.5-release'
source for viewer 7.1.5.8443591509
Diffstat (limited to 'indra/newview/llscrollingpanelparambase.cpp')
-rw-r--r-- | indra/newview/llscrollingpanelparambase.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp index fe7a362723..2a6c25235d 100644 --- a/indra/newview/llscrollingpanelparambase.cpp +++ b/indra/newview/llscrollingpanelparambase.cpp @@ -43,6 +43,7 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints) : LLScrollingPanel( panel_params ), mParam(param), + mSlider(nullptr), mAllowModify(allow_modify), mWearable(wearable) { @@ -50,13 +51,15 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan buildFromFile( "panel_scrolling_param.xml"); else buildFromFile( "panel_scrolling_param_base.xml"); - - getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight())); + + mSlider = getChild<LLSliderCtrl>("param slider"); + mSlider->setMaxValue(100.f * (mParam->getMaxWeight() - mParam->getMinWeight())); + mSlider->setValue(weightToSlider(param->getWeight())); std::string display_name = LLTrans::getString(param->getDisplayName()); - getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name); - getChildView("param slider")->setEnabled(mAllowModify); - childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this); + mSlider->setLabelArg("[DESC]", display_name); + mSlider->setEnabled(mAllowModify); + mSlider->setCommitCallback(boost::bind(LLScrollingPanelParamBase::onSliderMoved, mSlider, this)); setVisible(FALSE); setBorderVisible( FALSE ); @@ -77,9 +80,9 @@ void LLScrollingPanelParamBase::updatePanel(BOOL allow_modify) } F32 current_weight = mWearable->getVisualParamWeight( param->getID() ); - getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) ); + mSlider->setValue(weightToSlider( current_weight ) ); mAllowModify = allow_modify; - getChildView("param slider")->setEnabled(mAllowModify); + mSlider->setEnabled(mAllowModify); } // static @@ -90,7 +93,7 @@ void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata) LLViewerVisualParam* param = self->mParam; F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() ); - F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() ); + F32 new_weight = self->sliderToWeight( (F32)slider->getValue().asReal() ); if (current_weight != new_weight ) { self->mWearable->setVisualParamWeight( param->getID(), new_weight); @@ -99,14 +102,12 @@ void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata) } } -F32 LLScrollingPanelParamBase::weightToPercent( F32 weight ) +F32 LLScrollingPanelParamBase::weightToSlider(F32 weight) { - LLViewerVisualParam* param = mParam; - return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f; + return (weight - mParam->getMinWeight()) * 100.f; } -F32 LLScrollingPanelParamBase::percentToWeight( F32 percent ) +F32 LLScrollingPanelParamBase::sliderToWeight(F32 slider) { - LLViewerVisualParam* param = mParam; - return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight(); + return slider / 100.f + mParam->getMinWeight(); } |