From 10e5e5694668a5376378dc487b54f1045080e47e Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 Jul 2024 23:24:39 -0400 Subject: Reduce findChild stalls in appearance floater --- indra/newview/lloutfitgallery.cpp | 40 ++++++++++++++-------- indra/newview/lloutfitgallery.h | 1 + indra/newview/llpaneloutfitedit.cpp | 39 +++++++++++++-------- indra/newview/llpaneloutfitedit.h | 8 +++++ indra/newview/llpaneloutfitsinventory.cpp | 12 +++---- indra/newview/llpaneloutfitsinventory.h | 1 + indra/newview/llscrollingpanelparambase.cpp | 13 +++---- indra/newview/llscrollingpanelparambase.h | 1 + indra/newview/llsidepanelappearance.cpp | 7 ++-- indra/newview/llsidepanelappearance.h | 4 +++ indra/newview/llwearableitemslist.cpp | 18 ++++++---- indra/newview/llwearableitemslist.h | 2 ++ .../skins/default/xui/en/panel_edit_alpha.xml | 5 --- 13 files changed, 97 insertions(+), 54 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index b1b9f69f4f..7482890d1e 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -739,13 +739,16 @@ void LLOutfitGallery::onFilterSubStringChanged(const std::string& new_string, co void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) { - if (mOutfitMap[base_id]) + auto base_it = mOutfitMap.find(base_id); + if (base_it != mOutfitMap.end()) { - mOutfitMap[base_id]->setOutfitWorn(true); + base_it->second->setOutfitWorn(true); } - if (mOutfitMap[prev_id]) + + auto prev_it = mOutfitMap.find(prev_id); + if (prev_it != mOutfitMap.end()) { - mOutfitMap[prev_id]->setOutfitWorn(false); + prev_it->second->setOutfitWorn(false); } } @@ -859,13 +862,16 @@ void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const L { if (mSelectedOutfitUUID == category_id) return; - if (mOutfitMap[mSelectedOutfitUUID]) + + auto selected_it = mOutfitMap.find(mSelectedOutfitUUID); + if (selected_it != mOutfitMap.end()) { - mOutfitMap[mSelectedOutfitUUID]->setSelected(false); + selected_it->second->setSelected(false); } - if (mOutfitMap[category_id]) + auto category_it = mOutfitMap.find(category_id); + if (category_it != mOutfitMap.end()) { - mOutfitMap[category_id]->setSelected(true); + category_it->second->setSelected(true); } // mSelectedOutfitUUID will be set in LLOutfitListBase::ChangeOutfitSelection } @@ -887,9 +893,10 @@ bool LLOutfitGallery::canWearSelected() bool LLOutfitGallery::hasDefaultImage(const LLUUID& outfit_cat_id) { - if (mOutfitMap[outfit_cat_id]) + auto outfit_it = mOutfitMap.find(outfit_cat_id); + if (outfit_it != mOutfitMap.end()) { - return mOutfitMap[outfit_cat_id]->isDefaultImage(); + return outfit_it->second->isDefaultImage(); } return false; } @@ -937,6 +944,7 @@ LLOutfitGalleryItem::~LLOutfitGalleryItem() bool LLOutfitGalleryItem::postBuild() { + mPreviewIcon = getChild("preview_outfit"); setDefaultImage(); mOutfitNameText = getChild("outfit_name"); @@ -952,10 +960,12 @@ void LLOutfitGalleryItem::draw() LLPanel::draw(); // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white); - LLRect border = getChildView("preview_outfit")->getRect(); + static LLUIColor selected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemSelected", LLColor4::white); + static LLUIColor unselected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemUnselected", LLColor4::white); + const LLColor4& border_color = mSelected ? selected_color : unselected_color; + LLRect border = mPreviewIcon->getRect(); border.mRight = border.mRight + 1; - gl_rect_2d(border, border_color.get(), false); + gl_rect_2d(border, border_color, false); // If the floater is focused, don't apply its alpha to the texture (STORM-677). const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); @@ -1111,7 +1121,7 @@ bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { mImageAssetId = image_asset_id; mTexturep = texture; - getChildView("preview_outfit")->setVisible(false); + mPreviewIcon->setVisible(false); mDefaultImage = false; mImageUpdatePending = (texture->getDiscardLevel() == -1); return true; @@ -1128,7 +1138,7 @@ void LLOutfitGalleryItem::setDefaultImage() { mTexturep = NULL; mImageAssetId.setNull(); - getChildView("preview_outfit")->setVisible(true); + mPreviewIcon->setVisible(true); mDefaultImage = true; mImageUpdatePending = false; } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index d921a7fe72..5b2a33d0ca 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -261,6 +261,7 @@ private: LLTextBox* mOutfitNameText; LLTextBox* mOutfitWornText; LLPanel* mTextBgPanel; + LLIconCtrl* mPreviewIcon = nullptr; bool mSelected; bool mWorn; bool mDefaultImage; diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index ce545ae21d..fadf3633e8 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -434,6 +434,8 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit() delete mCOFDragAndDropObserver; + delete mWearableListViewItemsComparator; + while (!mListViewItemTypes.empty()) { delete mListViewItemTypes.back(); mListViewItemTypes.pop_back(); @@ -476,8 +478,11 @@ bool LLPanelOutfitEdit::postBuild() mFolderViewBtn = getChild("folder_view_btn"); mListViewBtn = getChild("list_view_btn"); + + mFilterPanel = getChild("filter_panel"); + mFilterBtn = getChild("filter_button"); + mFilterBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this)); - childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL); childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL); childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL); childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL); @@ -530,13 +535,17 @@ bool LLPanelOutfitEdit::postBuild() mSearchFilter = getChild("look_item_filter"); mSearchFilter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onSearchEdit, this, _2)); - childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this)); + mShowAddWearablesBtn = getChild("show_add_wearables_btn"); + mShowAddWearablesBtn->setClickedCallback(boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this)); mPlusBtn = getChild("plus_btn"); mPlusBtn->setClickedCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this)); childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance())); + mNoAddWearablesButtonBar = getChild("no_add_wearables_button_bar"); + mAddWearablesButtonBar = getChild("add_wearables_button_bar"); + /* * By default AT_CLOTHING are sorted by (in in MY OUTFITS): * - by type (types order determined in LLWearableType::EType) @@ -567,7 +576,11 @@ bool LLPanelOutfitEdit::postBuild() getChild(SAVE_BTN)->setCommitCallback(boost::bind(&LLPanelOutfitEdit::saveOutfit, this, false)); getChild(SAVE_AS_BTN)->setCommitCallback(boost::bind(&LLPanelOutfitEdit::saveOutfit, this, true)); + mLoadingIndicator = getChild("edit_outfit_loading_indicator"); + mOutfitNameStatusPanel = getChild("outfit_name_and_status"); + onOutfitChanging(gAgentWearables.isCOFChangeInProgress()); + return true; } @@ -603,15 +616,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables) { mAddWearablesPanel->setVisible(show_add_wearables); - getChild("show_add_wearables_btn")->setValue(show_add_wearables); + mShowAddWearablesBtn->setValue(show_add_wearables); updateFiltersVisibility(); - getChildView("filter_button")->setVisible( show_add_wearables); + mFilterBtn->setVisible( show_add_wearables); //search filter should be disabled if (!show_add_wearables) { - getChild("filter_button")->setValue(false); + mFilterBtn->setValue(false); mFolderViewFilterCmbBox->setVisible(false); mListViewFilterCmbBox->setVisible(false); @@ -638,15 +651,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables) } //switching button bars - getChildView("no_add_wearables_button_bar")->setVisible( !show_add_wearables); - getChildView("add_wearables_button_bar")->setVisible( show_add_wearables); + mNoAddWearablesButtonBar->setVisible( !show_add_wearables); + mAddWearablesButtonBar->setVisible( show_add_wearables); } void LLPanelOutfitEdit::showWearablesFilter() { - bool filter_visible = getChild("filter_button")->getValue(); + bool filter_visible = mFilterBtn->getValue(); - getChildView("filter_panel")->setVisible( filter_visible); + mFilterPanel->setVisible(filter_visible); if(!filter_visible) { @@ -1309,19 +1322,17 @@ static void update_status_widget_rect(LLView * widget, S32 right_border) void LLPanelOutfitEdit::onOutfitChanging(bool started) { - static LLLoadingIndicator* indicator = getChild("edit_outfit_loading_indicator"); - static LLView* status_panel = getChild("outfit_name_and_status"); - static S32 indicator_delta = status_panel->getRect().getWidth() - indicator->getRect().mLeft; + S32 indicator_delta = mOutfitNameStatusPanel->getRect().getWidth() - mLoadingIndicator->getRect().mLeft; S32 delta = started ? indicator_delta : 0; - S32 right_border = status_panel->getRect().getWidth() - delta; + S32 right_border = mOutfitNameStatusPanel->getRect().getWidth() - delta; if (mCurrentOutfitName) update_status_widget_rect(mCurrentOutfitName, right_border); if (mStatus) update_status_widget_rect(mStatus, right_border); - indicator->setVisible(started); + mLoadingIndicator->setVisible(started); } void LLPanelOutfitEdit::getCurrentItemUUID(LLUUID& selected_id) diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h index 384b7faee4..a989d93d9e 100644 --- a/indra/newview/llpaneloutfitedit.h +++ b/indra/newview/llpaneloutfitedit.h @@ -59,6 +59,7 @@ class LLMenuGL; class LLFindNonLinksByMask; class LLFindWearablesOfType; class LLWearableItemTypeNameComparator; +class LLLoadingIndicator; class LLPanelOutfitEdit : public LLPanel { @@ -218,7 +219,14 @@ private: LLButton* mFolderViewBtn; LLButton* mListViewBtn; LLButton* mPlusBtn; + LLButton* mShowAddWearablesBtn = nullptr; + LLButton* mFilterBtn = nullptr; LLPanel* mAddWearablesPanel; + LLPanel* mOutfitNameStatusPanel = nullptr; + LLLoadingIndicator* mLoadingIndicator = nullptr; + LLView* mFilterPanel = nullptr; + LLUICtrl* mNoAddWearablesButtonBar = nullptr; + LLUICtrl* mAddWearablesButtonBar = nullptr; LLComboBox* mFolderViewFilterCmbBox; LLComboBox* mListViewFilterCmbBox; diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 5b595a48b7..b226c2ca1a 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -252,7 +252,8 @@ void LLPanelOutfitsInventory::openApearanceTab(const std::string& tab_name) void LLPanelOutfitsInventory::initListCommandsHandlers() { mListCommands = getChild("bottom_panel"); - mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); + mWearBtn = mListCommands->getChild("wear_btn"); + mWearBtn->setCommitCallback(boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); mMyOutfitsPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); mOutfitGalleryPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); } @@ -263,14 +264,13 @@ void LLPanelOutfitsInventory::updateListCommands() bool wear_enabled = isActionEnabled("wear"); bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); - - LLButton* wear_btn = mListCommands->getChild("wear_btn"); + mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled); mOutfitGalleryPanel->childSetEnabled("trash_btn", trash_enabled); - wear_btn->setEnabled(wear_enabled); - wear_btn->setVisible(wear_visible); + mWearBtn->setEnabled(wear_enabled); + mWearBtn->setVisible(wear_visible); getChild(SAVE_BTN)->setEnabled(make_outfit_enabled); - wear_btn->setToolTip(getString((!isOutfitsGalleryPanelActive() && mMyOutfitsPanel->hasItemSelected()) ? "wear_items_tooltip" : "wear_outfit_tooltip")); + mWearBtn->setToolTip(getString((!isOutfitsGalleryPanelActive() && mMyOutfitsPanel->hasItemSelected()) ? "wear_items_tooltip" : "wear_outfit_tooltip")); } void LLPanelOutfitsInventory::onTrashButtonClick() diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index 0c501d5c71..e046681e95 100644 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -101,6 +101,7 @@ protected: private: LLPanel* mListCommands; LLMenuGL* mMenuAdd; + LLButton* mWearBtn = nullptr; // List Commands // ////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp index 247639aa48..d6b5434fa4 100644 --- a/indra/newview/llscrollingpanelparambase.cpp +++ b/indra/newview/llscrollingpanelparambase.cpp @@ -51,12 +51,13 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan else buildFromFile( "panel_scrolling_param_base.xml"); - getChild("param slider")->setValue(weightToPercent(param->getWeight())); + mParamSlider = getChild("param slider"); + mParamSlider->setValue(weightToPercent(param->getWeight())); std::string display_name = LLTrans::getString(param->getDisplayName()); - getChild("param slider")->setLabelArg("[DESC]", display_name); - getChildView("param slider")->setEnabled(mAllowModify); - childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this); + mParamSlider->setLabelArg("[DESC]", display_name); + mParamSlider->setEnabled(mAllowModify); + mParamSlider->setCommitCallback(LLScrollingPanelParamBase::onSliderMoved, this); setVisible(false); setBorderVisible( false ); @@ -77,9 +78,9 @@ void LLScrollingPanelParamBase::updatePanel(bool allow_modify) } F32 current_weight = mWearable->getVisualParamWeight( param->getID() ); - getChild("param slider")->setValue(weightToPercent( current_weight ) ); + mParamSlider->setValue(weightToPercent( current_weight ) ); mAllowModify = allow_modify; - getChildView("param slider")->setEnabled(mAllowModify); + mParamSlider->setEnabled(mAllowModify); } // static diff --git a/indra/newview/llscrollingpanelparambase.h b/indra/newview/llscrollingpanelparambase.h index 9deafcc81a..d5477a8397 100644 --- a/indra/newview/llscrollingpanelparambase.h +++ b/indra/newview/llscrollingpanelparambase.h @@ -55,6 +55,7 @@ public: public: LLViewerVisualParam* mParam; protected: + LLUICtrl* mParamSlider = nullptr; bool mAllowModify; LLWearable *mWearable; }; diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 35d07d1ac8..c618483fc4 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -39,6 +39,7 @@ #include "llfloaterreg.h" #include "llfloaterworldmap.h" #include "llfolderviewmodel.h" +#include "llloadingindicator.h" #include "lloutfitobserver.h" #include "llpaneleditwearable.h" #include "llpaneloutfitsinventory.h" @@ -137,6 +138,8 @@ bool LLSidepanelAppearance::postBuild() mCurrOutfitPanel = getChild("panel_currentlook"); + mWearableLoadingIndicator = getChild("wearables_loading_indicator"); + mEditOutfitBtn = getChild("edit_outfit_btn"); setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChanged,this,_2)); @@ -541,8 +544,8 @@ void LLSidepanelAppearance::inventoryFetched() void LLSidepanelAppearance::setWearablesLoading(bool val) { - getChildView("wearables_loading_indicator")->setVisible( val); - getChildView("edit_outfit_btn")->setVisible( !val); + mWearableLoadingIndicator->setVisible(val); + mEditOutfitBtn->setVisible(!val); if (!val) { diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h index f3d34a857c..1c1de99795 100644 --- a/indra/newview/llsidepanelappearance.h +++ b/indra/newview/llsidepanelappearance.h @@ -38,6 +38,7 @@ class LLCurrentlyWornFetchObserver; class LLPanelEditWearable; class LLViewerWearable; class LLPanelOutfitsInventory; +class LLLoadingIndicator; class LLSidepanelAppearance : public LLPanel { @@ -86,8 +87,11 @@ private: LLButton* mOpenOutfitBtn; LLButton* mEditAppearanceBtn; + LLButton* mEditOutfitBtn = nullptr; LLPanel* mCurrOutfitPanel; + LLLoadingIndicator* mWearableLoadingIndicator = nullptr; + LLTextBox* mCurrentLookName; LLTextBox* mOutfitStatus; diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 5ee6aec9f9..8ce1a745c3 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -102,15 +102,21 @@ LLPanelWearableOutfitItem::Params::Params() bool LLPanelWearableOutfitItem::postBuild() { + if (mShowWidgets) + { + mAddWearableBtn = getChild("add_wearable"); + mRemoveWearableBtn = getChild("remove_wearable"); + } + LLPanelWearableListItem::postBuild(); if(mShowWidgets) { - addWidgetToRightSide("add_wearable"); - addWidgetToRightSide("remove_wearable"); + addWidgetToRightSide(mAddWearableBtn); + addWidgetToRightSide(mRemoveWearableBtn); - childSetAction("add_wearable", boost::bind(&LLPanelWearableOutfitItem::onAddWearable, this)); - childSetAction("remove_wearable", boost::bind(&LLPanelWearableOutfitItem::onRemoveWearable, this)); + mAddWearableBtn->setClickedCallback(boost::bind(&LLPanelWearableOutfitItem::onAddWearable, this)); + mRemoveWearableBtn->setClickedCallback(boost::bind(&LLPanelWearableOutfitItem::onRemoveWearable, this)); setWidgetsVisible(false); reshapeWidgets(); @@ -205,12 +211,12 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name, } if(mShowWidgets) { - setShowWidget("add_wearable", !is_worn); + setShowWidget(mAddWearableBtn, !is_worn); // Body parts can't be removed, only replaced LLViewerInventoryItem* inv_item = getItem(); bool show_remove = is_worn && inv_item && (inv_item->getType() != LLAssetType::AT_BODYPART); - setShowWidget("remove_wearable", show_remove); + setShowWidget(mRemoveWearableBtn, show_remove); if(mHovered) { diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h index 7b69711154..3fe1059176 100644 --- a/indra/newview/llwearableitemslist.h +++ b/indra/newview/llwearableitemslist.h @@ -104,6 +104,8 @@ protected: bool worn_indication_enabled, const Params& params, bool show_widgets = false); private: + LLButton* mAddWearableBtn = nullptr; + LLButton* mRemoveWearableBtn = nullptr; bool mWornIndicationEnabled; bool mShowWidgets; }; diff --git a/indra/newview/skins/default/xui/en/panel_edit_alpha.xml b/indra/newview/skins/default/xui/en/panel_edit_alpha.xml index 30fee7361f..ab0e447028 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_alpha.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_alpha.xml @@ -33,7 +33,6 @@ top="0" width="313" >