From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/newview/llscrollingpanelparam.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscrollingpanelparam.cpp') diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index bfa453a0ae..bec7349991 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -99,7 +99,7 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param LLScrollingPanelParam::~LLScrollingPanelParam() { } -void LLScrollingPanelParam::updatePanel(BOOL allow_modify) +void LLScrollingPanelParam::updatePanel(bool allow_modify) { if (!mWearable) { @@ -114,7 +114,7 @@ void LLScrollingPanelParam::updatePanel(BOOL allow_modify) getChildView("more")->setEnabled(mAllowModify); } -void LLScrollingPanelParam::setVisible( BOOL visible ) +void LLScrollingPanelParam::setVisible( bool visible ) { if( getVisible() != visible ) { -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/newview/llscrollingpanelparam.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/newview/llscrollingpanelparam.cpp') diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index bec7349991..a77c387573 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -50,7 +50,7 @@ const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128; S32 LLScrollingPanelParam::sUpdateDelayFrames = 0; LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params, - LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints ) + LLViewerJointMesh* mesh, LLViewerVisualParam* param, bool allow_modify, LLWearable* wearable, LLJoint* jointp, bool use_hints ) : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints) { // *HACK To avoid hard coding texture position, lets use border's position for texture. @@ -66,8 +66,8 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param pos_x = getChild("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 ); + mHintMin->setAllowsUpdates( false ); + mHintMax->setAllowsUpdates( false ); std::string min_name = LLTrans::getString(param->getMinDisplayName()); std::string max_name = LLTrans::getString(param->getMaxDisplayName()); @@ -92,8 +92,8 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param more->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD ); } - setVisible(FALSE); - setBorderVisible( FALSE ); + setVisible(false); + setBorderVisible( false ); } LLScrollingPanelParam::~LLScrollingPanelParam() @@ -149,8 +149,8 @@ void LLScrollingPanelParam::draw() getChildView("right_border")->setVisible( !mHintMax->getVisible()); // Draw all the children except for the labels - getChildView("min param text")->setVisible( FALSE ); - getChildView("max param text")->setVisible( FALSE ); + getChildView("min param text")->setVisible( false ); + getChildView("max param text")->setVisible( false ); LLPanel::draw(); // If we're in a focused floater, don't apply the floater's alpha to visual param hint, @@ -176,10 +176,10 @@ void LLScrollingPanelParam::draw() // Draw labels on top of the buttons - getChildView("min param text")->setVisible( TRUE ); + getChildView("min param text")->setVisible( true ); drawChild(getChild("min param text")); - getChildView("max param text")->setVisible( TRUE ); + getChildView("max param text")->setVisible( true ); drawChild(getChild("max param text")); } -- cgit v1.2.3 From 5ac0b9debc100a5a4d14e9eaad1a6542c927a275 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 23 Mar 2024 00:17:29 +0200 Subject: viewer#951 Crash at LLScrollingPanelParam::draw I'm not sure what causes this, but 1. Calling expensive getChild inside draw is not a good idea 2. I hope that simplified draw will capture a bit more info in bugsplat or will shift callctack elsewhere --- indra/newview/llscrollingpanelparam.cpp | 71 +++++++++++++++------------------ 1 file changed, 33 insertions(+), 38 deletions(-) (limited to 'indra/newview/llscrollingpanelparam.cpp') diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index a77c387573..833eaaf8ca 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -53,44 +53,39 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param LLViewerJointMesh* mesh, LLViewerVisualParam* param, bool allow_modify, LLWearable* wearable, LLJoint* jointp, bool use_hints ) : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints) { - // *HACK To avoid hard coding texture position, lets use border's position for texture. - LLViewBorder* left_border = getChild("left_border"); - + mLessBtn = getChild("less"); + mMoreBtn = getChild("more"); + mLeftBorder = getChild("left_border"); + mRightBorder = getChild("right_border"); + mMinParamText = getChild("min param text"); + mMaxParamText = getChild("max param text"); + + // *HACK To avoid hard coding texture position, lets use border's position for texture. static LLUICachedControl slider_ctrl_height ("UISliderctrlHeight", 0); - S32 pos_x = left_border->getRect().mLeft + left_border->getBorderWidth(); - S32 pos_y = left_border->getRect().mBottom + left_border->getBorderWidth(); + S32 pos_x = mLeftBorder->getRect().mLeft + mLeftBorder->getBorderWidth(); + S32 pos_y = mLeftBorder->getRect().mBottom + mLeftBorder->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()), wearable, min_weight, jointp); - pos_x = getChild("right_border")->getRect().mLeft + left_border->getBorderWidth(); + pos_x = mRightBorder->getRect().mLeft + mLeftBorder->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 ); - std::string min_name = LLTrans::getString(param->getMinDisplayName()); - std::string max_name = LLTrans::getString(param->getMaxDisplayName()); - getChild("min param text")->setValue(min_name); - getChild("max param text")->setValue(max_name); + mMinParamText->setValue(LLTrans::getString(param->getMinDisplayName())); + mMaxParamText->setValue(LLTrans::getString(param->getMaxDisplayName())); - LLButton* less = getChild("less"); - if (less) - { - less->setMouseDownCallback( LLScrollingPanelParam::onHintMinMouseDown, this ); - less->setMouseUpCallback( LLScrollingPanelParam::onHintMinMouseUp, this ); - less->setHeldDownCallback( LLScrollingPanelParam::onHintMinHeldDown, this ); - less->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD ); - } + mLessBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMinMouseDown, this); + mLessBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMinMouseUp, this); + mLessBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMinHeldDown, this); + mLessBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); - LLButton* more = getChild("more"); - if (more) - { - more->setMouseDownCallback( LLScrollingPanelParam::onHintMaxMouseDown, this ); - more->setMouseUpCallback( LLScrollingPanelParam::onHintMaxMouseUp, this ); - more->setHeldDownCallback( LLScrollingPanelParam::onHintMaxHeldDown, this ); - more->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD ); - } + mMoreBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMaxMouseDown, this); + mMoreBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMaxMouseUp, this); + mMoreBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMaxHeldDown, this); + mMoreBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); setVisible(false); setBorderVisible( false ); @@ -110,8 +105,8 @@ void LLScrollingPanelParam::updatePanel(bool allow_modify) mHintMin->requestUpdate( sUpdateDelayFrames++ ); mHintMax->requestUpdate( sUpdateDelayFrames++ ); - getChildView("less")->setEnabled(mAllowModify); - getChildView("more")->setEnabled(mAllowModify); + mLessBtn->setEnabled(mAllowModify); + mMoreBtn->setEnabled(mAllowModify); } void LLScrollingPanelParam::setVisible( bool visible ) @@ -141,16 +136,16 @@ void LLScrollingPanelParam::draw() return; } - getChildView("less")->setVisible( mHintMin->getVisible()); - getChildView("more")->setVisible( mHintMax->getVisible()); + mLessBtn->setVisible( mHintMin->getVisible()); + mMoreBtn->setVisible( mHintMax->getVisible()); // hide borders if texture has been loaded - getChildView("left_border")->setVisible( !mHintMin->getVisible()); - getChildView("right_border")->setVisible( !mHintMax->getVisible()); + mLeftBorder->setVisible( !mHintMin->getVisible()); + mRightBorder->setVisible( !mHintMax->getVisible()); // Draw all the children except for the labels - getChildView("min param text")->setVisible( false ); - getChildView("max param text")->setVisible( false ); + mMinParamText->setVisible( false ); + mMaxParamText->setVisible( false ); LLPanel::draw(); // If we're in a focused floater, don't apply the floater's alpha to visual param hint, @@ -176,11 +171,11 @@ void LLScrollingPanelParam::draw() // Draw labels on top of the buttons - getChildView("min param text")->setVisible( true ); - drawChild(getChild("min param text")); + mMinParamText->setVisible( true ); + drawChild(mMinParamText); - getChildView("max param text")->setVisible( true ); - drawChild(getChild("max param text")); + mMaxParamText->setVisible( true ); + drawChild(mMaxParamText); } // static -- cgit v1.2.3 From a0c52be0793c353d1aec7fb1e7ad0a885a61a62b Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 15 Apr 2024 18:39:23 +0300 Subject: Revert "SL-20140 Setting shape hand size to 36 won't save" This reverts commit 810a3d24c2e3671f926091c062b101bdec6a1517. (secondlife/jira-archive-internal#70482) --- indra/newview/llscrollingpanelparam.cpp | 63 +++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'indra/newview/llscrollingpanelparam.cpp') 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("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("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("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(); +} -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/newview/llscrollingpanelparam.cpp | 706 ++++++++++++++++---------------- 1 file changed, 353 insertions(+), 353 deletions(-) (limited to 'indra/newview/llscrollingpanelparam.cpp') diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index d1d3e4f988..8dfe21e4cb 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -1,353 +1,353 @@ -/** - * @file llscrollingpanelparam.cpp - * @brief UI panel for a list of visual param panels - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llscrollingpanelparam.h" -#include "llviewerjointmesh.h" -#include "llviewervisualparam.h" -#include "llwearable.h" -#include "llviewervisualparam.h" -#include "lltoolmorph.h" -#include "lltrans.h" -#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::PARAM_HINT_WIDTH = 128; -const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128; - -// LLScrollingPanelParam -//static -S32 LLScrollingPanelParam::sUpdateDelayFrames = 0; - -LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params, - LLViewerJointMesh* mesh, LLViewerVisualParam* param, bool allow_modify, LLWearable* wearable, LLJoint* jointp, bool use_hints ) - : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints) -{ - mLessBtn = getChild("less"); - mMoreBtn = getChild("more"); - mLeftBorder = getChild("left_border"); - mRightBorder = getChild("right_border"); - mMinParamText = getChild("min param text"); - mMaxParamText = getChild("max param text"); - - // *HACK To avoid hard coding texture position, lets use border's position for texture. - static LLUICachedControl slider_ctrl_height ("UISliderctrlHeight", 0); - S32 pos_x = mLeftBorder->getRect().mLeft + mLeftBorder->getBorderWidth(); - S32 pos_y = mLeftBorder->getRect().mBottom + mLeftBorder->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()), wearable, min_weight, jointp); - pos_x = mRightBorder->getRect().mLeft + mLeftBorder->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 ); - - mMinParamText->setValue(LLTrans::getString(param->getMinDisplayName())); - mMaxParamText->setValue(LLTrans::getString(param->getMaxDisplayName())); - - mLessBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMinMouseDown, this); - mLessBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMinMouseUp, this); - mLessBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMinHeldDown, this); - mLessBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); - - mMoreBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMaxMouseDown, this); - mMoreBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMaxMouseUp, this); - mMoreBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMaxHeldDown, this); - mMoreBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); - - setVisible(false); - setBorderVisible( false ); -} - -LLScrollingPanelParam::~LLScrollingPanelParam() -{ -} -void LLScrollingPanelParam::updatePanel(bool allow_modify) -{ - if (!mWearable) - { - // not editing a wearable just now, no update necessary - return; - } - LLScrollingPanelParamBase::updatePanel(allow_modify); - - mHintMin->requestUpdate( sUpdateDelayFrames++ ); - mHintMax->requestUpdate( sUpdateDelayFrames++ ); - mLessBtn->setEnabled(mAllowModify); - mMoreBtn->setEnabled(mAllowModify); -} - -void LLScrollingPanelParam::setVisible( bool visible ) -{ - if( getVisible() != visible ) - { - LLPanel::setVisible( visible ); - if (mHintMin) - mHintMin->setAllowsUpdates( visible ); - if (mHintMax) - mHintMax->setAllowsUpdates( visible ); - - if( visible ) - { - if (mHintMin) - mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ ); - if (mHintMax) - mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ ); - } - } -} - -void LLScrollingPanelParam::draw() -{ - if( !mWearable ) - { - return; - } - - mLessBtn->setVisible( mHintMin->getVisible()); - mMoreBtn->setVisible( mHintMax->getVisible()); - - // hide borders if texture has been loaded - mLeftBorder->setVisible( !mHintMin->getVisible()); - mRightBorder->setVisible( !mHintMax->getVisible()); - - // Draw all the children except for the labels - mMinParamText->setVisible( false ); - mMaxParamText->setVisible( false ); - LLPanel::draw(); - - // If we're in a focused floater, don't apply the floater's alpha to visual param hint, - // making its behavior similar to texture controls'. - F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - - // Draw the hints over the "less" and "more" buttons. - gGL.pushUIMatrix(); - { - const LLRect& r = mHintMin->getRect(); - gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); - mHintMin->draw(alpha); - } - gGL.popUIMatrix(); - - gGL.pushUIMatrix(); - { - const LLRect& r = mHintMax->getRect(); - gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); - mHintMax->draw(alpha); - } - gGL.popUIMatrix(); - - - // Draw labels on top of the buttons - mMinParamText->setVisible( true ); - drawChild(mMinParamText); - - mMaxParamText->setVisible( true ); - drawChild(mMaxParamText); -} - -// static -void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata) -{ -} - -// static -void LLScrollingPanelParam::onSliderMouseUp(LLUICtrl* ctrl, void* userdata) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax ); -} - -// static -void LLScrollingPanelParam::onHintMinMouseDown( void* userdata ) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - self->onHintMouseDown( self->mHintMin ); -} - -// static -void LLScrollingPanelParam::onHintMaxMouseDown( void* userdata ) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - self->onHintMouseDown( self->mHintMax ); -} - - -void LLScrollingPanelParam::onHintMouseDown( LLVisualParamHint* hint ) -{ - // morph towards this result - F32 current_weight = mWearable->getVisualParamWeight( hint->getVisualParam()->getID() ); - - // if we have maxed out on this morph, we shouldn't be able to click it - if( hint->getVisualParamWeight() != current_weight ) - { - mMouseDownTimer.reset(); - mLastHeldTime = 0.f; - } -} - -// static -void LLScrollingPanelParam::onHintMinHeldDown( void* userdata ) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - self->onHintHeldDown( self->mHintMin ); -} - -// static -void LLScrollingPanelParam::onHintMaxHeldDown( void* userdata ) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - self->onHintHeldDown( self->mHintMax ); -} - -void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint ) -{ - F32 current_weight = mWearable->getVisualParamWeight( hint->getVisualParam()->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("param slider"); - if (slider) - { - if (slider->getMinValue() < new_percent - && new_percent < slider->getMaxValue()) - { - mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight); - mWearable->writeToAvatar(gAgentAvatarp); - gAgentAvatarp->updateVisualParams(); - - slider->setValue( weightToPercent( new_weight ) ); - } - } - } -} - -// static -void LLScrollingPanelParam::onHintMinMouseUp( void* userdata ) -{ - LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; - - F32 elapsed_time = self->mMouseDownTimer.getElapsedTimeF32(); - - LLVisualParamHint* hint = self->mHintMin; - - 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 directiona - F32 new_weight = current_weight - (range / 10.f); - F32 new_percent = self->weightToPercent(new_weight); - LLSliderCtrl* slider = self->getChild("param slider"); - if (slider) - { - 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 ); -} - -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("param slider"); - if (slider) - { - 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(); -} +/** + * @file llscrollingpanelparam.cpp + * @brief UI panel for a list of visual param panels + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llscrollingpanelparam.h" +#include "llviewerjointmesh.h" +#include "llviewervisualparam.h" +#include "llwearable.h" +#include "llviewervisualparam.h" +#include "lltoolmorph.h" +#include "lltrans.h" +#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::PARAM_HINT_WIDTH = 128; +const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128; + +// LLScrollingPanelParam +//static +S32 LLScrollingPanelParam::sUpdateDelayFrames = 0; + +LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params, + LLViewerJointMesh* mesh, LLViewerVisualParam* param, bool allow_modify, LLWearable* wearable, LLJoint* jointp, bool use_hints ) + : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints) +{ + mLessBtn = getChild("less"); + mMoreBtn = getChild("more"); + mLeftBorder = getChild("left_border"); + mRightBorder = getChild("right_border"); + mMinParamText = getChild("min param text"); + mMaxParamText = getChild("max param text"); + + // *HACK To avoid hard coding texture position, lets use border's position for texture. + static LLUICachedControl slider_ctrl_height ("UISliderctrlHeight", 0); + S32 pos_x = mLeftBorder->getRect().mLeft + mLeftBorder->getBorderWidth(); + S32 pos_y = mLeftBorder->getRect().mBottom + mLeftBorder->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()), wearable, min_weight, jointp); + pos_x = mRightBorder->getRect().mLeft + mLeftBorder->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 ); + + mMinParamText->setValue(LLTrans::getString(param->getMinDisplayName())); + mMaxParamText->setValue(LLTrans::getString(param->getMaxDisplayName())); + + mLessBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMinMouseDown, this); + mLessBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMinMouseUp, this); + mLessBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMinHeldDown, this); + mLessBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); + + mMoreBtn->setMouseDownCallback(LLScrollingPanelParam::onHintMaxMouseDown, this); + mMoreBtn->setMouseUpCallback(LLScrollingPanelParam::onHintMaxMouseUp, this); + mMoreBtn->setHeldDownCallback(LLScrollingPanelParam::onHintMaxHeldDown, this); + mMoreBtn->setHeldDownDelay(PARAM_STEP_TIME_THRESHOLD); + + setVisible(false); + setBorderVisible( false ); +} + +LLScrollingPanelParam::~LLScrollingPanelParam() +{ +} +void LLScrollingPanelParam::updatePanel(bool allow_modify) +{ + if (!mWearable) + { + // not editing a wearable just now, no update necessary + return; + } + LLScrollingPanelParamBase::updatePanel(allow_modify); + + mHintMin->requestUpdate( sUpdateDelayFrames++ ); + mHintMax->requestUpdate( sUpdateDelayFrames++ ); + mLessBtn->setEnabled(mAllowModify); + mMoreBtn->setEnabled(mAllowModify); +} + +void LLScrollingPanelParam::setVisible( bool visible ) +{ + if( getVisible() != visible ) + { + LLPanel::setVisible( visible ); + if (mHintMin) + mHintMin->setAllowsUpdates( visible ); + if (mHintMax) + mHintMax->setAllowsUpdates( visible ); + + if( visible ) + { + if (mHintMin) + mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ ); + if (mHintMax) + mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ ); + } + } +} + +void LLScrollingPanelParam::draw() +{ + if( !mWearable ) + { + return; + } + + mLessBtn->setVisible( mHintMin->getVisible()); + mMoreBtn->setVisible( mHintMax->getVisible()); + + // hide borders if texture has been loaded + mLeftBorder->setVisible( !mHintMin->getVisible()); + mRightBorder->setVisible( !mHintMax->getVisible()); + + // Draw all the children except for the labels + mMinParamText->setVisible( false ); + mMaxParamText->setVisible( false ); + LLPanel::draw(); + + // If we're in a focused floater, don't apply the floater's alpha to visual param hint, + // making its behavior similar to texture controls'. + F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); + + // Draw the hints over the "less" and "more" buttons. + gGL.pushUIMatrix(); + { + const LLRect& r = mHintMin->getRect(); + gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); + mHintMin->draw(alpha); + } + gGL.popUIMatrix(); + + gGL.pushUIMatrix(); + { + const LLRect& r = mHintMax->getRect(); + gGL.translateUI((F32)r.mLeft, (F32)r.mBottom, 0.f); + mHintMax->draw(alpha); + } + gGL.popUIMatrix(); + + + // Draw labels on top of the buttons + mMinParamText->setVisible( true ); + drawChild(mMinParamText); + + mMaxParamText->setVisible( true ); + drawChild(mMaxParamText); +} + +// static +void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata) +{ +} + +// static +void LLScrollingPanelParam::onSliderMouseUp(LLUICtrl* ctrl, void* userdata) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax ); +} + +// static +void LLScrollingPanelParam::onHintMinMouseDown( void* userdata ) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + self->onHintMouseDown( self->mHintMin ); +} + +// static +void LLScrollingPanelParam::onHintMaxMouseDown( void* userdata ) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + self->onHintMouseDown( self->mHintMax ); +} + + +void LLScrollingPanelParam::onHintMouseDown( LLVisualParamHint* hint ) +{ + // morph towards this result + F32 current_weight = mWearable->getVisualParamWeight( hint->getVisualParam()->getID() ); + + // if we have maxed out on this morph, we shouldn't be able to click it + if( hint->getVisualParamWeight() != current_weight ) + { + mMouseDownTimer.reset(); + mLastHeldTime = 0.f; + } +} + +// static +void LLScrollingPanelParam::onHintMinHeldDown( void* userdata ) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + self->onHintHeldDown( self->mHintMin ); +} + +// static +void LLScrollingPanelParam::onHintMaxHeldDown( void* userdata ) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + self->onHintHeldDown( self->mHintMax ); +} + +void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint ) +{ + F32 current_weight = mWearable->getVisualParamWeight( hint->getVisualParam()->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("param slider"); + if (slider) + { + if (slider->getMinValue() < new_percent + && new_percent < slider->getMaxValue()) + { + mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight); + mWearable->writeToAvatar(gAgentAvatarp); + gAgentAvatarp->updateVisualParams(); + + slider->setValue( weightToPercent( new_weight ) ); + } + } + } +} + +// static +void LLScrollingPanelParam::onHintMinMouseUp( void* userdata ) +{ + LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata; + + F32 elapsed_time = self->mMouseDownTimer.getElapsedTimeF32(); + + LLVisualParamHint* hint = self->mHintMin; + + 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 directiona + F32 new_weight = current_weight - (range / 10.f); + F32 new_percent = self->weightToPercent(new_weight); + LLSliderCtrl* slider = self->getChild("param slider"); + if (slider) + { + 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 ); +} + +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("param slider"); + if (slider) + { + 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(); +} -- cgit v1.2.3