From 4a361046f32a685408ddbc1e4a3138946c448ff1 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Mon, 26 Jul 2010 17:53:48 -0400 Subject: EXT-8229 FIXED Add "--no options--" automatically instead of special casing for it in right-click menus Changed logic so that the menu is post-processed and, at that time, nooptions is added if the menu is seen to be empty. --- indra/newview/llfolderview.cpp | 44 +++++++++++++++++++++++++++++--- indra/newview/llfolderview.h | 2 ++ indra/newview/llinventorybridge.cpp | 6 ----- indra/newview/llpanelobjectinventory.cpp | 2 -- 4 files changed, 42 insertions(+), 12 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 14d3bda8e9..5aa504eb35 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1874,13 +1874,18 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask ) } // Successively filter out invalid options - selected_items_t::iterator item_itor; + U32 flags = FIRST_SELECTED_ITEM; - for (item_itor = mSelectedItems.begin(); item_itor != mSelectedItems.end(); ++item_itor) + for (selected_items_t::iterator item_itor = mSelectedItems.begin(); + item_itor != mSelectedItems.end(); + ++item_itor) { - (*item_itor)->buildContextMenu(*menu, flags); + LLFolderViewItem* selected_item = (*item_itor); + selected_item->buildContextMenu(*menu, flags); flags = 0x0; } + + addNoOptions(menu); menu->updateParent(LLMenuGL::sMenuContainer); LLMenuGL::showPopup(this, menu, x, y); @@ -1889,7 +1894,7 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask ) } else { - if(menu && menu->getVisible()) + if (menu && menu->getVisible()) { menu->setVisible(FALSE); } @@ -1898,6 +1903,37 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask ) return handled; } +// Add "--no options--" if the menu is completely blank. +BOOL LLFolderView::addNoOptions(LLMenuGL* menu) const +{ + const std::string nooptions_str = "--no options--"; + LLView *nooptions_item = NULL; + + const LLView::child_list_t *list = menu->getChildList(); + for (LLView::child_list_t::const_iterator itor = list->begin(); + itor != list->end(); + ++itor) + { + LLView *menu_item = (*itor); + if (menu_item->getVisible()) + { + return FALSE; + } + std::string name = menu_item->getName(); + if (menu_item->getName() == nooptions_str) + { + nooptions_item = menu_item; + } + } + if (nooptions_item) + { + nooptions_item->setVisible(TRUE); + nooptions_item->setEnabled(FALSE); + return TRUE; + } + return FALSE; +} + BOOL LLFolderView::handleHover( S32 x, S32 y, MASK mask ) { return LLView::handleHover( x, y, mask ); diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 3944fa53c9..4047e31c08 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -291,6 +291,8 @@ protected: bool selectFirstItem(); bool selectLastItem(); + BOOL addNoOptions(LLMenuGL* menu) const; + protected: LLHandle mPopupMenuHandle; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 0b1408616e..f2a91defef 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2612,12 +2612,6 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) mDisabledItems.push_back(std::string("Share")); } - if (mItems.empty()) - { - mItems.push_back(std::string("--no options--")); - mDisabledItems.push_back(std::string("--no options--")); - } - hide_context_entries(menu, mItems, mDisabledItems); // Add menu items that are dependent on the contents of the folder. diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index ca1361c84b..116e5ba4cb 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -750,8 +750,6 @@ void LLTaskCategoryBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { std::vector items; std::vector disabled_items; - items.push_back(std::string("--no options--")); - disabled_items.push_back(std::string("--no options--")); hide_context_entries(menu, items, disabled_items); } -- cgit v1.2.3 From 34ab18d0c2f7de57e42ded0c3d94ee0fec17da28 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Mon, 26 Jul 2010 18:14:32 -0400 Subject: EXT-8918 FIXED Incorrect right-click options for library items Library items have "Share" disabled. --- indra/newview/llinventorybridge.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index f2a91defef..38f3521b2d 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -952,6 +952,8 @@ void LLInvFVBridge::purgeItem(LLInventoryModel *model, const LLUUID &uuid) BOOL LLInvFVBridge::canShare() const { + if (!isAgentInventory()) return FALSE; + const LLInventoryModel* model = getInventoryModel(); if (!model) return FALSE; @@ -963,9 +965,10 @@ BOOL LLInvFVBridge::canShare() const return (BOOL)LLGiveInventory::isInventoryGiveAcceptable(item); } - // All categories can be given. - const LLViewerInventoryCategory* cat = model->getCategory(mUUID); - return (cat != NULL); + // Categories can be given. + if (model->getCategory(mUUID)) return TRUE; + + return FALSE; } // +=================================================+ -- cgit v1.2.3