Example #1
0
void LLPanelDisplay::updateSliderText(LLUICtrl* ctrl, void* user_data)
{
	// get our UI widgets
	LLTextBox* text_box = (LLTextBox*)user_data;
	LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
	if(text_box == NULL || slider == NULL)
	{
		return;
	}

	// get range and points when text should change
	F32 range = slider->getMaxValue() - slider->getMinValue();
	llassert(range > 0);
	F32 midPoint = slider->getMinValue() + range / 3.0f;
	F32 highPoint = slider->getMinValue() + (2.0f * range / 3.0f);

	// choose the right text
	if(slider->getValueF32() < midPoint)
	{
		text_box->setText(std::string("Low"));
	} 
	else if (slider->getValueF32() < highPoint)
	{
		text_box->setText(std::string("Mid"));
	}
	else
	{
		text_box->setText(std::string("High"));
	}
}
void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata )
{
	LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata;

	F32 elapsed_time = self->mMouseDownTimer.getElapsedTimeF32();

	if (isAgentAvatarValid())
	{
		LLVisualParamHint* hint = self->mHintMax;

		if (elapsed_time < PARAM_STEP_TIME_THRESHOLD)
		{
			// step in direction
			F32 current_weight = self->mWearable->getVisualParamWeight( hint->getVisualParam()->getID() );
			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->weightToPercent(new_weight);
			LLSliderCtrl* slider = self->getChild<LLSliderCtrl>("param slider");
			if (slider)
			{
				if (slider->getMinValue() < new_percent
					&& new_percent < slider->getMaxValue())
				{
					self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight, FALSE);
					self->mWearable->writeToAvatar();
					slider->setValue( self->weightToPercent( new_weight ) );
				}
			}
		}
	}

	LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax );
}
void LLScrollingPanelParam::onHintHeldDown( bool max )
{
	LLVisualParamHint* hint = max ? mHintMax : mHintMin;
	LLViewerVisualParam* param = hint->getVisualParam();

	if(!mWearable || !param)
	{
		return;
	}

	F32 current_weight = mWearable->getVisualParamWeight( param->getID() );

	if (current_weight != hint->getVisualParamWeight() )
	{
		const F32 FULL_BLEND_TIME = 2.f;
		F32 elapsed_time = mMouseDownTimer.getElapsedTimeF32() - mLastHeldTime;
		mLastHeldTime += elapsed_time;

		F32 new_weight;
		if (current_weight > hint->getVisualParamWeight() )
		{
			new_weight = current_weight - (elapsed_time / FULL_BLEND_TIME);
		}
		else
		{
			new_weight = current_weight + (elapsed_time / FULL_BLEND_TIME);
		}

		// Make sure we're not taking the slider out of bounds
		// (this is where some simple UI limits are stored)
		F32 new_percent = weightToPercent(new_weight);
		LLSliderCtrl* slider = getChild<LLSliderCtrl>("param slider");
		if (slider)
		{
			if (slider->getMinValue() < new_percent
				&& new_percent < slider->getMaxValue())
			{
				mWearable->setVisualParamWeight(param->getID(), new_weight, FALSE);
				mWearable->writeToAvatar();
				gAgentAvatarp->updateVisualParams();

				slider->setValue( weightToPercent( new_weight ) );
			}
		}
	}
}
void LLScrollingPanelParam::onHintMouseUp( bool max )
{
	F32 elapsed_time = mMouseDownTimer.getElapsedTimeF32();

	if (isAgentAvatarValid())
	{
		LLVisualParamHint* hint			= max ? mHintMax : mHintMin;

		if (elapsed_time < PARAM_STEP_TIME_THRESHOLD)
		{
			LLViewerVisualParam* param = hint->getVisualParam();

			if(mWearable)
			{
				// step in direction
				F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
				F32 range = mHintMax->getVisualParamWeight() - mHintMin->getVisualParamWeight();
				//if min, range should be negative.
				if(!max)
					range *= -1.f;
				// step a fraction in the negative direction
				F32 new_weight = current_weight + (range / 10.f);
				F32 new_percent = weightToPercent(new_weight);
				LLSliderCtrl* slider = getChild<LLSliderCtrl>("param slider");
				if (slider)
				{
					if (slider->getMinValue() < new_percent
						&& new_percent < slider->getMaxValue())
					{
						mWearable->setVisualParamWeight(param->getID(), new_weight, FALSE);
						mWearable->writeToAvatar();
						slider->setValue( weightToPercent( new_weight ) );
					}
				}
			}
		}
	}

	LLVisualParamHint::requestHintUpdates( mHintMin, mHintMax );
}