Skip to content
Snippets Groups Projects
Commit a9164676 authored by Monroe Linden's avatar Monroe Linden
Browse files

Code cleanup in LLPanelEditWearable, from Nyx.

Removed the misnamed LLPanelEditWearable::initializePanel() (which was actually being called multiple times for each object), and moved its functionality to postBuild() and showWearable().
parent fbee0d8e
No related branches found
No related tags found
No related merge requests found
...@@ -520,7 +520,8 @@ static void init_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel, co ...@@ -520,7 +520,8 @@ static void init_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel, co
LLColorSwatchCtrl* color_swatch_ctrl = panel->getChild<LLColorSwatchCtrl>(entry->mControlName); LLColorSwatchCtrl* color_swatch_ctrl = panel->getChild<LLColorSwatchCtrl>(entry->mControlName);
if (color_swatch_ctrl) if (color_swatch_ctrl)
{ {
color_swatch_ctrl->setOriginal(self->getWearable()->getClothesColor(entry->mTextureIndex)); // Can't get the color from the wearable here, since the wearable may not be set when this is called.
color_swatch_ctrl->setOriginal(LLColor4::white);
} }
} }
...@@ -654,6 +655,49 @@ BOOL LLPanelEditWearable::postBuild() ...@@ -654,6 +655,49 @@ BOOL LLPanelEditWearable::postBuild()
configureAlphaCheckbox(LLVOAvatarDefines::TEX_EYES_ALPHA, "eye alpha texture invisible"); configureAlphaCheckbox(LLVOAvatarDefines::TEX_EYES_ALPHA, "eye alpha texture invisible");
configureAlphaCheckbox(LLVOAvatarDefines::TEX_HAIR_ALPHA, "hair alpha texture invisible"); configureAlphaCheckbox(LLVOAvatarDefines::TEX_HAIR_ALPHA, "hair alpha texture invisible");
// configure tab expanded callbacks
for (U32 type_index = 0; type_index < (U32)LLWearableType::WT_COUNT; ++type_index)
{
LLWearableType::EType type = (LLWearableType::EType) type_index;
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
continue;
}
U8 num_subparts = wearable_entry->mSubparts.size();
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
continue;
}
const std::string accordion_tab = subpart_entry->mAccordionTab;
LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab);
if (!tab)
{
llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
continue;
}
// initialize callback to ensure camera view changes appropriately.
tab->setDropDownStateChangedCallback(boost::bind(&LLPanelEditWearable::onTabExpandedCollapsed,this,_2,index));
}
// initialize texture and color picker controls
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (getPanel(type), type, boost::bind(init_color_swatch_ctrl, this, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (getPanel(type), type, boost::bind(init_texture_ctrl, this, _1, _2));
}
return TRUE; return TRUE;
} }
...@@ -690,10 +734,9 @@ void LLPanelEditWearable::setWearable(LLWearable *wearable) ...@@ -690,10 +734,9 @@ void LLPanelEditWearable::setWearable(LLWearable *wearable)
showWearable(mWearablePtr, FALSE); showWearable(mWearablePtr, FALSE);
mWearablePtr = wearable; mWearablePtr = wearable;
showWearable(mWearablePtr, TRUE); showWearable(mWearablePtr, TRUE);
initializePanel();
} }
//static //static
void LLPanelEditWearable::onRevertButtonClicked(void* userdata) void LLPanelEditWearable::onRevertButtonClicked(void* userdata)
{ {
...@@ -880,29 +923,83 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show) ...@@ -880,29 +923,83 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show)
std::string title; std::string title;
std::string description_title; std::string description_title;
const LLEditWearableDictionary::WearableEntry *entry = LLEditWearableDictionary::getInstance()->getWearable(type); const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!entry) if (!wearable_entry)
{ {
llwarns << "called LLPanelEditWearable::showWearable with an invalid wearable type! (" << type << ")" << llendl; llwarns << "called LLPanelEditWearable::showWearable with an invalid wearable type! (" << type << ")" << llendl;
return; return;
} }
targetPanel = getPanel(type); targetPanel = getPanel(type);
title = getString(entry->mTitle); title = getString(wearable_entry->mTitle);
description_title = getString(entry->mDescTitle); description_title = getString(wearable_entry->mDescTitle);
// Update picker controls state
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (targetPanel, type, boost::bind(set_enabled_color_swatch_ctrl, show, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (targetPanel, type, boost::bind(set_enabled_texture_ctrl, show, _1, _2));
targetPanel->setVisible(show); targetPanel->setVisible(show);
toggleTypeSpecificControls(type);
if (show) if (show)
{ {
mPanelTitle->setText(title); mPanelTitle->setText(title);
mDescTitle->setText(description_title); mDescTitle->setText(description_title);
}
// set name
mTextEditor->setText(wearable->getName());
// Update picker controls state updatePanelPickerControls(type);
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (targetPanel, type, boost::bind(set_enabled_color_swatch_ctrl, show, _1, _2)); updateTypeSpecificControls(type);
for_each_picker_ctrl_entry <LLTextureCtrl> (targetPanel, type, boost::bind(set_enabled_texture_ctrl, show, _1, _2));
showDefaultSubpart(); // clear and rebuild visual param list
U8 num_subparts = wearable_entry->mSubparts.size();
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
continue;
}
const std::string scrolling_panel = subpart_entry->mParamList;
const std::string accordion_tab = subpart_entry->mAccordionTab;
LLScrollingPanelList *panel_list = getChild<LLScrollingPanelList>(scrolling_panel);
LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab);
if (!panel_list)
{
llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
continue;
}
if (!tab)
{
llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
continue;
}
// what edit group do we want to extract params for?
const std::string edit_group = subpart_entry->mEditGroup;
// storage for ordered list of visual params
value_map_t sorted_params;
getSortedParams(sorted_params, edit_group);
buildParamList(panel_list, sorted_params, tab);
updateScrollingPanelUI();
}
showDefaultSubpart();
updateVerbs();
}
} }
void LLPanelEditWearable::showDefaultSubpart() void LLPanelEditWearable::showDefaultSubpart()
...@@ -967,91 +1064,6 @@ void LLPanelEditWearable::updateScrollingPanelList() ...@@ -967,91 +1064,6 @@ void LLPanelEditWearable::updateScrollingPanelList()
updateScrollingPanelUI(); updateScrollingPanelUI();
} }
void LLPanelEditWearable::initializePanel()
{
if (!mWearablePtr)
{
// cannot initialize with a null reference.
return;
}
LLWearableType::EType type = mWearablePtr->getType();
// set name
mTextEditor->setText(mWearablePtr->getName());
// toggle wearable type-specific controls
toggleTypeSpecificControls(type);
// clear and rebuild visual param list
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
return;
}
U8 num_subparts = wearable_entry->mSubparts.size();
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
continue;
}
const std::string scrolling_panel = subpart_entry->mParamList;
const std::string accordion_tab = subpart_entry->mAccordionTab;
LLScrollingPanelList *panel_list = getChild<LLScrollingPanelList>(scrolling_panel);
LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab);
if (!panel_list)
{
llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
continue;
}
if (!tab)
{
llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
continue;
}
// what edit group do we want to extract params for?
const std::string edit_group = subpart_entry->mEditGroup;
// initialize callback to ensure camera view changes appropriately.
tab->setDropDownStateChangedCallback(boost::bind(&LLPanelEditWearable::onTabExpandedCollapsed,this,_2,index));
// storage for ordered list of visual params
value_map_t sorted_params;
getSortedParams(sorted_params, edit_group);
buildParamList(panel_list, sorted_params, tab);
updateScrollingPanelUI();
}
// initialize texture and color picker controls
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (getPanel(type), type, boost::bind(init_color_swatch_ctrl, this, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (getPanel(type), type, boost::bind(init_texture_ctrl, this, _1, _2));
showDefaultSubpart();
updateVerbs();
if (getWearable())
{
LLWearableType::EType type = getWearable()->getType();
updatePanelPickerControls(type);
updateTypeSpecificControls(type);
}
}
void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type) void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type)
{ {
// Toggle controls specific to shape editing panel. // Toggle controls specific to shape editing panel.
......
...@@ -78,7 +78,6 @@ class LLPanelEditWearable : public LLPanel ...@@ -78,7 +78,6 @@ class LLPanelEditWearable : public LLPanel
typedef std::map<F32, LLViewerVisualParam*> value_map_t; typedef std::map<F32, LLViewerVisualParam*> value_map_t;
void showWearable(LLWearable* wearable, BOOL show); void showWearable(LLWearable* wearable, BOOL show);
void initializePanel();
void updateScrollingPanelUI(); void updateScrollingPanelUI();
LLPanel* getPanel(LLWearableType::EType type); LLPanel* getPanel(LLWearableType::EType type);
void getSortedParams(value_map_t &sorted_params, const std::string &edit_group); void getSortedParams(value_map_t &sorted_params, const std::string &edit_group);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment