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.cpp70
1 files changed, 37 insertions, 33 deletions
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index 7980fe1945..d715c47631 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -42,24 +42,21 @@
#include "llbutton.h"
#include "llsliderctrl.h"
#include "llagent.h"
+#include "llviewborder.h"
#include "llvoavatarself.h"
// Constants for LLPanelVisualParam
const F32 LLScrollingPanelParam::PARAM_STEP_TIME_THRESHOLD = 0.25f;
-const S32 LLScrollingPanelParam::BTN_BORDER = 2;
const S32 LLScrollingPanelParam::PARAM_HINT_WIDTH = 128;
const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128;
-const S32 LLScrollingPanelParam::PARAM_HINT_LABEL_HEIGHT = 16;
-const S32 LLScrollingPanelParam::PARAM_PANEL_WIDTH = 2 * (3* BTN_BORDER + PARAM_HINT_WIDTH + LLPANEL_BORDER_WIDTH);
-const S32 LLScrollingPanelParam::PARAM_PANEL_HEIGHT = 2 * BTN_BORDER + PARAM_HINT_HEIGHT + PARAM_HINT_LABEL_HEIGHT + 4 * LLPANEL_BORDER_WIDTH;
// LLScrollingPanelParam
//static
S32 LLScrollingPanelParam::sUpdateDelayFrames = 0;
LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params,
- LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable )
+ LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp )
: LLScrollingPanel( panel_params ),
mParam(param),
mAllowModify(allow_modify),
@@ -67,29 +64,32 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_scrolling_param.xml");
+ // *HACK To avoid hard coding texture position, lets use border's position for texture.
+ LLViewBorder* left_border = getChild<LLViewBorder>("left_border");
+
static LLUICachedControl<S32> slider_ctrl_height ("UISliderctrlHeight", 0);
- S32 pos_x = 2 * LLPANEL_BORDER_WIDTH;
- S32 pos_y = 3 * LLPANEL_BORDER_WIDTH + slider_ctrl_height;
+ S32 pos_x = left_border->getRect().mLeft + left_border->getBorderWidth();
+ S32 pos_y = left_border->getRect().mBottom + left_border->getBorderWidth();
F32 min_weight = param->getMinWeight();
F32 max_weight = param->getMaxWeight();
- mHintMin = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), min_weight);
- pos_x += PARAM_HINT_WIDTH + 3 * BTN_BORDER;
- mHintMax = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), max_weight );
+ mHintMin = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), wearable, min_weight, jointp);
+ pos_x = getChild<LLViewBorder>("right_border")->getRect().mLeft + left_border->getBorderWidth();
+ mHintMax = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, (LLViewerVisualParam*) wearable->getVisualParam(param->getID()), wearable, max_weight, jointp );
mHintMin->setAllowsUpdates( FALSE );
mHintMax->setAllowsUpdates( FALSE );
- childSetValue("param slider", weightToPercent(param->getWeight()));
+ getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
std::string display_name = LLTrans::getString(param->getDisplayName());
- childSetLabelArg("param slider", "[DESC]", display_name);
- childSetEnabled("param slider", mAllowModify);
+ getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
+ getChildView("param slider")->setEnabled(mAllowModify);
childSetCommitCallback("param slider", LLScrollingPanelParam::onSliderMoved, this);
std::string min_name = LLTrans::getString(param->getMinDisplayName());
std::string max_name = LLTrans::getString(param->getMaxDisplayName());
- childSetValue("min param text", min_name);
- childSetValue("max param text", max_name);
+ getChild<LLUICtrl>("min param text")->setValue(min_name);
+ getChild<LLUICtrl>("max param text")->setValue(max_name);
LLButton* less = getChild<LLButton>("less");
if (less)
@@ -126,14 +126,14 @@ void LLScrollingPanelParam::updatePanel(BOOL allow_modify)
return;
}
F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
- childSetValue("param slider", weightToPercent( current_weight ) );
+ getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
mHintMin->requestUpdate( sUpdateDelayFrames++ );
mHintMax->requestUpdate( sUpdateDelayFrames++ );
mAllowModify = allow_modify;
- childSetEnabled("param slider", mAllowModify);
- childSetEnabled("less", mAllowModify);
- childSetEnabled("more", mAllowModify);
+ getChildView("param slider")->setEnabled(mAllowModify);
+ getChildView("less")->setEnabled(mAllowModify);
+ getChildView("more")->setEnabled(mAllowModify);
}
void LLScrollingPanelParam::setVisible( BOOL visible )
@@ -159,21 +159,23 @@ void LLScrollingPanelParam::draw()
return;
}
- childSetVisible("less", mHintMin->getVisible());
- childSetVisible("more", mHintMax->getVisible());
+ getChildView("less")->setVisible( mHintMin->getVisible());
+ getChildView("more")->setVisible( mHintMax->getVisible());
+
+ // hide borders if texture has been loaded
+ getChildView("left_border")->setVisible( !mHintMin->getVisible());
+ getChildView("right_border")->setVisible( !mHintMax->getVisible());
// Draw all the children except for the labels
- childSetVisible( "min param text", FALSE );
- childSetVisible( "max param text", FALSE );
+ getChildView("min param text")->setVisible( FALSE );
+ getChildView("max param text")->setVisible( FALSE );
LLPanel::draw();
// Draw the hints over the "less" and "more" buttons.
gGL.pushUIMatrix();
{
const LLRect& r = mHintMin->getRect();
- F32 left = (F32)(r.mLeft + BTN_BORDER);
- F32 bot = (F32)(r.mBottom + BTN_BORDER);
- gGL.translateUI(left, bot, 0.f);
+ gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f);
mHintMin->draw();
}
gGL.popUIMatrix();
@@ -181,20 +183,18 @@ void LLScrollingPanelParam::draw()
gGL.pushUIMatrix();
{
const LLRect& r = mHintMax->getRect();
- F32 left = (F32)(r.mLeft + BTN_BORDER);
- F32 bot = (F32)(r.mBottom + BTN_BORDER);
- gGL.translateUI(left, bot, 0.f);
+ gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f);
mHintMax->draw();
}
gGL.popUIMatrix();
// Draw labels on top of the buttons
- childSetVisible( "min param text", TRUE );
- drawChild(getChild<LLView>("min param text"), BTN_BORDER, BTN_BORDER);
+ getChildView("min param text")->setVisible( TRUE );
+ drawChild(getChild<LLView>("min param text"));
- childSetVisible( "max param text", TRUE );
- drawChild(getChild<LLView>("max param text"), BTN_BORDER, BTN_BORDER);
+ getChildView("max param text")->setVisible( TRUE );
+ drawChild(getChild<LLView>("max param text"));
}
// static
@@ -209,6 +209,7 @@ void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata)
if (current_weight != new_weight )
{
self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
+ self->mWearable->writeToAvatar();
gAgentAvatarp->updateVisualParams();
}
}
@@ -298,6 +299,7 @@ void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint )
&& new_percent < slider->getMaxValue())
{
mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight, FALSE);
+ mWearable->writeToAvatar();
gAgentAvatarp->updateVisualParams();
slider->setValue( weightToPercent( new_weight ) );
@@ -330,6 +332,7 @@ void LLScrollingPanelParam::onHintMinMouseUp( void* userdata )
&& new_percent < slider->getMaxValue())
{
self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight, FALSE);
+ self->mWearable->writeToAvatar();
slider->setValue( self->weightToPercent( new_weight ) );
}
}
@@ -363,6 +366,7 @@ void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata )
&& new_percent < slider->getMaxValue())
{
self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight, FALSE);
+ self->mWearable->writeToAvatar();
slider->setValue( self->weightToPercent( new_weight ) );
}
}