From 15413e44427c5cc332bcae65462498b349d15eba Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 5 May 2010 12:29:53 +0300 Subject: Fixed major bug EXT-6797 (attempting to create new folder while viewing recent inventory renames newest item instead.) Implemented Recent Inventory Panel specific classes to create appropriate context menu for Folders in Recent Items Panel: * Registered new LLInventoryRecentItemsPanel class * Added appropriate Folder Bridge and Bridge Builder Updated main inventory panel to not show "+" button on Recent Items tab * Placed controls into Layout Stack. * Change visibility of panel with "+" button while switching between tabs. * also made bottom panel wider to be consistent with other side panels (see screenshots). Reviewed by Loren Shih at https://codereview.productengine.com/secondlife/r/334/ --HG-- branch : product-engine --- indra/newview/llinventorybridge.cpp | 64 ++++++++++ indra/newview/llinventorybridge.h | 57 +++++++++ indra/newview/llinventorypanel.cpp | 27 ++++ indra/newview/llpanelmaininventory.cpp | 6 +- .../skins/default/xui/en/panel_main_inventory.xml | 140 +++++++++++++-------- 5 files changed, 239 insertions(+), 55 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2d08c0a01a..228ab7ebd6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -5525,3 +5525,67 @@ LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_ /** Bridge Actions ** ********************************************************************************/ + +/************************************************************************/ +/* Recent Inventory Panel related classes */ +/************************************************************************/ +void LLRecentItemsFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) +{ + LLFolderBridge::buildContextMenu(menu, flags); + + menuentry_vec_t disabled_items, items = getMenuItems(); + + items.erase(std::find(items.begin(), items.end(), std::string("New Folder"))); + items.erase(std::find(items.begin(), items.end(), std::string("New Script"))); + items.erase(std::find(items.begin(), items.end(), std::string("New Note"))); + items.erase(std::find(items.begin(), items.end(), std::string("New Gesture"))); + items.erase(std::find(items.begin(), items.end(), std::string("New Clothes"))); + items.erase(std::find(items.begin(), items.end(), std::string("New Body Parts"))); + + hide_context_entries(menu, items, disabled_items); +} + +LLInvFVBridge* LLRecentInventoryBridgeBuilder::createBridge( + LLAssetType::EType asset_type, + LLAssetType::EType actual_asset_type, + LLInventoryType::EType inv_type, + LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid, + U32 flags /*= 0x00*/ ) const +{ + LLInvFVBridge* new_listener = NULL; + switch(asset_type) + { + case LLAssetType::AT_CATEGORY: + if (actual_asset_type == LLAssetType::AT_LINK_FOLDER) + { + // *TODO: Create a link folder handler instead if it is necessary + new_listener = LLInventoryFVBridgeBuilder::createBridge( + asset_type, + actual_asset_type, + inv_type, + inventory, + root, + uuid, + flags); + break; + } + new_listener = new LLRecentItemsFolderBridge(inv_type, inventory, root, uuid); + break; + default: + new_listener = LLInventoryFVBridgeBuilder::createBridge( + asset_type, + actual_asset_type, + inv_type, + inventory, + root, + uuid, + flags); + } + return new_listener; + +} + + +// EOF diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index de63bdd76b..c45e376cab 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -349,6 +349,11 @@ protected: void modifyOutfit(BOOL append); void determineFolderType(); + /** + * Returns a copy of current menu items. + */ + menuentry_vec_t getMenuItems() { return mItems; } + public: static LLFolderBridge* sSelf; static void staticFolderOptionsMenu(); @@ -659,6 +664,58 @@ protected: }; +/************************************************************************/ +/* Recent Inventory Panel related classes */ +/************************************************************************/ +class LLRecentInventoryBridgeBuilder; +/** + * Overridden version of the Inventory-Folder-View-Bridge for Folders + */ +class LLRecentItemsFolderBridge : public LLFolderBridge +{ + friend class LLRecentInventoryBridgeBuilder; + +public: + /** + * Creates context menu for Folders related to Recent Inventory Panel. + * + * It uses base logic and than removes from visible items "New..." menu items. + */ + /*virtual*/ void buildContextMenu(LLMenuGL& menu, U32 flags); + +protected: + LLRecentItemsFolderBridge(LLInventoryType::EType type, + LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid) : + LLFolderBridge(inventory, root, uuid) + { + mInvType = type; + } +}; + +/** + * Bridge builder to create Inventory-Folder-View-Bridge for Recent Inventory Panel + */ +class LLRecentInventoryBridgeBuilder : public LLInventoryFVBridgeBuilder +{ + /** + * Overrides FolderBridge for Recent Inventory Panel. + * + * It use base functionality for bridges other than FolderBridge. + */ + virtual LLInvFVBridge* createBridge(LLAssetType::EType asset_type, + LLAssetType::EType actual_asset_type, + LLInventoryType::EType inv_type, + LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid, + U32 flags = 0x00) const; + +}; + + + void wear_inventory_item_on_avatar(LLInventoryItem* item); void rez_attachment(LLViewerInventoryItem* item, diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 15c872a7c4..dd1e039cb1 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1001,3 +1001,30 @@ BOOL LLInventoryPanel::getIsHiddenFolderType(LLFolderType::EType folder_type) co { return (std::find(mHiddenFolderTypes.begin(), mHiddenFolderTypes.end(), folder_type) != mHiddenFolderTypes.end()); } + + +/************************************************************************/ +/* Recent Inventory Panel related class */ +/************************************************************************/ +class LLInventoryRecentItemsPanel; +static LLDefaultChildRegistry::Register t_recent_inventory_panel("recent_inventory_panel"); + +static const LLRecentInventoryBridgeBuilder RECENT_ITEMS_BUILDER; +class LLInventoryRecentItemsPanel : public LLInventoryPanel +{ +public: + struct Params : public LLInitParam::Block + {}; + +protected: + LLInventoryRecentItemsPanel (const Params&); + friend class LLUICtrlFactory; +}; + +LLInventoryRecentItemsPanel::LLInventoryRecentItemsPanel( const Params& params) +: LLInventoryPanel(params) +{ + // replace bridge builder to have necessary View bridges. + mInvFVBridgeBuilder = &RECENT_ITEMS_BUILDER; +} + diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 0ba373c51b..a84280c213 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -167,7 +167,7 @@ BOOL LLPanelMainInventory::postBuild() // Now load the stored settings from disk, if available. std::ostringstream filterSaveName; filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME); - llinfos << "LLPanelMainInventory::init: reading from " << filterSaveName << llendl; + llinfos << "LLPanelMainInventory::init: reading from " << filterSaveName.str() << llendl; llifstream file(filterSaveName.str()); LLSD savedFilterState; if (file.is_open()) @@ -492,6 +492,10 @@ void LLPanelMainInventory::onFilterSelected() { return; } + + BOOL recent_active = ("Recent Items" == mActivePanel->getName()); + childSetVisible("add_btn_panel", !recent_active); + setFilterSubString(mFilterSubString); LLInventoryFilter* filter = mActivePanel->getFilter(); LLFloaterInventoryFinder *finder = getFinder(); diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml index 46625144e1..d65b86f007 100644 --- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml @@ -84,7 +84,7 @@ sort_order_setting="InventorySortOrder" top="16" width="288" /> - - - -