diff options
| author | Rye Mutt <rye@alchemyviewer.org> | 2022-10-19 16:19:33 -0400 | 
|---|---|---|
| committer | Rye Mutt <rye@alchemyviewer.org> | 2022-10-19 16:21:05 -0400 | 
| commit | b9552e596fdeaf577d1de1e6d4d2ba5d46bceeb9 (patch) | |
| tree | 8036e037008d603f338c311d5cc0d2f21d40bca7 | |
| parent | 1fb1a9df7a6664946f1f758330a0e6cfaef0dd8f (diff) | |
Reduce folderview menu bloat via lazy creation on right click
| -rw-r--r-- | indra/llui/llfolderview.cpp | 58 | ||||
| -rw-r--r-- | indra/llui/llfolderview.h | 3 | ||||
| -rw-r--r-- | indra/newview/llfloaterimcontainer.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llfloaterimsessiontab.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llinventorypanel.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llpanelobjectinventory.cpp | 1 | 
7 files changed, 63 insertions, 20 deletions
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index ea2ca68e47..e1869e8125 100644 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -163,6 +163,7 @@ LLFolderView::LLFolderView(const Params& p)  :	LLFolderViewFolder(p),  	mScrollContainer( NULL ),  	mPopupMenuHandle(), +	mMenuFileName(p.options_menu),  	mAllowMultiSelect(p.allow_multiselect),  	mAllowDrag(p.allow_drag),  	mShowEmptyMessage(p.show_empty_message), @@ -182,6 +183,7 @@ LLFolderView::LLFolderView(const Params& p)  	mMinWidth(0),  	mDragAndDropThisFrame(FALSE),  	mCallbackRegistrar(NULL), +	mEnableRegistrar(NULL),  	mUseEllipses(p.use_ellipses),  	mDraggingOverItem(NULL),  	mStatusTextBox(NULL), @@ -244,17 +246,6 @@ LLFolderView::LLFolderView(const Params& p)  	mStatusTextBox->setFollowsTop();  	addChild(mStatusTextBox); - -	// make the popup menu available -	llassert(LLMenuGL::sMenuContainer != NULL); -	LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(p.options_menu, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); -	if (!menu) -	{ -		menu = LLUICtrlFactory::getDefaultWidget<LLMenuGL>("inventory_menu"); -	} -	menu->setBackgroundColor(LLUIColorTable::instance().getColor("MenuPopupBgColor")); -	mPopupMenuHandle = menu->getHandle(); -  	mViewModelItem->openItem();  	mAreChildrenInited = true; // root folder is a special case due to not being loaded normally, assume that it's inited. @@ -276,6 +267,7 @@ LLFolderView::~LLFolderView( void )  	mStatusTextBox = NULL;  	if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die(); +	mPopupMenuHandle.markDead();  	mAutoOpenItems.removeAllNodes();  	clearSelection(); @@ -1438,22 +1430,56 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask )  	BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL;  	S32 count = mSelectedItems.size(); -	LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); +	LLMenuGL* menu = static_cast<LLMenuGL*>(mPopupMenuHandle.get()); +	if (!menu) +	{ +		if (mCallbackRegistrar) +		{ +			mCallbackRegistrar->pushScope(); +		} +		if (mEnableRegistrar) +		{ +			mEnableRegistrar->pushScope(); +		} +		llassert(LLMenuGL::sMenuContainer != NULL); +		menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(mMenuFileName, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); +		if (!menu) +		{ +			menu = LLUICtrlFactory::getDefaultWidget<LLMenuGL>("inventory_menu"); +		} +		menu->setBackgroundColor(LLUIColorTable::instance().getColor("MenuPopupBgColor")); +		mPopupMenuHandle = menu->getHandle(); +		if (mEnableRegistrar) +		{ +			mEnableRegistrar->popScope(); +		} +		if (mCallbackRegistrar) +		{ +			mCallbackRegistrar->popScope(); +		} +	}  	bool hide_folder_menu = mSuppressFolderMenu && isFolderSelected(); -	if ((handled -		&& ( count > 0 && (hasVisibleChildren()) ) // show menu only if selected items are visible -		&& menu ) && +	if (menu && (handled +		&& ( count > 0 && (hasVisibleChildren()) )) && // show menu only if selected items are visible  		!hide_folder_menu)  	{  		if (mCallbackRegistrar)          {  			mCallbackRegistrar->pushScope();          } +		if (mEnableRegistrar) +		{ +			mEnableRegistrar->pushScope(); +		}  		updateMenuOptions(menu);  		menu->updateParent(LLMenuGL::sMenuContainer);  		LLMenuGL::showPopup(this, menu, x, y); +		if (mEnableRegistrar) +		{ +			mEnableRegistrar->popScope(); +		}  		if (mCallbackRegistrar)          {  			mCallbackRegistrar->popScope(); @@ -1531,7 +1557,7 @@ void LLFolderView::deleteAllChildren()  {  	closeRenamer();  	if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die(); -	mPopupMenuHandle = LLHandle<LLView>(); +	mPopupMenuHandle.markDead();  	mScrollContainer = NULL;  	mRenameItem = NULL;  	mRenamer = NULL; diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index 6bb5e6c02e..7dfa04828a 100644 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -235,6 +235,7 @@ public:  	bool showItemLinkOverlays() { return mShowItemLinkOverlays; }  	void setCallbackRegistrar(LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* registrar) { mCallbackRegistrar = registrar; } +	void setEnableRegistrar(LLUICtrl::EnableCallbackRegistry::ScopedRegistrar* registrar) { mEnableRegistrar = registrar; }  	LLPanel* getParentPanel() { return mParentPanel.get(); }  	// DEBUG only @@ -272,6 +273,7 @@ protected:  protected:  	LLHandle<LLView>					mPopupMenuHandle; +	std::string						mMenuFileName;  	selected_items_t				mSelectedItems;  	bool							mKeyboardSelection, @@ -327,6 +329,7 @@ protected:  	LLFolderViewItem*				mDraggingOverItem; // See EXT-719  	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* mCallbackRegistrar; +	LLUICtrl::EnableCallbackRegistry::ScopedRegistrar* mEnableRegistrar;  public:  	static F32 sAutoOpenTime; diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index 703b5d0011..2720b7fcf7 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -211,6 +211,7 @@ BOOL LLFloaterIMContainer::postBuild()      p.options_menu = "menu_conversation.xml";  	mConversationsRoot = LLUICtrlFactory::create<LLFolderView>(p);      mConversationsRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); +	mConversationsRoot->setEnableRegistrar(&mEnableCallbackRegistrar);  	// Add listener to conversation model events  	mConversationsEventStream.listen("ConversationsRefresh", boost::bind(&LLFloaterIMContainer::onConversationModelEvent, this, _1)); diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 93a0b39e02..f973ae43cc 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -317,6 +317,7 @@ BOOL LLFloaterIMSessionTab::postBuild()      p.name = "root";  	mConversationsRoot = LLUICtrlFactory::create<LLFolderView>(p);      mConversationsRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); +	mConversationsRoot->setEnableRegistrar(&mEnableCallbackRegistrar);  	// Attach that root to the scroller  	mScroller->addChild(mConversationsRoot);  	mConversationsRoot->setScrollContainer(mScroller); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 6b102c7500..c065c76dca 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -211,7 +211,11 @@ LLFolderView * LLInventoryPanel::createFolderRoot(LLUUID root_id )      p.allow_drop = mParams.allow_drop_on_root;      p.options_menu = "menu_inventory.xml"; -    return LLUICtrlFactory::create<LLFolderView>(p); +	LLFolderView* fv = LLUICtrlFactory::create<LLFolderView>(p); +	fv->setCallbackRegistrar(&mCommitCallbackRegistrar); +	fv->setEnableRegistrar(&mEnableCallbackRegistrar); + +	return fv;  }  void LLInventoryPanel::clearFolderRoot() @@ -264,6 +268,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)  	}  	mCommitCallbackRegistrar.popScope();  	mFolderRoot.get()->setCallbackRegistrar(&mCommitCallbackRegistrar); +	mFolderRoot.get()->setEnableRegistrar(&mEnableCallbackRegistrar);  	// Scroller  		LLRect scroller_view_rect = getRect(); diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 89256b40c4..81acb1c8b4 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -307,6 +307,13 @@ LLPanelMainInventory::~LLPanelMainInventory( void )  	gInventory.removeObserver(this);  	delete mSavedFolderState; + +	auto menu = mMenuAddHandle.get(); +	if(menu) +	{ +		menu->die(); +		mMenuAddHandle.markDead(); +	}  }  LLInventoryPanel* LLPanelMainInventory::getAllItemsPanel() @@ -1177,13 +1184,12 @@ void LLPanelMainInventory::initListCommandsHandlers()  	mEnableCallbackRegistrar.add("Inventory.GearDefault.Check", boost::bind(&LLPanelMainInventory::isActionChecked, this, _2));  	mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2));  	mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); -	mGearMenuButton->setMenu(mMenuGearDefault); +	mGearMenuButton->setMenu(mMenuGearDefault, LLMenuButton::MP_TOP_LEFT, true);  	LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());  	mMenuAddHandle = menu->getHandle();  	mMenuVisibility = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_search_visibility.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); -	mVisibilityMenuButton->setMenu(mMenuVisibility); -	mVisibilityMenuButton->setMenuPosition(LLMenuButton::MP_BOTTOM_LEFT); +	mVisibilityMenuButton->setMenu(mMenuVisibility, LLMenuButton::MP_BOTTOM_LEFT, true);  	// Update the trash button when selected item(s) get worn or taken off.  	LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLPanelMainInventory::updateListCommands, this)); diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index cfaa9456be..17b4528d97 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -1360,6 +1360,7 @@ void LLPanelObjectInventory::reset()  	mFolders = LLUICtrlFactory::create<LLFolderView>(p);  	mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar); +	mFolders->setEnableRegistrar(&mEnableCallbackRegistrar);  	if (hasFocus())  	{  | 
