Intermediate step in refactoring appearance panel
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLSCROLLINGPANELLIST_H
|
||||
#define LL_LLSCROLLINGPANELLIST_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "llui.h"
|
||||
@@ -56,6 +59,8 @@ public:
|
||||
LLScrollingPanelList(const std::string& name, const LLRect& rect)
|
||||
: LLUICtrl(name, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {}
|
||||
|
||||
typedef std::deque<LLScrollingPanel*> panel_list_t;
|
||||
|
||||
virtual void setValue(const LLSD& value) {};
|
||||
|
||||
virtual void draw();
|
||||
@@ -64,11 +69,16 @@ public:
|
||||
void addPanel( LLScrollingPanel* panel );
|
||||
void updatePanels(BOOL allow_modify);
|
||||
|
||||
const panel_list_t& getPanelList() { return mPanelList; }
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
|
||||
private:
|
||||
void updatePanelVisiblilty();
|
||||
|
||||
std::deque<LLScrollingPanel*> mPanelList;
|
||||
|
||||
panel_list_t mPanelList;
|
||||
};
|
||||
|
||||
#endif //LL_LLSCROLLINGPANELLIST_H
|
||||
|
||||
@@ -341,6 +341,7 @@ set(viewer_SOURCE_FILES
|
||||
llpanelavatar.cpp
|
||||
llpanelclassified.cpp
|
||||
llpanelcontents.cpp
|
||||
llpaneleditwearable.cpp
|
||||
llpaneldebug.cpp
|
||||
llpaneldirbrowser.cpp
|
||||
llpaneldirclassified.cpp
|
||||
@@ -404,6 +405,8 @@ set(viewer_SOURCE_FILES
|
||||
llregionposition.cpp
|
||||
llremoteparcelrequest.cpp
|
||||
llsavedsettingsglue.cpp
|
||||
llscrollingpanelparam.cpp
|
||||
llscrollingpanelparambase.cpp
|
||||
llselectmgr.cpp
|
||||
llsky.cpp
|
||||
llspatialpartition.cpp
|
||||
@@ -833,6 +836,7 @@ set(viewer_HEADER_FILES
|
||||
llpanelavatar.h
|
||||
llpanelclassified.h
|
||||
llpanelcontents.h
|
||||
llpaneleditwearable.h
|
||||
llpaneldebug.h
|
||||
llpaneldirbrowser.h
|
||||
llpaneldirclassified.h
|
||||
@@ -898,6 +902,8 @@ set(viewer_HEADER_FILES
|
||||
llremoteparcelrequest.h
|
||||
llresourcedata.h
|
||||
llsavedsettingsglue.h
|
||||
llscrollingpanelparam.h
|
||||
llscrollingpanelparambase.h
|
||||
llselectmgr.h
|
||||
llsky.h
|
||||
llspatialpartition.h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -91,7 +91,6 @@ public:
|
||||
void generateVisualParamHints(LLViewerJointMesh* joint_mesh,
|
||||
param_map& params, bool bVisualHint);
|
||||
|
||||
const std::string& getEditGroup();
|
||||
void updateScrollingPanelList(BOOL allow_modify);
|
||||
|
||||
void setWearable(LLWearableType::EType type, LLWearable* wearable, U32 perm_mask, BOOL is_complete);
|
||||
|
||||
1405
indra/newview/llpaneleditwearable.cpp
Normal file
1405
indra/newview/llpaneleditwearable.cpp
Normal file
File diff suppressed because it is too large
Load Diff
114
indra/newview/llpaneleditwearable.h
Normal file
114
indra/newview/llpaneleditwearable.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file llpaneleditwearable.h
|
||||
* @brief A LLPanel dedicated to the editing of wearables.
|
||||
*
|
||||
* $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$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPANELEDITWEARABLE_H
|
||||
#define LL_LLPANELEDITWEARABLE_H
|
||||
|
||||
#include "llpanel.h"
|
||||
#include "llscrollingpanellist.h"
|
||||
#include "llmodaldialog.h"
|
||||
#include "llvoavatardefines.h"
|
||||
#include "llwearabletype.h"
|
||||
|
||||
class LLAccordionCtrl;
|
||||
class LLCheckBoxCtrl;
|
||||
class LLWearable;
|
||||
class LLTextBox;
|
||||
class LLViewerInventoryItem;
|
||||
class LLViewerVisualParam;
|
||||
class LLVisualParamHint;
|
||||
class LLViewerJointMesh;
|
||||
class LLAccordionCtrlTab;
|
||||
class LLJoint;
|
||||
class LLLineEditor;
|
||||
class LLSubpart;
|
||||
class LLWearableSaveAsDialog;
|
||||
|
||||
enum ESubpart;
|
||||
using namespace LLVOAvatarDefines;
|
||||
|
||||
class LLPanelEditWearable : public LLPanel
|
||||
{
|
||||
public:
|
||||
LLPanelEditWearable( LLWearableType::EType type );
|
||||
virtual ~LLPanelEditWearable();
|
||||
|
||||
virtual BOOL postBuild();
|
||||
virtual void draw();
|
||||
virtual BOOL isDirty() const; // LLUICtrl
|
||||
|
||||
void addTextureDropTarget( ETextureIndex te, const std::string& name, const LLUUID& default_image_id, BOOL allow_no_texture );
|
||||
void addInvisibilityCheckbox(ETextureIndex te, const std::string& name);
|
||||
|
||||
const std::string& getLabel() { return LLWearableType::getTypeLabel( mType ); }
|
||||
LLWearableType::EType getType() const{ return mType; }
|
||||
LLWearable* getWearable() const;
|
||||
|
||||
ESubpart getDefaultSubpart();
|
||||
void setSubpart( ESubpart subpart );
|
||||
void switchToDefaultSubpart();
|
||||
|
||||
void setWearable(LLWearable* wearable, U32 perm_mask, BOOL is_complete);
|
||||
|
||||
void setUIPermissions(U32 perm_mask, BOOL is_complete);
|
||||
|
||||
void hideTextureControls();
|
||||
bool textureIsInvisible(ETextureIndex te);
|
||||
void initPreviousTextureList();
|
||||
void initPreviousTextureListEntry(ETextureIndex te);
|
||||
|
||||
static void onRevertButtonClicked( void* userdata );
|
||||
void onCommitSexChange();
|
||||
|
||||
virtual void setVisible( BOOL visible );
|
||||
|
||||
// Callbacks
|
||||
static void onBtnSubpart( void* userdata );
|
||||
static void onBtnTakeOff( void* userdata );
|
||||
static void onBtnSave( void* userdata );
|
||||
|
||||
static void onBtnSaveAs( void* userdata );
|
||||
static void onSaveAsCommit( LLWearableSaveAsDialog* save_as_dialog, void* userdata );
|
||||
|
||||
static void onBtnTakeOffDialog( S32 option, void* userdata );
|
||||
static void onBtnCreateNew( void* userdata );
|
||||
static void onInvisibilityCommit( LLUICtrl* ctrl, void* userdata );
|
||||
static bool onSelectAutoWearOption(const LLSD& notification, const LLSD& response);
|
||||
|
||||
|
||||
|
||||
void onColorSwatchCommit(const LLUICtrl*);
|
||||
void onTexturePickerCommit(const LLUICtrl*);
|
||||
private:
|
||||
|
||||
LLWearableType::EType mType;
|
||||
BOOL mCanTakeOff;
|
||||
std::map<std::string, S32> mInvisibilityList;
|
||||
std::map<S32, LLUUID> mPreviousTextureList;
|
||||
ESubpart mCurrentSubpart;
|
||||
};
|
||||
|
||||
#endif
|
||||
329
indra/newview/llscrollingpanelparam.cpp
Normal file
329
indra/newview/llscrollingpanelparam.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
/**
|
||||
* @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"
|
||||
#include "llagentwearables.h"
|
||||
#include "llfloatercustomize.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;
|
||||
|
||||
const S32 BTN_BORDER = 2;
|
||||
const S32 PARAM_HINT_LABEL_HEIGHT = 16;
|
||||
const S32 PARAM_PANEL_WIDTH = 2 * (3* BTN_BORDER + LLScrollingPanelParam::PARAM_HINT_WIDTH + LLPANEL_BORDER_WIDTH);
|
||||
const S32 PARAM_PANEL_HEIGHT = 2 * BTN_BORDER + LLScrollingPanelParam::PARAM_HINT_HEIGHT + PARAM_HINT_LABEL_HEIGHT + 4 * LLPANEL_BORDER_WIDTH;
|
||||
|
||||
// LLScrollingPanelParam
|
||||
//static
|
||||
S32 LLScrollingPanelParam::sUpdateDelayFrames = 0;
|
||||
|
||||
LLScrollingPanelParam::LLScrollingPanelParam( const std::string& name,
|
||||
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, bool bVisualHint )
|
||||
: LLScrollingPanelParamBase( name, mesh, param, allow_modify, bVisualHint, LLRect( 0, PARAM_PANEL_HEIGHT, PARAM_PANEL_WIDTH, 0 )),
|
||||
mLess(NULL),
|
||||
mMore(NULL)
|
||||
{
|
||||
|
||||
if(bVisualHint)
|
||||
{
|
||||
S32 pos_x = 2 * LLPANEL_BORDER_WIDTH;
|
||||
S32 pos_y = 3 * LLPANEL_BORDER_WIDTH + SLIDERCTRL_HEIGHT;
|
||||
F32 min_weight = param->getMinWeight();
|
||||
F32 max_weight = param->getMaxWeight();
|
||||
|
||||
mHintMin = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, param, min_weight);
|
||||
pos_x += PARAM_HINT_WIDTH + 3 * BTN_BORDER;
|
||||
mHintMax = new LLVisualParamHint( pos_x, pos_y, PARAM_HINT_WIDTH, PARAM_HINT_HEIGHT, mesh, param, max_weight );
|
||||
|
||||
mHintMin->setAllowsUpdates( FALSE );
|
||||
mHintMax->setAllowsUpdates( FALSE );
|
||||
|
||||
// *TODO::translate
|
||||
std::string min_name = param->getMinDisplayName();
|
||||
std::string max_name = param->getMaxDisplayName();
|
||||
childSetValue("min param text", min_name);
|
||||
childSetValue("max param text", max_name);
|
||||
mLess = getChild<LLButton>("less");
|
||||
mLess->setMouseDownCallback( boost::bind(&LLScrollingPanelParam::onHintMouseDown, this, false) );
|
||||
mLess->setMouseUpCallback( boost::bind(&LLScrollingPanelParam::onHintMouseUp, this, false) );
|
||||
mLess->setHeldDownCallback( boost::bind(&LLScrollingPanelParam::onHintHeldDown, this, false) );
|
||||
mLess->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD );
|
||||
|
||||
mMore = getChild<LLButton>("more");
|
||||
mMore->setMouseDownCallback( boost::bind(&LLScrollingPanelParam::onHintMouseDown, this, true) );
|
||||
mMore->setMouseUpCallback( boost::bind(&LLScrollingPanelParam::onHintMouseUp, this, true) );
|
||||
mMore->setHeldDownCallback( boost::bind(&LLScrollingPanelParam::onHintHeldDown, this, true) );
|
||||
mMore->setHeldDownDelay( PARAM_STEP_TIME_THRESHOLD );
|
||||
}
|
||||
|
||||
setVisible(FALSE);
|
||||
setBorderVisible( FALSE );
|
||||
}
|
||||
|
||||
LLScrollingPanelParam::~LLScrollingPanelParam()
|
||||
{
|
||||
mHintMin = NULL;
|
||||
mHintMax = NULL;
|
||||
}
|
||||
|
||||
void LLScrollingPanelParam::updatePanel(BOOL allow_modify)
|
||||
{
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)mParam->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
|
||||
if(!wearable)
|
||||
{
|
||||
// not editing a wearable just now, no update necessary
|
||||
return;
|
||||
}
|
||||
|
||||
LLScrollingPanelParamBase::updatePanel(allow_modify);
|
||||
|
||||
if(mHintMin)
|
||||
mHintMin->requestUpdate( sUpdateDelayFrames++ );
|
||||
if(mHintMax)
|
||||
mHintMax->requestUpdate( sUpdateDelayFrames++ );
|
||||
|
||||
if(mLess)
|
||||
mLess->setEnabled(mAllowModify);
|
||||
if(mMore)
|
||||
mMore->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()
|
||||
{
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)mParam->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
|
||||
if( !wearable || gFloaterCustomize->isMinimized() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(mLess)
|
||||
mLess->setVisible(mHintMin && mHintMin->getVisible());
|
||||
if(mMore)
|
||||
mMore->setVisible(mHintMax && mHintMax->getVisible());
|
||||
|
||||
// Draw all the children except for the labels
|
||||
childSetVisible( "min param text", FALSE );
|
||||
childSetVisible( "max param text", FALSE );
|
||||
LLPanel::draw();
|
||||
|
||||
// Draw the hints over the "less" and "more" buttons.
|
||||
if(mHintMin)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
const LLRect& r = mHintMin->getRect();
|
||||
F32 left = (F32)(r.mLeft + BTN_BORDER);
|
||||
F32 bot = (F32)(r.mBottom + BTN_BORDER);
|
||||
gGL.translatef(left, bot, 0.f);
|
||||
mHintMin->draw();
|
||||
}
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
if(mHintMax)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
const LLRect& r = mHintMax->getRect();
|
||||
F32 left = (F32)(r.mLeft + BTN_BORDER);
|
||||
F32 bot = (F32)(r.mBottom + BTN_BORDER);
|
||||
gGL.translatef(left, bot, 0.f);
|
||||
mHintMax->draw();
|
||||
}
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
|
||||
// Draw labels on top of the buttons
|
||||
childSetVisible( "min param text", TRUE );
|
||||
drawChild(getChild<LLView>("min param text"), BTN_BORDER, BTN_BORDER);
|
||||
|
||||
childSetVisible( "max param text", TRUE );
|
||||
drawChild(getChild<LLView>("max param text"), BTN_BORDER, BTN_BORDER);
|
||||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
||||
void LLScrollingPanelParam::onHintMouseDown( bool max )
|
||||
{
|
||||
LLVisualParamHint* hint = max ? mHintMax : mHintMin;
|
||||
LLViewerVisualParam* param = hint->getVisualParam();
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)mParam->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
|
||||
if(!wearable || !param)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// morph towards this result
|
||||
F32 current_weight = wearable->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;
|
||||
}
|
||||
}
|
||||
|
||||
void LLScrollingPanelParam::onHintHeldDown( bool max )
|
||||
{
|
||||
LLVisualParamHint* hint = max ? mHintMax : mHintMin;
|
||||
LLViewerVisualParam* param = hint->getVisualParam();
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)param->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
|
||||
if(!wearable || !param)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
F32 current_weight = wearable->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())
|
||||
{
|
||||
wearable->setVisualParamWeight(param->getID(), new_weight, FALSE);
|
||||
wearable->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();
|
||||
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)param->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
if(wearable)
|
||||
{
|
||||
// step in direction
|
||||
F32 current_weight = wearable->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())
|
||||
{
|
||||
wearable->setVisualParamWeight(param->getID(), new_weight, FALSE);
|
||||
wearable->writeToAvatar();
|
||||
slider->setValue( weightToPercent( new_weight ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LLVisualParamHint::requestHintUpdates( mHintMin, mHintMax );
|
||||
}
|
||||
|
||||
76
indra/newview/llscrollingpanelparam.h
Normal file
76
indra/newview/llscrollingpanelparam.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file llscrollingpanelparam.h
|
||||
* @brief the scrolling panel containing 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$
|
||||
*/
|
||||
|
||||
#ifndef LL_SCROLLINGPANELPARAM_H
|
||||
#define LL_SCROLLINGPANELPARAM_H
|
||||
|
||||
#include "llscrollingpanelparambase.h"
|
||||
|
||||
class LLViewerJointMesh;
|
||||
class LLViewerVisualParam;
|
||||
class LLWearable;
|
||||
class LLVisualParamHint;
|
||||
class LLViewerVisualParam;
|
||||
class LLJoint;
|
||||
|
||||
class LLScrollingPanelParam : public LLScrollingPanelParamBase
|
||||
{
|
||||
public:
|
||||
LLScrollingPanelParam( const std::string& name, LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, bool bVisualHint );
|
||||
virtual ~LLScrollingPanelParam();
|
||||
|
||||
virtual void draw();
|
||||
virtual void setVisible( BOOL visible );
|
||||
virtual void updatePanel(BOOL allow_modify);
|
||||
|
||||
static void onSliderMouseDown(LLUICtrl* ctrl, void* userdata);
|
||||
static void onSliderMouseUp(LLUICtrl* ctrl, void* userdata);
|
||||
|
||||
void onHintMouseUp( bool max );
|
||||
void onHintMouseDown( bool max );
|
||||
void onHintHeldDown( bool max );
|
||||
|
||||
public:
|
||||
// Constants for LLPanelVisualParam
|
||||
const static F32 PARAM_STEP_TIME_THRESHOLD;
|
||||
|
||||
const static S32 PARAM_HINT_WIDTH;
|
||||
const static S32 PARAM_HINT_HEIGHT;
|
||||
LLPointer<LLVisualParamHint> mHintMin;
|
||||
LLPointer<LLVisualParamHint> mHintMax;
|
||||
LLButton* mLess;
|
||||
LLButton* mMore;
|
||||
static S32 sUpdateDelayFrames;
|
||||
|
||||
protected:
|
||||
LLTimer mMouseDownTimer; // timer for how long mouse has been held down on a hint.
|
||||
F32 mLastHeldTime;
|
||||
BOOL mAllowModify;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
139
indra/newview/llscrollingpanelparambase.cpp
Normal file
139
indra/newview/llscrollingpanelparambase.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* @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 "llscrollingpanelparambase.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"
|
||||
#include "llagentwearables.h"
|
||||
|
||||
LLScrollingPanelParamBase::LLScrollingPanelParamBase( const std::string& name,
|
||||
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, bool bVisualHint, LLRect rect )
|
||||
: LLScrollingPanel( name, rect ),
|
||||
mParam(param),
|
||||
mAllowModify(allow_modify)
|
||||
{
|
||||
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_scrolling_param.xml");
|
||||
//Set up the slider
|
||||
LLSliderCtrl *slider = getChild<LLSliderCtrl>("param slider");
|
||||
|
||||
//Kill everything that isn't the slider...
|
||||
if(!bVisualHint)
|
||||
{
|
||||
child_list_t to_remove;
|
||||
child_list_t::const_iterator it;
|
||||
for (it = getChildList()->begin(); it != getChildList()->end(); it++)
|
||||
{
|
||||
if ((*it) != slider && (*it)->getName() != "panel border")
|
||||
{
|
||||
to_remove.push_back(*it);
|
||||
}
|
||||
}
|
||||
for (it = to_remove.begin(); it != to_remove.end(); it++)
|
||||
{
|
||||
removeChild(*it);
|
||||
delete (*it);
|
||||
}
|
||||
slider->translate(0,/*PARAM_HINT_HEIGHT*/128);
|
||||
reshape(getRect().getWidth(),getRect().getHeight()-128);
|
||||
}
|
||||
|
||||
slider->setValue(weightToPercent(param->getWeight()));
|
||||
slider->setLabelArg("[DESC]", param->getDisplayName());
|
||||
slider->setEnabled(mAllowModify);
|
||||
slider->setCommitCallback(boost::bind(&LLScrollingPanelParamBase::onSliderMoved, this, _1));
|
||||
|
||||
setVisible(FALSE);
|
||||
setBorderVisible( FALSE );
|
||||
}
|
||||
|
||||
LLScrollingPanelParamBase::~LLScrollingPanelParamBase()
|
||||
{
|
||||
}
|
||||
|
||||
void LLScrollingPanelParamBase::updatePanel(BOOL allow_modify)
|
||||
{
|
||||
LLViewerVisualParam* param = mParam;
|
||||
LLWearable* wearable = gAgentWearables.getWearable( (LLWearableType::EType)param->getWearableType(), 0 ); // TODO: MULTI-WEARABLE
|
||||
if(!wearable)
|
||||
{
|
||||
// not editing a wearable just now, no update necessary
|
||||
return;
|
||||
}
|
||||
|
||||
F32 current_weight = wearable->getVisualParamWeight( param->getID() );
|
||||
childSetValue("param slider", weightToPercent( current_weight ) );
|
||||
mAllowModify = allow_modify;
|
||||
childSetEnabled("param slider", mAllowModify);
|
||||
}
|
||||
|
||||
void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl)
|
||||
{
|
||||
if(!mParam)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LLWearable* wearable = gAgentWearables.getWearable( (LLWearableType::EType)mParam->getWearableType(), 0 ); // TODO: MULTI-WEARABLE
|
||||
|
||||
if(!wearable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
|
||||
|
||||
F32 current_weight = wearable->getVisualParamWeight(mParam->getID());
|
||||
F32 new_weight = percentToWeight( (F32)slider->getValue().asReal() );
|
||||
if (current_weight != new_weight )
|
||||
{
|
||||
wearable->setVisualParamWeight( mParam->getID(), new_weight, FALSE);
|
||||
wearable->writeToAvatar();
|
||||
gAgentAvatarp->updateVisualParams();
|
||||
}
|
||||
}
|
||||
|
||||
F32 LLScrollingPanelParamBase::weightToPercent( F32 weight )
|
||||
{
|
||||
LLViewerVisualParam* param = mParam;
|
||||
return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f;
|
||||
}
|
||||
|
||||
F32 LLScrollingPanelParamBase::percentToWeight( F32 percent )
|
||||
{
|
||||
LLViewerVisualParam* param = mParam;
|
||||
return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight();
|
||||
}
|
||||
61
indra/newview/llscrollingpanelparambase.h
Normal file
61
indra/newview/llscrollingpanelparambase.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file llscrollingpanelparam.h
|
||||
* @brief the scrolling panel containing 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$
|
||||
*/
|
||||
|
||||
#ifndef LL_SCROLLINGPANELPARAMBASE_H
|
||||
#define LL_SCROLLINGPANELPARAMBASE_H
|
||||
|
||||
#include "llpanel.h"
|
||||
#include "llscrollingpanellist.h"
|
||||
|
||||
class LLViewerJointMesh;
|
||||
class LLViewerVisualParam;
|
||||
class LLWearable;
|
||||
class LLVisualParamHint;
|
||||
class LLViewerVisualParam;
|
||||
class LLJoint;
|
||||
|
||||
class LLScrollingPanelParamBase : public LLScrollingPanel
|
||||
{
|
||||
public:
|
||||
LLScrollingPanelParamBase( const std::string& name,
|
||||
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, bool bVisualHint, LLRect rect );
|
||||
virtual ~LLScrollingPanelParamBase();
|
||||
|
||||
virtual void updatePanel(BOOL allow_modify);
|
||||
|
||||
void onSliderMoved(LLUICtrl* ctrl);
|
||||
|
||||
F32 weightToPercent( F32 weight );
|
||||
F32 percentToWeight( F32 percent );
|
||||
|
||||
public:
|
||||
LLViewerVisualParam* mParam;
|
||||
protected:
|
||||
BOOL mAllowModify;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "llviewerwindow.h"
|
||||
#include "llvoavatarself.h"
|
||||
#include "pipeline.h"
|
||||
#include "llagentwearables.h"
|
||||
|
||||
|
||||
//static
|
||||
@@ -152,7 +153,8 @@ BOOL LLVisualParamHint::needsRender()
|
||||
void LLVisualParamHint::preRender(BOOL clear_depth)
|
||||
{
|
||||
mLastParamWeight = mVisualParam->getWeight();
|
||||
//mWearablePtr->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE);
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)mVisualParam->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
if(wearable)wearable->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE);
|
||||
gAgentAvatarp->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE);
|
||||
gAgentAvatarp->setVisualParamWeight("Blink_Left", 0.f);
|
||||
gAgentAvatarp->setVisualParamWeight("Blink_Right", 0.f);
|
||||
@@ -252,7 +254,10 @@ BOOL LLVisualParamHint::render()
|
||||
gGL.setSceneBlendType(LLRender::BT_ALPHA);
|
||||
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
|
||||
}
|
||||
gAgentAvatarp->setVisualParamWeight(mVisualParam, mLastParamWeight);
|
||||
gAgentAvatarp->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight);
|
||||
LLWearable* wearable = gAgentWearables.getWearable((LLWearableType::EType)mVisualParam->getWearableType(),0); // TODO: MULTI-WEARABLE
|
||||
if(wearable)wearable->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight, FALSE);
|
||||
gAgentAvatarp->updateVisualParams();
|
||||
gGL.color4f(1,1,1,1);
|
||||
mGLTexturep->setGLTextureCreated(true);
|
||||
return TRUE;
|
||||
|
||||
@@ -1077,6 +1077,27 @@ void LLWearable::revertValues()
|
||||
{
|
||||
panel->updateScrollingPanelList();
|
||||
}*/
|
||||
if( gFloaterCustomize )
|
||||
{
|
||||
if(gAgentWearables.getWearableIndex(this) != 0) // TODO: MULTI-WEARABLE
|
||||
return;
|
||||
|
||||
LLViewerInventoryItem* item;
|
||||
item = (LLViewerInventoryItem*)gInventory.getItem(getItemID()); // TODO: MULTI-WEARABLE
|
||||
U32 perm_mask = PERM_NONE;
|
||||
BOOL is_complete = FALSE;
|
||||
if(item)
|
||||
{
|
||||
perm_mask = item->getPermissions().getMaskOwner();
|
||||
is_complete = item->isComplete();
|
||||
if(!is_complete)
|
||||
{
|
||||
item->fetchFromServer();
|
||||
}
|
||||
}
|
||||
gFloaterCustomize->setWearable(mType, this, perm_mask, is_complete);
|
||||
LLFloaterCustomize::setCurrentWearableType( mType );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLWearable::isOnTop() const
|
||||
@@ -1118,6 +1139,28 @@ void LLWearable::saveValues()
|
||||
{
|
||||
panel->updateScrollingPanelList();
|
||||
}*/
|
||||
if( gFloaterCustomize )
|
||||
{
|
||||
if(gAgentWearables.getWearableIndex(this) != 0) // TODO: MULTI-WEARABLE
|
||||
return;
|
||||
|
||||
LLViewerInventoryItem* item;
|
||||
item = (LLViewerInventoryItem*)gInventory.getItem(getItemID()); // TODO: MULTI-WEARABLE
|
||||
U32 perm_mask = PERM_NONE;
|
||||
BOOL is_complete = FALSE;
|
||||
if(item)
|
||||
{
|
||||
perm_mask = item->getPermissions().getMaskOwner();
|
||||
is_complete = item->isComplete();
|
||||
if(!is_complete)
|
||||
{
|
||||
item->fetchFromServer();
|
||||
}
|
||||
}
|
||||
gFloaterCustomize->setWearable(mType, this, perm_mask, is_complete);
|
||||
LLFloaterCustomize::setCurrentWearableType( mType );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LLWearable::syncImages(te_map_t &src, te_map_t &dst)
|
||||
|
||||
Reference in New Issue
Block a user