From 08381a276dbf0544692c44236b40f57ec111aefc Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 23 Jun 2010 15:30:48 +0300 Subject: EXT-7755 ADDITIONAL FIX Fixed issues with wrong title after an outfit from the Inventory is worn, "Wear..." menu items state is made consistent with "Wear" button. * Empty string is replaced with "Changing outfits" while changing COF; * Fixed title to show "No Outfit" after an outfit from the Inventory is worn; * Fixed bug with visible indicator after an empty folder is DnD from the Inventory "Clothing" * Updated context and Gear "Wear..." menu items to take into account "isCOFChangeInProgress" state in on_enable callbacks Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/625/ --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 6542afc366..b3d39f2a4a 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -103,8 +103,13 @@ protected: { return get_is_category_renameable(&gInventory, outfit_cat_id); } + else if ("wear_replace" == param) + { + return !gAgentWearables.isCOFChangeInProgress(); + } else if ("wear_add" == param) { + if (gAgentWearables.isCOFChangeInProgress()) return false; return LLAppearanceMgr::getCanAddToCOF(outfit_cat_id); } else if ("take_off" == param) -- cgit v1.3 From 887b2858d4d180d3679f1eb39fd37be5a551615e Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Fri, 11 Jun 2010 20:02:42 +0300 Subject: EXT-7779 FIXED Changed wearing panel from inventory panel to a flat list similar to My Outfits view. - Added common interface for My Outfits and Wearing tabs. - Changed LLPanelOutfitsInventory to use common interface for My Outfits and Wearing tabs. - Removed dependency on outfits side panel from inventory bridge context menus. - Removed unused LLShowCreatedOutfit class from llagentwearables.cpp. - Restored opening newly created outfit in My Outfits tab. - Fixed worn items indication for Wearing tab items. Revieved by Neal Orman at https://codereview.productengine.com/secondlife/r/604/. --HG-- branch : product-engine --- indra/newview/CMakeLists.txt | 3 + indra/newview/llagentwearables.cpp | 40 -- indra/newview/llappearancemgr.cpp | 17 +- indra/newview/llinventorybridge.cpp | 64 +--- indra/newview/llinventorybridge.h | 1 - indra/newview/lloutfitslist.cpp | 78 +++- indra/newview/lloutfitslist.h | 22 +- indra/newview/llpanelappearancetab.h | 22 +- indra/newview/llpaneloutfitsinventory.cpp | 424 ++------------------- indra/newview/llpaneloutfitsinventory.h | 54 +-- indra/newview/llpanelwearing.cpp | 130 +++++++ indra/newview/llpanelwearing.h | 73 ++++ indra/newview/llwearableitemslist.cpp | 15 +- indra/newview/llwearableitemslist.h | 11 +- .../default/xui/en/panel_outfits_inventory.xml | 37 +- 15 files changed, 400 insertions(+), 591 deletions(-) create mode 100644 indra/newview/llpanelwearing.cpp create mode 100644 indra/newview/llpanelwearing.h (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c1b2d680be..ce42cb6038 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -363,6 +363,7 @@ set(viewer_SOURCE_FILES llpaneltopinfobar.cpp llpanelvolume.cpp llpanelvolumepulldown.cpp + llpanelwearing.cpp llparcelselection.cpp llparticipantlist.cpp llpatchvertexarray.cpp @@ -830,6 +831,7 @@ set(viewer_HEADER_FILES lloutfitslist.h lloutfitobserver.h lloutputmonitorctrl.h + llpanelappearancetab.h llpanelavatar.h llpanelavatartag.h llpanelblockedlist.h @@ -883,6 +885,7 @@ set(viewer_HEADER_FILES llpaneltopinfobar.h llpanelvolume.h llpanelvolumepulldown.h + llpanelwearing.h llparcelselection.h llparticipantlist.h llpatchvertexarray.h diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 5728256dba..017fcf6e2b 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -48,7 +48,6 @@ #include "llmd5.h" #include "llnotificationsutil.h" #include "lloutfitobserver.h" -#include "llpaneloutfitsinventory.h" #include "llsidepanelappearance.h" #include "llsidetray.h" #include "lltexlayer.h" @@ -1232,45 +1231,6 @@ void LLAgentWearables::createStandardWearablesAllDone() gAgentAvatarp->onFirstTEMessageReceived(); } - -class LLShowCreatedOutfit: public LLInventoryCallback -{ -public: - LLShowCreatedOutfit(LLUUID& folder_id): - mFolderID(folder_id) - { - } - - virtual ~LLShowCreatedOutfit() - { - LLSD key; - LLSideTray::getInstance()->showPanel("panel_outfits_inventory", key); - LLPanelOutfitsInventory *outfit_panel = - dynamic_cast(LLSideTray::getInstance()->getPanel("panel_outfits_inventory")); - // TODO: add handling "My Outfits" tab. - if (outfit_panel && outfit_panel->isCOFPanelActive()) - { - outfit_panel->getRootFolder()->clearSelection(); - outfit_panel->getRootFolder()->setSelectionByID(mFolderID, TRUE); - } - LLAccordionCtrlTab* tab_outfits = outfit_panel ? outfit_panel->findChild("tab_outfits") : 0; - if (tab_outfits && !tab_outfits->getDisplayChildren()) - { - tab_outfits->changeOpenClose(tab_outfits->getDisplayChildren()); - } - - LLAppearanceMgr::instance().updateIsDirty(); - LLAppearanceMgr::instance().updatePanelOutfitName(""); - } - - virtual void fire(const LLUUID&) - { - } - -private: - LLUUID mFolderID; -}; - void LLAgentWearables::makeNewOutfitDone(S32 type, U32 index) { LLUUID first_item_id = getWearableItemID((LLWearableType::EType)type, index); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index f088a620d6..597076503d 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -45,7 +45,7 @@ #include "llinventoryobserver.h" #include "llnotificationsutil.h" #include "lloutfitobserver.h" -#include "llpaneloutfitsinventory.h" +#include "lloutfitslist.h" #include "llselectmgr.h" #include "llsidepanelappearance.h" #include "llsidetray.h" @@ -2306,18 +2306,11 @@ public: { LLSideTray::getInstance()->showPanel("panel_outfits_inventory", key); } - LLPanelOutfitsInventory *outfit_panel = - dynamic_cast(LLSideTray::getInstance()->getPanel("panel_outfits_inventory")); - if (outfit_panel) + LLOutfitsList *outfits_list = + dynamic_cast(LLSideTray::getInstance()->getPanel("outfitslist_tab")); + if (outfits_list) { - outfit_panel->getRootFolder()->clearSelection(); - outfit_panel->getRootFolder()->setSelectionByID(mFolderID, TRUE); - } - - LLAccordionCtrlTab* tab_outfits = outfit_panel ? outfit_panel->findChild("tab_outfits") : 0; - if (tab_outfits && !tab_outfits->getDisplayChildren()) - { - tab_outfits->changeOpenClose(tab_outfits->getDisplayChildren()); + outfits_list->setSelectedOutfitByUUID(mFolderID); } LLAppearanceMgr::getInstance()->updateIsDirty(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index afaeddaaeb..a5f24c55fe 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -72,7 +72,6 @@ #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llwearablelist.h" -#include "llpaneloutfitsinventory.h" typedef std::pair two_uuids_t; typedef std::list two_uuids_list_t; @@ -511,17 +510,6 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { const LLInventoryObject *obj = getInventoryObject(); - bool is_sidepanel = isInOutfitsSidePanel(); - if (is_sidepanel) - { - // Sidepanel includes restricted menu. - if (obj && obj->getIsLinkType() && !get_is_item_worn(mUUID)) - { - items.push_back(std::string("Remove Link")); - } - return; - } - if (obj) { if (obj->getIsLinkType()) @@ -948,16 +936,6 @@ void LLInvFVBridge::purgeItem(LLInventoryModel *model, const LLUUID &uuid) } } -BOOL LLInvFVBridge::isInOutfitsSidePanel() const -{ - LLInventoryPanel *my_panel = dynamic_cast(mInventoryPanel.get()); - LLPanelOutfitsInventory *outfit_panel = - dynamic_cast(LLSideTray::getInstance()->getPanel("panel_outfits_inventory")); - if (!outfit_panel) - return FALSE; - return outfit_panel->isTabPanel(my_panel); -} - BOOL LLInvFVBridge::canShare() const { const LLInventoryModel* model = getInventoryModel(); @@ -2430,17 +2408,8 @@ void LLFolderBridge::folderOptionsMenu() const bool is_ensemble = (type == LLFolderType::FT_NONE || LLFolderType::lookupIsEnsembleType(type)); - // calling card related functionality for folders. - - const bool is_sidepanel = isInOutfitsSidePanel(); - if (is_sidepanel) - { - mItems.push_back("Rename"); - addDeleteContextMenuOptions(mItems, disabled_items); - } - // Only enable calling-card related options for non-system folders. - if (!is_sidepanel && !is_system_folder) + if (!is_system_folder) { LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD); if (mCallingCards || checkFolderForContentsOfType(model, is_callingcard)) @@ -2469,10 +2438,7 @@ void LLFolderBridge::folderOptionsMenu() checkFolderForContentsOfType(model, is_object) || checkFolderForContentsOfType(model, is_gesture) ) { - if (!is_sidepanel) - { - mItems.push_back(std::string("Folder Wearables Separator")); - } + mItems.push_back(std::string("Folder Wearables Separator")); // Only enable add/replace outfit for non-system folders. if (!is_system_folder) @@ -3763,13 +3729,6 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Share")); } - bool is_sidepanel = isInOutfitsSidePanel(); - - if (!is_sidepanel) - { - addOpenRightClickMenuOption(items); - items.push_back(std::string("Properties")); - } getClipboardEntries(true, items, disabled_items, flags); @@ -4071,12 +4030,8 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Share")); } - bool is_sidepanel = isInOutfitsSidePanel(); - if (!is_sidepanel) - { - items.push_back(std::string("Properties")); - } + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); @@ -4431,24 +4386,17 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Share")); } - bool is_sidepanel = isInOutfitsSidePanel(); - if (can_open && !is_sidepanel) + if (can_open) { addOpenRightClickMenuOption(items); } - if (!is_sidepanel) - { - items.push_back(std::string("Properties")); - } + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); - if (!is_sidepanel) - { - items.push_back(std::string("Wearable Separator")); - } + items.push_back(std::string("Wearable Separator")); items.push_back(std::string("Wearable Edit")); diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 64d0f8d254..97e87c2f3b 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -74,7 +74,6 @@ public: U32 flags = 0x00); virtual ~LLInvFVBridge() {} - BOOL isInOutfitsSidePanel() const; // allow context menus to be customized for side panel BOOL canShare() const; //-------------------------------------------------------------------- diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index b3d39f2a4a..a285926a8b 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -162,7 +162,7 @@ protected: static LLRegisterPanelClassWrapper t_outfits_list("outfits_list"); LLOutfitsList::LLOutfitsList() - : LLPanel() + : LLPanelAppearanceTab() , mAccordion(NULL) , mListCommands(NULL) , mIsInitialized(false) @@ -313,7 +313,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) // If filter is currently applied we store the initial tab state and // open it to show matched items if any. - if (!mFilterSubString.empty()) + if (!sFilterSubString.empty()) { tab->notifyChildren(LLSD().with("action","store_state")); tab->setDisplayChildren(true); @@ -323,7 +323,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) // filter to the newly added list. list->setForceRefresh(true); - list->setFilterSubString(mFilterSubString); + list->setFilterSubString(sFilterSubString); } } @@ -415,14 +415,74 @@ void LLOutfitsList::performAction(std::string action) } } +void LLOutfitsList::removeSelected() +{ + if (mSelectedOutfitUUID.notNull()) + { + remove_category(&gInventory, mSelectedOutfitUUID); + } +} + +void LLOutfitsList::setSelectedOutfitByUUID(const LLUUID& outfit_uuid) +{ + for (outfits_map_t::iterator iter = mOutfitsMap.begin(); + iter != mOutfitsMap.end(); + ++iter) + { + if (outfit_uuid == iter->first) + { + LLAccordionCtrlTab* tab = iter->second; + if (!tab) continue; + + LLWearableItemsList* list = dynamic_cast(tab->getAccordionView()); + if (!list) continue; + + tab->setFocus(TRUE); + changeOutfitSelection(list, outfit_uuid); + + tab->setDisplayChildren(true); + } + } +} + +// virtual void LLOutfitsList::setFilterSubString(const std::string& string) { applyFilter(string); - mFilterSubString = string; + sFilterSubString = string; +} + +bool LLOutfitsList::isActionEnabled(const LLSD& userdata) +{ + const std::string command_name = userdata.asString(); + if (command_name == "delete") + { + return !mItemSelected && LLAppearanceMgr::instance().getCanRemoveOutfit(mSelectedOutfitUUID); + } + if (command_name == "rename") + { + return get_is_category_renameable(&gInventory, mSelectedOutfitUUID); + } + if (command_name == "save_outfit") + { + bool outfit_locked = LLAppearanceMgr::getInstance()->isOutfitLocked(); + bool outfit_dirty = LLAppearanceMgr::getInstance()->isOutfitDirty(); + // allow save only if outfit isn't locked and is dirty + return !outfit_locked && outfit_dirty; + } + if (command_name == "wear") + { + return mSelectedOutfitUUID.notNull(); + } + if (command_name == "take_off") + { + return LLAppearanceMgr::getInstance()->getBaseOutfitUUID() == mSelectedOutfitUUID; + } + return false; } -boost::signals2::connection LLOutfitsList::addSelectionChangeCallback(selection_change_callback_t cb) +boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb) { return mSelectionChangeSignal.connect(cb); } @@ -558,7 +618,7 @@ void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) { - if (!ctrl || mFilterSubString.empty()) + if (!ctrl || sFilterSubString.empty()) return; for (outfits_map_t::iterator @@ -572,7 +632,7 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) LLWearableItemsList* list = dynamic_cast(tab->getAccordionView()); if (list != ctrl) continue; - applyFilterToTab(iter->first, tab, mFilterSubString); + applyFilterToTab(iter->first, tab, sFilterSubString); } } @@ -588,7 +648,7 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; - bool more_restrictive = mFilterSubString.size() < new_filter_substring.size() && !new_filter_substring.substr(0, mFilterSubString.size()).compare(mFilterSubString); + bool more_restrictive = sFilterSubString.size() < new_filter_substring.size() && !new_filter_substring.substr(0, sFilterSubString.size()).compare(sFilterSubString); // Restore tab visibility in case of less restrictive filter // to compare it with updated string if it was previously hidden. @@ -603,7 +663,7 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) list->setFilterSubString(new_filter_substring); } - if(mFilterSubString.empty() && !new_filter_substring.empty()) + if(sFilterSubString.empty() && !new_filter_substring.empty()) { //store accordion tab state when filter is not empty tab->notifyChildren(LLSD().with("action","store_state")); diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index a6b9a66836..14a1aab415 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -37,12 +37,14 @@ // newview #include "llinventorymodel.h" -#include "llinventoryobserver.h" +#include "llpanelappearancetab.h" class LLAccordionCtrlTab; +class LLInventoryCategoriesObserver; class LLWearableItemsList; class LLListContextMenu; + /** * @class LLOutfitTabNameComparator * @@ -66,9 +68,9 @@ public: * which displays each outfit in an accordion tab with a flat list * of items inside it. * - * Starts fetching nevessary inventory content on first openning. + * Starts fetching necessary inventory content on first opening. */ -class LLOutfitsList : public LLPanel +class LLOutfitsList : public LLPanelAppearanceTab { public: typedef boost::function selection_change_callback_t; @@ -88,11 +90,17 @@ public: void performAction(std::string action); - void setFilterSubString(const std::string& string); + void removeSelected(); + + void setSelectedOutfitByUUID(const LLUUID& outfit_uuid); + + /*virtual*/ void setFilterSubString(const std::string& string); + + /*virtual*/ bool isActionEnabled(const LLSD& userdata); const LLUUID& getSelectedOutfitUUID() const { return mSelectedOutfitUUID; } - boost::signals2::connection addSelectionChangeCallback(selection_change_callback_t cb); + boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb); /** * Returns true if there is a selection inside currently selected outfit @@ -184,13 +192,11 @@ private: LLUUID mHighlightedOutfitUUID; selection_change_signal_t mSelectionChangeSignal; - std::string mFilterSubString; - typedef std::map outfits_map_t; typedef outfits_map_t::value_type outfits_map_value_t; outfits_map_t mOutfitsMap; - LLListContextMenu* mOutfitMenu; + LLListContextMenu* mOutfitMenu; bool mIsInitialized; /** diff --git a/indra/newview/llpanelappearancetab.h b/indra/newview/llpanelappearancetab.h index c2f8dbd074..af984c521c 100644 --- a/indra/newview/llpanelappearancetab.h +++ b/indra/newview/llpanelappearancetab.h @@ -1,6 +1,6 @@ /** - * @file llpanelplacestab.h - * @brief Tabs interface for Side Bar "Places" panel + * @file llpanelappearancetab.h + * @brief Tabs interface for Side Bar "My Appearance" panel * * $LicenseInfo:firstyear=2009&license=viewergpl$ * @@ -34,28 +34,20 @@ #include "llpanel.h" -#include "llpanelappearance.h" - class LLPanelAppearanceTab : public LLPanel { public: - LLPanelAppearanceTab(LLPanelAppearance *parent) : - LLPanel(), - mParent(parent) - {} + LLPanelAppearanceTab() : LLPanel() {} virtual ~LLPanelAppearanceTab() {} - virtual void onSearchEdit(const std::string& string) = 0; - virtual void updateVerbs() = 0; // Updates buttons at the bottom of Appearance panel - virtual void onWear() = 0; - virtual void onEdit() = 0; - virtual void onNew() = 0; + virtual void setFilterSubString(const std::string& string) = 0; - bool isTabVisible(); // Check if parent TabContainer is visible. + virtual bool isActionEnabled(const LLSD& userdata) = 0; + static const std::string& getFilterSubString() { return sFilterSubString; } protected: - LLPanelAppearance* mParent; + static std::string sFilterSubString; }; #endif //LL_LLPANELAPPEARANCETAB_H diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 77c135c716..57c82b7ac4 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -33,40 +33,23 @@ #include "llpaneloutfitsinventory.h" -#include "llagent.h" -#include "llagentwearables.h" -#include "llappearancemgr.h" +#include "llmenugl.h" +#include "llnotificationsutil.h" +#include "lltabcontainer.h" -#include "llbutton.h" -#include "llfloaterreg.h" -#include "llfloaterworldmap.h" -#include "llfloaterinventory.h" -#include "llfoldervieweventlistener.h" -#include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventorypanel.h" -#include "lllandmark.h" -#include "lllineeditor.h" -#include "llmodaldialog.h" -#include "llnotificationsutil.h" +#include "llagentwearables.h" +#include "llappearancemgr.h" #include "lloutfitobserver.h" #include "lloutfitslist.h" +#include "llpanelwearing.h" #include "llsaveoutfitcombobtn.h" #include "llsidepanelappearance.h" #include "llsidetray.h" -#include "lltabcontainer.h" #include "llviewerfoldertype.h" -#include "llviewerjointattachment.h" -#include "llvoavatarself.h" - -// List Commands -#include "lldndbutton.h" -#include "llmenugl.h" #include "llviewermenu.h" -#include "llviewercontrol.h" - static const std::string OUTFITS_TAB_NAME = "outfitslist_tab"; static const std::string COF_TAB_NAME = "cof_tab"; @@ -246,11 +229,10 @@ private: LLPanelOutfitsInventory::LLPanelOutfitsInventory() : mMyOutfitsPanel(NULL), mCurrentOutfitPanel(NULL), + mActivePanel(NULL), mGearMenu(NULL), mInitialized(false) { - mSavedFolderState = new LLSaveFolderState(); - mSavedFolderState->setApply(FALSE); gAgentWearables.addLoadedCallback(boost::bind(&LLPanelOutfitsInventory::onWearablesLoaded, this)); gAgentWearables.addLoadingStartedCallback(boost::bind(&LLPanelOutfitsInventory::onWearablesLoading, this)); @@ -263,7 +245,6 @@ LLPanelOutfitsInventory::LLPanelOutfitsInventory() : LLPanelOutfitsInventory::~LLPanelOutfitsInventory() { delete mGearMenu; - delete mSavedFolderState; } // virtual @@ -305,7 +286,8 @@ void LLPanelOutfitsInventory::onOpen(const LLSD& key) // and update verbs. onTabChange(); - // Auto open the first outfit newly created so new users can see sample outfit contents + // *TODO: Auto open the first outfit newly created so new users can see sample outfit contents + /* static bool should_open_outfit = true; if (should_open_outfit && gAgent.isFirstLogin()) { @@ -325,6 +307,7 @@ void LLPanelOutfitsInventory::onOpen(const LLSD& key) } } should_open_outfit = false; + */ } void LLPanelOutfitsInventory::updateVerbs() @@ -338,93 +321,30 @@ void LLPanelOutfitsInventory::updateVerbs() // virtual void LLPanelOutfitsInventory::onSearchEdit(const std::string& string) { - mFilterSubString = string; + if (!mActivePanel) return; - // TODO: add handling "My Outfits" tab. - if (!isCOFPanelActive()) - { - mMyOutfitsPanel->setFilterSubString(string); - return; - } + mFilterSubString = string; if (string == "") { - getActivePanel()->setFilterSubString(LLStringUtil::null); - - // re-open folders that were initially open - mSavedFolderState->setApply(TRUE); - getRootFolder()->applyFunctorRecursively(*mSavedFolderState); - LLOpenFoldersWithSelection opener; - getRootFolder()->applyFunctorRecursively(opener); - getRootFolder()->scrollToShowSelection(); + mActivePanel->setFilterSubString(LLStringUtil::null); } LLInventoryModelBackgroundFetch::instance().start(); - if (getActivePanel()->getFilterSubString().empty() && string.empty()) + if (mActivePanel->getFilterSubString().empty() && string.empty()) { // current filter and new filter empty, do nothing return; } - // save current folder open state if no filter currently applied - if (getRootFolder()->getFilterSubString().empty()) - { - mSavedFolderState->setApply(FALSE); - getRootFolder()->applyFunctorRecursively(*mSavedFolderState); - } - // set new filter string - getActivePanel()->setFilterSubString(string); + mActivePanel->setFilterSubString(string); } void LLPanelOutfitsInventory::onWearButtonClick() { - // TODO: Remove if/else, add common interface - // for "My Outfits" and "Wearing" tabs. - if (!isCOFPanelActive()) - { - mMyOutfitsPanel->performAction("replaceoutfit"); - } - else - { - LLFolderViewEventListener* listenerp = getCorrectListenerForAction(); - if (listenerp) - { - listenerp->performAction(NULL, "replaceoutfit"); - } - } -} - -void LLPanelOutfitsInventory::onAdd() -{ - // TODO: Remove if/else, add common interface - // for "My Outfits" and "Wearing" tabs. - if (!isCOFPanelActive()) - { - mMyOutfitsPanel->performAction("addtooutfit"); - } - else - { - LLFolderViewEventListener* listenerp = getCorrectListenerForAction(); - if (listenerp) - { - listenerp->performAction(NULL, "addtooutfit"); - } - } -} - -void LLPanelOutfitsInventory::onRemove() -{ - LLFolderViewEventListener* listenerp = getCorrectListenerForAction(); - if (listenerp) - { - listenerp->performAction(NULL, "removefromoutfit"); - } -} - -void LLPanelOutfitsInventory::onEdit() -{ + mMyOutfitsPanel->performAction("replaceoutfit"); } bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD& response) @@ -454,8 +374,6 @@ bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD& return false; } - - void LLPanelOutfitsInventory::onSave() { std::string outfit_name; @@ -483,57 +401,6 @@ void LLPanelOutfitsInventory::onSave() }*/ } -void LLPanelOutfitsInventory::onSelectionChange(const std::deque &items, BOOL user_action) -{ - updateVerbs(); - - // TODO: add handling "My Outfits" tab. - if (!isCOFPanelActive()) - return; - - if (getRootFolder()->needsAutoRename() && items.size()) - { - getRootFolder()->startRenamingSelectedItem(); - getRootFolder()->setNeedsAutoRename(FALSE); - } -} - -LLFolderViewEventListener *LLPanelOutfitsInventory::getCorrectListenerForAction() -{ - // TODO: add handling "My Outfits" tab. - if (!isCOFPanelActive()) - return NULL; - - LLFolderViewItem* current_item = getRootFolder()->getCurSelectedItem(); - if (!current_item) - return NULL; - - LLFolderViewEventListener* listenerp = current_item->getListener(); - if (getIsCorrectType(listenerp)) - { - return listenerp; - } - return NULL; -} - -bool LLPanelOutfitsInventory::getIsCorrectType(const LLFolderViewEventListener *listenerp) const -{ - if (listenerp->getInventoryType() == LLInventoryType::IT_CATEGORY) - { - LLViewerInventoryCategory *cat = gInventory.getCategory(listenerp->getUUID()); - if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) - { - return true; - } - } - return false; -} - -LLFolderView *LLPanelOutfitsInventory::getRootFolder() -{ - return getActivePanel()->getRootFolder(); -} - //static LLPanelOutfitsInventory* LLPanelOutfitsInventory::findInstance() { @@ -551,13 +418,6 @@ void LLPanelOutfitsInventory::initListCommandsHandlers() mListCommands->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); - LLDragAndDropButton* trash_btn = mListCommands->getChild("trash_btn"); - trash_btn->setDragAndDropHandler(boost::bind(&LLPanelOutfitsInventory::handleDragAndDropToTrash, this - , _4 // BOOL drop - , _5 // EDragAndDropType cargo_type - , _7 // EAcceptance* accept - )); - mGearMenu = new LLOutfitListGearMenu(mMyOutfitsPanel, this); } @@ -568,6 +428,9 @@ void LLPanelOutfitsInventory::updateListCommands() bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); + // *TODO: Enable gear menu for Wearing tab. + childSetEnabled("options_gear_btn", wear_visible); + mListCommands->childSetEnabled("trash_btn", trash_enabled); mListCommands->childSetEnabled("wear_btn", wear_enabled); mListCommands->childSetVisible("wear_btn", wear_visible); @@ -584,263 +447,52 @@ void LLPanelOutfitsInventory::showGearMenu() void LLPanelOutfitsInventory::onTrashButtonClick() { - onClipboardAction("delete"); -} + mMyOutfitsPanel->removeSelected(); -void LLPanelOutfitsInventory::onClipboardAction(const LLSD& userdata) -{ - std::string command_name = userdata.asString(); - if (isCOFPanelActive()) - { - getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name); - } - else // "My Outfits" tab active - { - if (command_name == "delete") - { - const LLUUID& selected_outfit_id = mMyOutfitsPanel->getSelectedOutfitUUID(); - if (selected_outfit_id.notNull()) - { - remove_category(&gInventory, selected_outfit_id); - } - } - else - { - llwarns << "Unrecognized action" << llendl; - } - } - updateListCommands(); - updateVerbs(); + updateListCommands(); + updateVerbs(); } -void LLPanelOutfitsInventory::onCustomAction(const LLSD& userdata) +bool LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) { - if (!isActionEnabled(userdata)) - return; - - const std::string command_name = userdata.asString(); - if (command_name == "new") - { - onSave(); - } - if (command_name == "edit") - { - onEdit(); - } - if (command_name == "wear") - { - onWearButtonClick(); - } - // Note: This option has been removed from the gear menu. - if (command_name == "add") - { - onAdd(); - } - if (command_name == "remove") - { - onRemove(); - } - if (command_name == "rename") - { - onClipboardAction("rename"); - } - if (command_name == "remove_link") - { - onClipboardAction("delete"); - } - if (command_name == "delete") - { - onClipboardAction("delete"); - } - updateListCommands(); - updateVerbs(); -} - -BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) -{ - const std::string command_name = userdata.asString(); - if (command_name == "delete" || command_name == "remove") - { - BOOL can_delete = FALSE; - - if (isCOFPanelActive()) - { - LLFolderView* root = getActivePanel()->getRootFolder(); - if (root) - { - std::set selection_set = root->getSelectionList(); - can_delete = (selection_set.size() > 0); - for (std::set::iterator iter = selection_set.begin(); - iter != selection_set.end(); - ++iter) - { - const LLUUID &item_id = (*iter); - LLFolderViewItem *item = root->getItemByID(item_id); - can_delete &= item->getListener()->isItemRemovable(); - } - } - } - else // "My Outfits" tab active - { - const LLUUID& selected_outfit = mMyOutfitsPanel->getSelectedOutfitUUID(); - // first condition prevents trash btn from enabling when items are selected inside outfit (EXT-7847) - can_delete = !mMyOutfitsPanel->hasItemSelected() && LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit); - } - - return can_delete; - } - if (command_name == "remove_link") - { - BOOL can_delete = FALSE; - LLFolderView* root = getActivePanel()->getRootFolder(); - if (root) - { - std::set selection_set = root->getSelectionList(); - can_delete = (selection_set.size() > 0); - for (std::set::iterator iter = selection_set.begin(); - iter != selection_set.end(); - ++iter) - { - const LLUUID &item_id = (*iter); - LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (!item || !item->getIsLinkType()) - return FALSE; - } - return can_delete; - } - return FALSE; - } - if (command_name == "rename" || - command_name == "delete_outfit") - { - return (getCorrectListenerForAction() != NULL) && hasItemsSelected(); - } - - if (command_name == "wear") - { + return mActivePanel && mActivePanel->isActionEnabled(userdata); if (gAgentWearables.isCOFChangeInProgress()) return FALSE; - if (isCOFPanelActive()) - { - return FALSE; - } - return hasItemsSelected(); - } - if (command_name == "save_outfit") - { - bool outfit_locked = LLAppearanceMgr::getInstance()->isOutfitLocked(); - bool outfit_dirty =LLAppearanceMgr::getInstance()->isOutfitDirty(); - // allow save only if outfit isn't locked and is dirty - return !outfit_locked && outfit_dirty; - } - - if (command_name == "edit" || - command_name == "add" - ) - { - return (getCorrectListenerForAction() != NULL); - } - return TRUE; -} - -bool LLPanelOutfitsInventory::hasItemsSelected() -{ - bool has_items_selected = false; - - if (isCOFPanelActive()) - { - LLFolderView* root = getActivePanel()->getRootFolder(); - if (root) - { - std::set selection_set = root->getSelectionList(); - has_items_selected = (selection_set.size() > 0); - } - } - else // My Outfits Tab is active - { - has_items_selected = mMyOutfitsPanel->getSelectedOutfitUUID().notNull(); - } - return has_items_selected; -} - -bool LLPanelOutfitsInventory::handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept) -{ - *accept = ACCEPT_NO; - - const bool is_enabled = isActionEnabled("delete"); - if (is_enabled) *accept = ACCEPT_YES_MULTI; - - if (is_enabled && drop) - { - onClipboardAction("delete"); - } - return true; } - -// List Commands // -//////////////////////////////////////////////////////////////////////////////// +// List Commands // +////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// -// Tab panels // +// Tab panels // void LLPanelOutfitsInventory::initTabPanels() { - mCurrentOutfitPanel = getChild(COF_TAB_NAME); - mCurrentOutfitPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - mCurrentOutfitPanel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onTabSelectionChange, this, mCurrentOutfitPanel, _1, _2)); + mCurrentOutfitPanel = getChild(COF_TAB_NAME); + mCurrentOutfitPanel->setSelectionChangeCallback(boost::bind(&LLPanelOutfitsInventory::updateVerbs, this)); mMyOutfitsPanel = getChild(OUTFITS_TAB_NAME); - mMyOutfitsPanel->addSelectionChangeCallback(boost::bind(&LLPanelOutfitsInventory::updateVerbs, this)); + mMyOutfitsPanel->setSelectionChangeCallback(boost::bind(&LLPanelOutfitsInventory::updateVerbs, this)); mAppearanceTabs = getChild("appearance_tabs"); mAppearanceTabs->setCommitCallback(boost::bind(&LLPanelOutfitsInventory::onTabChange, this)); } -void LLPanelOutfitsInventory::onTabSelectionChange(LLInventoryPanel* tab_panel, const std::deque &items, BOOL user_action) -{ - if (user_action && items.size() > 0) - { - // TODO: add handling "My Outfits" tab. - if (isCOFPanelActive()) - { - onSelectionChange(items, user_action); - } - else - { - mCurrentOutfitPanel->getRootFolder()->clearSelection(); - } - } -} - void LLPanelOutfitsInventory::onTabChange() { - // TODO: add handling "My Outfits" tab. - if (isCOFPanelActive()) - { - mCurrentOutfitPanel->setFilterSubString(mFilterSubString); - } - else - { - mMyOutfitsPanel->setFilterSubString(mFilterSubString); - mMyOutfitsPanel->onOpen(LLSD()); - } + mActivePanel = dynamic_cast(mAppearanceTabs->getCurrentPanel()); + if (!mActivePanel) return; + + mActivePanel->setFilterSubString(mFilterSubString); + mActivePanel->onOpen(LLSD()); updateVerbs(); } -BOOL LLPanelOutfitsInventory::isTabPanel(LLInventoryPanel *panel) const +bool LLPanelOutfitsInventory::isCOFPanelActive() const { - // TODO: add handling "My Outfits" tab. - if (mCurrentOutfitPanel == panel) - { - return TRUE; - } - return FALSE; -} + if (!mActivePanel) return false; -BOOL LLPanelOutfitsInventory::isCOFPanelActive() const -{ - return (childGetVisibleTab("appearance_tabs")->getName() == COF_TAB_NAME); + return mActivePanel->getName() == COF_TAB_NAME; } void LLPanelOutfitsInventory::setWearablesLoading(bool val) diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index 287fcbf4bb..ff5d8b96bc 100644 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -34,20 +34,15 @@ #define LL_LLPANELOUTFITSINVENTORY_H #include "llpanel.h" -#include "llinventoryobserver.h" -class LLFolderView; -class LLFolderViewItem; -class LLFolderViewEventListener; -class LLInventoryPanel; class LLOutfitsList; -class LLSaveFolderState; -class LLButton; +class LLOutfitListGearMenu; +class LLPanelAppearanceTab; +class LLPanelWearing; class LLMenuGL; class LLSidepanelAppearance; class LLTabContainer; class LLSaveOutfitComboBtn; -class LLOutfitListGearMenu; class LLPanelOutfitsInventory : public LLPanel { @@ -60,55 +55,36 @@ public: /*virtual*/ void onOpen(const LLSD& key); void onSearchEdit(const std::string& string); - void onAdd(); - void onRemove(); - void onEdit(); void onSave(); bool onSaveCommit(const LLSD& notification, const LLSD& response); - void onSelectionChange(const std::deque &items, BOOL user_action); - - // If a compatible listener type is selected, then return a pointer to that. - // Otherwise, return NULL. - LLFolderViewEventListener* getCorrectListenerForAction(); - - LLFolderView* getRootFolder(); static LLSidepanelAppearance* getAppearanceSP(); static LLPanelOutfitsInventory* findInstance(); protected: void updateVerbs(); - bool getIsCorrectType(const LLFolderViewEventListener *listenerp) const; private: - LLSaveFolderState* mSavedFolderState; LLTabContainer* mAppearanceTabs; std::string mFilterSubString; std::auto_ptr mSaveComboBtn; -public: - ////////////////////////////////////////////////////////////////////////////////// - // tab panels - // TODO: change getActivePanel() to return the active tab instead of returning - // a pointer to "Wearing" inventory panel. - LLInventoryPanel* getActivePanel() { return mCurrentOutfitPanel; } - - BOOL isTabPanel(LLInventoryPanel *panel) const; - BOOL isCOFPanelActive() const; + ////////////////////////////////////////////////////////////////////////////////// + // tab panels // protected: void initTabPanels(); - void onTabSelectionChange(LLInventoryPanel* tab_panel, const std::deque &items, BOOL user_action); void onTabChange(); + bool isCOFPanelActive() const; private: + LLPanelAppearanceTab* mActivePanel; LLOutfitsList* mMyOutfitsPanel; - LLInventoryPanel* mCurrentOutfitPanel; + LLPanelWearing* mCurrentOutfitPanel; - // tab panels // - //////////////////////////////////////////////////////////////////////////////// - + // tab panels // + ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // List Commands // @@ -121,10 +97,7 @@ protected: void onWearButtonClick(); void showGearMenu(); void onTrashButtonClick(); - void onClipboardAction(const LLSD& userdata); - void onCustomAction(const LLSD& command_name); - bool handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept); - bool hasItemsSelected(); + bool isActionEnabled(const LLSD& userdata); void setWearablesLoading(bool val); void onWearablesLoaded(); void onWearablesLoading(); @@ -132,9 +105,8 @@ private: LLPanel* mListCommands; LLOutfitListGearMenu* mGearMenu; LLMenuGL* mMenuAdd; - // List Commands // - //////////////////////////////////////////////////////////////////////////////// - /// + // List Commands // + ////////////////////////////////////////////////////////////////////////////////// bool mInitialized; }; diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp new file mode 100644 index 0000000000..27f13a8093 --- /dev/null +++ b/indra/newview/llpanelwearing.cpp @@ -0,0 +1,130 @@ +/** + * @file llpanelwearing.cpp + * @brief List of agent's worn items. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelwearing.h" + +#include "llappearancemgr.h" +#include "llinventorymodel.h" +#include "llinventoryobserver.h" +#include "llwearableitemslist.h" + + +std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null; + +static LLRegisterPanelClassWrapper t_panel_wearing("panel_wearing"); + +LLPanelWearing::LLPanelWearing() + : LLPanelAppearanceTab() + , mCOFItemsList(NULL) + , mIsInitialized(false) +{ + mCategoriesObserver = new LLInventoryCategoriesObserver(); +} + +LLPanelWearing::~LLPanelWearing() +{ + if (gInventory.containsObserver(mCategoriesObserver)) + { + gInventory.removeObserver(mCategoriesObserver); + delete mCategoriesObserver; + } +} + +BOOL LLPanelWearing::postBuild() +{ + mCOFItemsList = getChild("cof_items_list"); + return TRUE; +} + +//virtual +void LLPanelWearing::onOpen(const LLSD& /*info*/) +{ + if (!mIsInitialized) + { + // *TODO: I'm not sure is this check necessary but it never match while developing. + if (!gInventory.isInventoryUsable()) + return; + + const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + + // *TODO: I'm not sure is this check necessary but it never match while developing. + LLViewerInventoryCategory* category = gInventory.getCategory(cof); + if (!category) + return; + + gInventory.addObserver(mCategoriesObserver); + + // Start observing changes in Current Outfit category. + mCategoriesObserver->addCategory(cof, boost::bind(&LLWearableItemsList::updateList, mCOFItemsList, cof)); + + // Fetch Current Outfit contents and refresh the list to display + // initially fetched items. If not all items are fetched now + // the observer will refresh the list as soon as the new items + // arrive. + category->fetch(); + + mCOFItemsList->updateList(cof); + + mIsInitialized = true; + } +} + +// virtual +void LLPanelWearing::setFilterSubString(const std::string& string) +{ + sFilterSubString = string; + mCOFItemsList->setFilterSubString(sFilterSubString); +} + +bool LLPanelWearing::isActionEnabled(const LLSD& userdata) +{ + const std::string command_name = userdata.asString(); + + if (command_name == "save_outfit") + { + bool outfit_locked = LLAppearanceMgr::getInstance()->isOutfitLocked(); + bool outfit_dirty = LLAppearanceMgr::getInstance()->isOutfitDirty(); + // allow save only if outfit isn't locked and is dirty + return !outfit_locked && outfit_dirty; + } + return false; +} + +boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_callback_t cb) +{ + if (!mCOFItemsList) return boost::signals2::connection(); + + return mCOFItemsList->setCommitCallback(cb); +} + +// EOF diff --git a/indra/newview/llpanelwearing.h b/indra/newview/llpanelwearing.h new file mode 100644 index 0000000000..15d0a3dd6d --- /dev/null +++ b/indra/newview/llpanelwearing.h @@ -0,0 +1,73 @@ +/** + * @file llpanelwearing.h + * @brief List of agent's worn items. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANELWEARING_H +#define LL_LLPANELWEARING_H + +#include "llpanel.h" + +// newview +#include "llpanelappearancetab.h" + +class LLInventoryCategoriesObserver; +class LLWearableItemsList; + +/** + * @class LLPanelWearing + * + * A list of agents's currently worn items represented by + * a flat list view. + * Starts fetching necessary inventory content on first opening. + */ +class LLPanelWearing : public LLPanelAppearanceTab +{ +public: + LLPanelWearing(); + virtual ~LLPanelWearing(); + + /*virtual*/ BOOL postBuild(); + + /*virtual*/ void onOpen(const LLSD& info); + + /*virtual*/ void setFilterSubString(const std::string& string); + + /*virtual*/ bool isActionEnabled(const LLSD& userdata); + + boost::signals2::connection setSelectionChangeCallback(commit_callback_t cb); + +private: + LLInventoryCategoriesObserver* mCategoriesObserver; + LLWearableItemsList* mCOFItemsList; + + bool mIsInitialized; +}; + +#endif //LL_LLPANELWEARING_H diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 6aa6ebaa54..da15b93697 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -95,19 +95,22 @@ LLPanelWearableListItem::LLPanelWearableListItem(LLViewerInventoryItem* item) ////////////////////////////////////////////////////////////////////////// // static -LLPanelWearableOutfitItem* LLPanelWearableOutfitItem::create(LLViewerInventoryItem* item) +LLPanelWearableOutfitItem* LLPanelWearableOutfitItem::create(LLViewerInventoryItem* item, + bool worn_indication_enabled) { LLPanelWearableOutfitItem* list_item = NULL; if (item) { - list_item = new LLPanelWearableOutfitItem(item); + list_item = new LLPanelWearableOutfitItem(item, worn_indication_enabled); list_item->init(); } return list_item; } -LLPanelWearableOutfitItem::LLPanelWearableOutfitItem(LLViewerInventoryItem* item) +LLPanelWearableOutfitItem::LLPanelWearableOutfitItem(LLViewerInventoryItem* item, + bool worn_indication_enabled) : LLPanelInventoryListItemBase(item) +, mWornIndicationEnabled(worn_indication_enabled) { } @@ -117,7 +120,7 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name, { std::string search_label = name; - if (get_is_item_worn(mInventoryItemUUID)) + if (mWornIndicationEnabled && get_is_item_worn(mInventoryItemUUID)) { search_label += LLTrans::getString("worn"); item_state = IS_WORN; @@ -444,6 +447,7 @@ static const LLDefaultChildRegistry::Register r("wearable_i LLWearableItemsList::Params::Params() : standalone("standalone", true) +, worn_indication_enabled("worn_indication_enabled", true) {} LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p) @@ -456,6 +460,7 @@ LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p) // Use built-in context menu. setRightMouseDownCallback(boost::bind(&LLWearableItemsList::onRightClick, this, _2, _3)); } + mWornIndicationEnabled = p.worn_indication_enabled; } // virtual @@ -471,7 +476,7 @@ void LLWearableItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrange llassert(item != NULL); } - LLPanelWearableOutfitItem *list_item = LLPanelWearableOutfitItem::create(item); + LLPanelWearableOutfitItem *list_item = LLPanelWearableOutfitItem::create(item, mWornIndicationEnabled); if (!list_item) return; diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h index 2bfb90e3ec..eb82418454 100644 --- a/indra/newview/llwearableitemslist.h +++ b/indra/newview/llwearableitemslist.h @@ -82,7 +82,8 @@ class LLPanelWearableOutfitItem : public LLPanelInventoryListItemBase { LOG_CLASS(LLPanelWearableOutfitItem); public: - static LLPanelWearableOutfitItem* create(LLViewerInventoryItem* item); + static LLPanelWearableOutfitItem* create(LLViewerInventoryItem* item, + bool worn_indication_enabled); /** * Updates item name and (worn) suffix. @@ -91,7 +92,11 @@ public: EItemState item_state = IS_DEFAULT); protected: - LLPanelWearableOutfitItem(LLViewerInventoryItem* item); + LLPanelWearableOutfitItem(LLViewerInventoryItem* item, + bool worn_indication_enabled); + +private: + bool mWornIndicationEnabled; }; class LLPanelDeletableWearableListItem : public LLPanelWearableListItem @@ -352,6 +357,7 @@ public: struct Params : public LLInitParam::Block { Optional standalone; + Optional worn_indication_enabled; Params(); }; @@ -377,6 +383,7 @@ protected: void onRightClick(S32 x, S32 y); bool mIsStandalone; + bool mWornIndicationEnabled; }; #endif //LL_LLWEARABLEITEMSLIST_H diff --git a/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml b/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml index a59070496e..9cd14c00fc 100644 --- a/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml @@ -34,22 +34,31 @@ follows="all" label="MY OUTFITS" layout="topleft" - width="315" /> - + + width="312"> + + - Date: Tue, 22 Jun 2010 16:34:27 +0300 Subject: EXT-4295 FIXED Added gear and context menus for Wearing tab. - Moved My Outfits gear menu from llpaneloutfitsinventory.cpp to lloutfitslist.cpp Revieved by Neal Orman and Mike Antipov at https://codereview.productengine.com/secondlife/r/604/. --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 165 +++++++++++++++++- indra/newview/lloutfitslist.h | 4 + indra/newview/llpanelappearancetab.h | 2 + indra/newview/llpaneloutfitsinventory.cpp | 186 +-------------------- indra/newview/llpaneloutfitsinventory.h | 4 - indra/newview/llpanelwearing.cpp | 84 ++++++++++ indra/newview/llpanelwearing.h | 8 + .../skins/default/xui/en/menu_wearing_gear.xml | 12 ++ .../skins/default/xui/en/menu_wearing_tab.xml | 12 ++ .../default/xui/en/panel_outfits_inventory.xml | 1 + 10 files changed, 284 insertions(+), 194 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/menu_wearing_gear.xml create mode 100644 indra/newview/skins/default/xui/en/menu_wearing_tab.xml (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index a285926a8b..b8489d450b 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -70,7 +70,148 @@ bool LLOutfitTabNameComparator::compare(const LLAccordionCtrlTab* tab1, const LL ////////////////////////////////////////////////////////////////////////// -class OutfitContextMenu : public LLListContextMenu +class LLOutfitListGearMenu +{ +public: + LLOutfitListGearMenu(LLOutfitsList* olist) + : mOutfitList(olist), + mMenu(NULL) + { + llassert_always(mOutfitList); + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + registrar.add("Gear.Wear", boost::bind(&LLOutfitListGearMenu::onWear, this)); + registrar.add("Gear.TakeOff", boost::bind(&LLOutfitListGearMenu::onTakeOff, this)); + registrar.add("Gear.Rename", boost::bind(&LLOutfitListGearMenu::onRename, this)); + registrar.add("Gear.Delete", boost::bind(&LLOutfitListGearMenu::onDelete, this)); + registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2)); + + enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitsList::isActionEnabled, mOutfitList, _2)); + enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenu::onVisible, this, _2)); + + mMenu = LLUICtrlFactory::getInstance()->createFromFile( + "menu_outfit_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + llassert(mMenu); + } + + void show(LLView* spawning_view) + { + if (!mMenu) return; + + updateItemsVisibility(); + mMenu->buildDrawLabels(); + mMenu->updateParent(LLMenuGL::sMenuContainer); + S32 menu_x = 0; + S32 menu_y = spawning_view->getRect().getHeight() + mMenu->getRect().getHeight(); + LLMenuGL::showPopup(spawning_view, mMenu, menu_x, menu_y); + } + + void updateItemsVisibility() + { + if (!mMenu) return; + + bool have_selection = getSelectedOutfitID().notNull(); + mMenu->setItemVisible("sepatator1", have_selection); + mMenu->setItemVisible("sepatator2", have_selection); + mMenu->arrangeAndClear(); // update menu height + } + +private: + const LLUUID& getSelectedOutfitID() + { + return mOutfitList->getSelectedOutfitUUID(); + } + + LLViewerInventoryCategory* getSelectedOutfit() + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.isNull()) + { + return NULL; + } + + LLViewerInventoryCategory* cat = gInventory.getCategory(selected_outfit_id); + return cat; + } + + void onWear() + { + LLViewerInventoryCategory* selected_outfit = getSelectedOutfit(); + if (selected_outfit) + { + LLAppearanceMgr::instance().wearInventoryCategory( + selected_outfit, /*copy=*/ FALSE, /*append=*/ FALSE); + } + } + + void onTakeOff() + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.notNull()) + { + LLAppearanceMgr::instance().takeOffOutfit(selected_outfit_id); + } + } + + void onRename() + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.notNull()) + { + LLAppearanceMgr::instance().renameOutfit(selected_outfit_id); + } + } + + void onDelete() + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.notNull()) + { + remove_category(&gInventory, selected_outfit_id); + } + } + + void onCreate(const LLSD& data) + { + LLWearableType::EType type = LLWearableType::typeNameToType(data.asString()); + if (type == LLWearableType::WT_NONE) + { + llwarns << "Invalid wearable type" << llendl; + return; + } + + LLAgentWearables::createWearable(type, true); + } + + bool onVisible(LLSD::String param) + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.isNull()) // no selection or invalid outfit selected + { + return false; + } + + // *TODO This condition leads to menu item behavior inconsistent with + // "Wear" button behavior and should be modified or removed. + bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == selected_outfit_id; + + if ("wear" == param) + { + return !is_worn; + } + + return true; + } + + LLOutfitsList* mOutfitList; + LLMenuGL* mMenu; +}; + +////////////////////////////////////////////////////////////////////////// + +class LLOutfitContextMenu : public LLListContextMenu { protected: /* virtual */ LLContextMenu* createMenu() @@ -89,8 +230,8 @@ protected: registrar.add("Outfit.Rename", boost::bind(renameOutfit, selected_id)); registrar.add("Outfit.Delete", boost::bind(deleteOutfit, selected_id)); - enable_registrar.add("Outfit.OnEnable", boost::bind(&OutfitContextMenu::onEnable, this, _2)); - enable_registrar.add("Outfit.OnVisible", boost::bind(&OutfitContextMenu::onVisible, this, _2)); + enable_registrar.add("Outfit.OnEnable", boost::bind(&LLOutfitContextMenu::onEnable, this, _2)); + enable_registrar.add("Outfit.OnVisible", boost::bind(&LLOutfitContextMenu::onVisible, this, _2)); return createFromFile("menu_outfit_tab.xml"); } @@ -170,11 +311,13 @@ LLOutfitsList::LLOutfitsList() { mCategoriesObserver = new LLInventoryCategoriesObserver(); - mOutfitMenu = new OutfitContextMenu(); + mGearMenu = new LLOutfitListGearMenu(this); + mOutfitMenu = new LLOutfitContextMenu(); } LLOutfitsList::~LLOutfitsList() { + delete mGearMenu; delete mOutfitMenu; if (gInventory.containsObserver(mCategoriesObserver)) @@ -453,8 +596,11 @@ void LLOutfitsList::setFilterSubString(const std::string& string) sFilterSubString = string; } +// virtual bool LLOutfitsList::isActionEnabled(const LLSD& userdata) { + if (mSelectedOutfitUUID.isNull()) return false; + const std::string command_name = userdata.asString(); if (command_name == "delete") { @@ -473,7 +619,7 @@ bool LLOutfitsList::isActionEnabled(const LLSD& userdata) } if (command_name == "wear") { - return mSelectedOutfitUUID.notNull(); + return !gAgentWearables.isCOFChangeInProgress(); } if (command_name == "take_off") { @@ -482,6 +628,13 @@ bool LLOutfitsList::isActionEnabled(const LLSD& userdata) return false; } +// virtual +void LLOutfitsList::showGearMenu(LLView* spawning_view) +{ + if (!mGearMenu) return; + mGearMenu->show(spawning_view); +} + boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb) { return mSelectionChangeSignal.connect(cb); @@ -761,7 +914,7 @@ void LLOutfitsList::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y) uuid_vec_t selected_uuids; - // Collect seleted items from all selected lists. + // Collect selected items from all selected lists. for (wearables_lists_map_t::iterator iter = mSelectedListsMap.begin(); iter != mSelectedListsMap.end(); ++iter) diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 14a1aab415..d207624792 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -41,6 +41,7 @@ class LLAccordionCtrlTab; class LLInventoryCategoriesObserver; +class LLOutfitListGearMenu; class LLWearableItemsList; class LLListContextMenu; @@ -98,6 +99,8 @@ public: /*virtual*/ bool isActionEnabled(const LLSD& userdata); + /*virtual*/ void showGearMenu(LLView* spawning_view); + const LLUUID& getSelectedOutfitUUID() const { return mSelectedOutfitUUID; } boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb); @@ -196,6 +199,7 @@ private: typedef outfits_map_t::value_type outfits_map_value_t; outfits_map_t mOutfitsMap; + LLOutfitListGearMenu* mGearMenu; LLListContextMenu* mOutfitMenu; bool mIsInitialized; diff --git a/indra/newview/llpanelappearancetab.h b/indra/newview/llpanelappearancetab.h index af984c521c..f1901a63a4 100644 --- a/indra/newview/llpanelappearancetab.h +++ b/indra/newview/llpanelappearancetab.h @@ -44,6 +44,8 @@ public: virtual bool isActionEnabled(const LLSD& userdata) = 0; + virtual void showGearMenu(LLView* spawning_view) = 0; + static const std::string& getFilterSubString() { return sFilterSubString; } protected: diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 57c82b7ac4..2f1cad8a75 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -33,7 +33,6 @@ #include "llpaneloutfitsinventory.h" -#include "llmenugl.h" #include "llnotificationsutil.h" #include "lltabcontainer.h" @@ -48,189 +47,16 @@ #include "llsidepanelappearance.h" #include "llsidetray.h" #include "llviewerfoldertype.h" -#include "llviewermenu.h" static const std::string OUTFITS_TAB_NAME = "outfitslist_tab"; static const std::string COF_TAB_NAME = "cof_tab"; static LLRegisterPanelClassWrapper t_inventory("panel_outfits_inventory"); -class LLPanelOutfitsInventory; -class LLOutfitListGearMenu -{ -public: - LLOutfitListGearMenu(LLOutfitsList* olist, LLPanelOutfitsInventory* parent_panel) - : mOutfitList(olist), - mMyOutfitsPanel(parent_panel), - mMenu(NULL) - { - llassert_always(mOutfitList); - - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - - registrar.add("Gear.Wear", boost::bind(&LLOutfitListGearMenu::onWear, this)); - registrar.add("Gear.TakeOff", boost::bind(&LLOutfitListGearMenu::onTakeOff, this)); - registrar.add("Gear.Rename", boost::bind(&LLOutfitListGearMenu::onRename, this)); - registrar.add("Gear.Delete", boost::bind(&LLOutfitListGearMenu::onDelete, this)); - registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2)); - - enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenu::onEnable, this, _2)); - enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenu::onVisible, this, _2)); - - mMenu = LLUICtrlFactory::getInstance()->createFromFile( - "menu_outfit_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - llassert(mMenu); - } - - LLMenuGL* getMenu() { return mMenu; } - - void show(LLView* spawning_view) - { - if (!mMenu) return; - - updateItemsVisibility(); - mMenu->buildDrawLabels(); - mMenu->updateParent(LLMenuGL::sMenuContainer); - S32 menu_x = 0; - S32 menu_y = spawning_view->getRect().getHeight() + mMenu->getRect().getHeight(); - LLMenuGL::showPopup(spawning_view, mMenu, menu_x, menu_y); - } - - void updateItemsVisibility() - { - if (!mMenu) return; - - bool have_selection = getSelectedOutfitID().notNull(); - mMenu->setItemVisible("sepatator1", have_selection); - mMenu->setItemVisible("sepatator2", have_selection); - mMenu->arrangeAndClear(); // update menu height - } - -private: - const LLUUID& getSelectedOutfitID() - { - return mOutfitList->getSelectedOutfitUUID(); - } - - LLViewerInventoryCategory* getSelectedOutfit() - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.isNull()) - { - return NULL; - } - - LLViewerInventoryCategory* cat = gInventory.getCategory(selected_outfit_id); - return cat; - } - - void onWear() - { - LLViewerInventoryCategory* selected_outfit = getSelectedOutfit(); - if (selected_outfit) - { - LLAppearanceMgr::instance().wearInventoryCategory( - selected_outfit, /*copy=*/ FALSE, /*append=*/ FALSE); - } - } - - void onTakeOff() - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.notNull()) - { - LLAppearanceMgr::instance().takeOffOutfit(selected_outfit_id); - } - } - - void onRename() - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.notNull()) - { - LLAppearanceMgr::instance().renameOutfit(selected_outfit_id); - } - } - - void onDelete() - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.notNull()) - { - remove_category(&gInventory, selected_outfit_id); - } - } - - void onCreate(const LLSD& data) - { - LLWearableType::EType type = LLWearableType::typeNameToType(data.asString()); - if (type == LLWearableType::WT_NONE) - { - llwarns << "Invalid wearable type" << llendl; - return; - } - - LLAgentWearables::createWearable(type, true); - } - - bool onEnable(LLSD::String param) - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.isNull()) // no selection or invalid outfit selected - { - return false; - } - - if ("rename" == param) - { - return get_is_category_renameable(&gInventory, selected_outfit_id); - } - else if ("delete" == param) - { - return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id); - } - else if ("take_off" == param) - { - return LLAppearanceMgr::getCanRemoveFromCOF(selected_outfit_id); - } - else if ("wear" == param) - { - return mMyOutfitsPanel->isActionEnabled(param); - } - - - return true; - } - - bool onVisible(LLSD::String param) - { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.isNull()) // no selection or invalid outfit selected - { - return false; - } - - bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == selected_outfit_id; - - if ("wear" == param) - { - return !is_worn; - } - - return true; - } - - LLOutfitsList* mOutfitList; - LLMenuGL* mMenu; - LLPanelOutfitsInventory* mMyOutfitsPanel; -}; - LLPanelOutfitsInventory::LLPanelOutfitsInventory() : mMyOutfitsPanel(NULL), mCurrentOutfitPanel(NULL), mActivePanel(NULL), - mGearMenu(NULL), mInitialized(false) { gAgentWearables.addLoadedCallback(boost::bind(&LLPanelOutfitsInventory::onWearablesLoaded, this)); @@ -244,7 +70,6 @@ LLPanelOutfitsInventory::LLPanelOutfitsInventory() : LLPanelOutfitsInventory::~LLPanelOutfitsInventory() { - delete mGearMenu; } // virtual @@ -417,8 +242,6 @@ void LLPanelOutfitsInventory::initListCommandsHandlers() mListCommands->childSetAction("options_gear_btn", boost::bind(&LLPanelOutfitsInventory::showGearMenu, this)); mListCommands->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); - - mGearMenu = new LLOutfitListGearMenu(mMyOutfitsPanel, this); } void LLPanelOutfitsInventory::updateListCommands() @@ -428,9 +251,6 @@ void LLPanelOutfitsInventory::updateListCommands() bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); - // *TODO: Enable gear menu for Wearing tab. - childSetEnabled("options_gear_btn", wear_visible); - mListCommands->childSetEnabled("trash_btn", trash_enabled); mListCommands->childSetEnabled("wear_btn", wear_enabled); mListCommands->childSetVisible("wear_btn", wear_visible); @@ -439,10 +259,10 @@ void LLPanelOutfitsInventory::updateListCommands() void LLPanelOutfitsInventory::showGearMenu() { - if (!mGearMenu) return; + if (!mActivePanel) return; LLView* spawning_view = getChild("options_gear_btn"); - mGearMenu->show(spawning_view); + mActivePanel->showGearMenu(spawning_view); } void LLPanelOutfitsInventory::onTrashButtonClick() @@ -456,8 +276,6 @@ void LLPanelOutfitsInventory::onTrashButtonClick() bool LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) { return mActivePanel && mActivePanel->isActionEnabled(userdata); - if (gAgentWearables.isCOFChangeInProgress()) return FALSE; - } // List Commands // ////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index ff5d8b96bc..a50e047140 100644 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -88,9 +88,6 @@ private: ////////////////////////////////////////////////////////////////////////////////// // List Commands // -public: - BOOL isActionEnabled(const LLSD& command_name); - protected: void initListCommandsHandlers(); void updateListCommands(); @@ -103,7 +100,6 @@ protected: void onWearablesLoading(); private: LLPanel* mListCommands; - LLOutfitListGearMenu* mGearMenu; LLMenuGL* mMenuAdd; // List Commands // ////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index 27f13a8093..b8852890ad 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -36,8 +36,64 @@ #include "llappearancemgr.h" #include "llinventorymodel.h" #include "llinventoryobserver.h" +#include "llsidetray.h" +#include "llviewermenu.h" #include "llwearableitemslist.h" +// Context menu and Gear menu helper. +static void edit_outfit() +{ + LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_outfit")); +} + +////////////////////////////////////////////////////////////////////////// + +class LLWearingGearMenu +{ +public: + LLWearingGearMenu() + : mMenu(NULL) + { + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + + registrar.add("Gear.Edit", boost::bind(&edit_outfit)); + + mMenu = LLUICtrlFactory::getInstance()->createFromFile( + "menu_wearing_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + llassert(mMenu); + } + + void show(LLView* spawning_view) + { + if (!mMenu) return; + + mMenu->buildDrawLabels(); + mMenu->updateParent(LLMenuGL::sMenuContainer); + S32 menu_x = 0; + S32 menu_y = spawning_view->getRect().getHeight() + mMenu->getRect().getHeight(); + LLMenuGL::showPopup(spawning_view, mMenu, menu_x, menu_y); + } + +private: + LLMenuGL* mMenu; +}; + +////////////////////////////////////////////////////////////////////////// + +class LLWearingContextMenu : public LLListContextMenu +{ +protected: + /* virtual */ LLContextMenu* createMenu() + { + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + + registrar.add("Wearing.Edit", boost::bind(&edit_outfit)); + + return createFromFile("menu_wearing_tab.xml"); + } +}; + +////////////////////////////////////////////////////////////////////////// std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null; @@ -49,10 +105,16 @@ LLPanelWearing::LLPanelWearing() , mIsInitialized(false) { mCategoriesObserver = new LLInventoryCategoriesObserver(); + + mGearMenu = new LLWearingGearMenu(); + mContextMenu = new LLWearingContextMenu(); } LLPanelWearing::~LLPanelWearing() { + delete mGearMenu; + delete mContextMenu; + if (gInventory.containsObserver(mCategoriesObserver)) { gInventory.removeObserver(mCategoriesObserver); @@ -63,6 +125,8 @@ LLPanelWearing::~LLPanelWearing() BOOL LLPanelWearing::postBuild() { mCOFItemsList = getChild("cof_items_list"); + mCOFItemsList->setRightMouseDownCallback(boost::bind(&LLPanelWearing::onWearableItemsListRightClick, this, _1, _2, _3)); + return TRUE; } @@ -106,6 +170,7 @@ void LLPanelWearing::setFilterSubString(const std::string& string) mCOFItemsList->setFilterSubString(sFilterSubString); } +// virtual bool LLPanelWearing::isActionEnabled(const LLSD& userdata) { const std::string command_name = userdata.asString(); @@ -120,6 +185,13 @@ bool LLPanelWearing::isActionEnabled(const LLSD& userdata) return false; } +// virtual +void LLPanelWearing::showGearMenu(LLView* spawning_view) +{ + if (!mGearMenu) return; + mGearMenu->show(spawning_view); +} + boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_callback_t cb) { if (!mCOFItemsList) return boost::signals2::connection(); @@ -127,4 +199,16 @@ boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_ca return mCOFItemsList->setCommitCallback(cb); } +void LLPanelWearing::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y) +{ + LLWearableItemsList* list = dynamic_cast(ctrl); + if (!list) return; + + uuid_vec_t selected_uuids; + + list->getSelectedUUIDs(selected_uuids); + + mContextMenu->show(ctrl, selected_uuids, x, y); +} + // EOF diff --git a/indra/newview/llpanelwearing.h b/indra/newview/llpanelwearing.h index 15d0a3dd6d..1573990d13 100644 --- a/indra/newview/llpanelwearing.h +++ b/indra/newview/llpanelwearing.h @@ -38,7 +38,9 @@ #include "llpanelappearancetab.h" class LLInventoryCategoriesObserver; +class LLListContextMenu; class LLWearableItemsList; +class LLWearingGearMenu; /** * @class LLPanelWearing @@ -61,11 +63,17 @@ public: /*virtual*/ bool isActionEnabled(const LLSD& userdata); + /*virtual*/ void showGearMenu(LLView* spawning_view); + boost::signals2::connection setSelectionChangeCallback(commit_callback_t cb); private: + void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y); + LLInventoryCategoriesObserver* mCategoriesObserver; LLWearableItemsList* mCOFItemsList; + LLWearingGearMenu* mGearMenu; + LLListContextMenu* mContextMenu; bool mIsInitialized; }; diff --git a/indra/newview/skins/default/xui/en/menu_wearing_gear.xml b/indra/newview/skins/default/xui/en/menu_wearing_gear.xml new file mode 100644 index 0000000000..84431a2f69 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_wearing_gear.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/indra/newview/skins/default/xui/en/menu_wearing_tab.xml b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml new file mode 100644 index 0000000000..85505f9972 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml b/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml index 9cd14c00fc..b365540d1f 100644 --- a/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_outfits_inventory.xml @@ -53,6 +53,7 @@ left="1" multi_select="true" name="cof_items_list" + standalone="false" top="0" translate="false" width="310" -- cgit v1.3 From 9aad53a4370b7647e4f907be7c3dc908906491b9 Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Thu, 24 Jun 2010 01:52:26 +0300 Subject: EXT-7158 FIXED Implemented showing of full outfit content if its name or any item(s) inside it match current filter. - Added availability to force showing unmatched items to LLFlatListViewEx - Applied it to wearable items lists in LLOutfitsList - Changed condition for outfit accordion tab showing (because now all items are visible, so checking their number doesn't help). Used here check for a flag added in this fix, which tells whether last applied filter found any matches in the list. Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/648/ --HG-- branch : product-engine --- indra/llui/llflatlistview.cpp | 21 ++++++++++++++++++++- indra/llui/llflatlistview.h | 17 +++++++++++++++++ indra/newview/lloutfitslist.cpp | 7 ++++++- 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index c7463e581c..f22b49f30f 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1226,6 +1226,8 @@ LLFlatListViewEx::LLFlatListViewEx(const Params& p) : LLFlatListView(p) , mNoFilteredItemsMsg(p.no_filtered_items_msg) , mNoItemsMsg(p.no_items_msg) +, mForceShowingUnmatchedItems(false) +, mLastFilterSucceded(false) { } @@ -1250,6 +1252,16 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string) } +bool LLFlatListViewEx::getForceShowingUnmatchedItems() +{ + return mForceShowingUnmatchedItems; +} + +void LLFlatListViewEx::setForceShowingUnmatchedItems(bool show) +{ + mForceShowingUnmatchedItems = show; +} + void LLFlatListViewEx::setFilterSubString(const std::string& filter_str) { if (0 != LLStringUtil::compareInsensitive(filter_str, mFilterSubString)) @@ -1273,6 +1285,7 @@ void LLFlatListViewEx::filterItems() item_panel_list_t items; getItems(items); + mLastFilterSucceded = false; for (item_panel_list_t::iterator iter = items.begin(), iter_end = items.end(); @@ -1283,13 +1296,14 @@ void LLFlatListViewEx::filterItems() // i.e. we don't hide items that don't support 'match_filter' action, separators etc. if (0 == pItem->notify(action)) { + mLastFilterSucceded = true; pItem->setVisible(true); } else { // TODO: implement (re)storing of current selection. selectItem(pItem, false); - pItem->setVisible(false); + pItem->setVisible(mForceShowingUnmatchedItems); } } @@ -1297,4 +1311,9 @@ void LLFlatListViewEx::filterItems() notifyParentItemsRectChanged(); } +bool LLFlatListViewEx::wasLasFilterSuccessfull() +{ + return mLastFilterSucceded; +} + //EOF diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index 0820a7ab67..caeddfc179 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -470,6 +470,10 @@ public: void setNoItemsMsg(const std::string& msg) { mNoItemsMsg = msg; } void setNoFilteredItemsMsg(const std::string& msg) { mNoFilteredItemsMsg = msg; } + bool getForceShowingUnmatchedItems(); + + void setForceShowingUnmatchedItems(bool show); + /** * Sets up new filter string and filters the list. */ @@ -481,6 +485,11 @@ public: */ void filterItems(); + /** + * Returns true if last call of filterItems() found at least one matching item + */ + bool wasLasFilterSuccessfull(); + protected: LLFlatListViewEx(const Params& p); @@ -496,6 +505,14 @@ private: std::string mNoFilteredItemsMsg; std::string mNoItemsMsg; std::string mFilterSubString; + /** + * Show list items that don't match current filter + */ + bool mForceShowingUnmatchedItems; + /** + * True if last call of filterItems() found at least one matching item + */ + bool mLastFilterSucceded; }; #endif diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index b8489d450b..67442dd573 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -439,6 +439,9 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) // Setting callback to reset items selection inside outfit on accordion collapsing and expanding (EXT-7875) tab->setDropDownStateChangedCallback(boost::bind(&LLOutfitsList::resetItemSelection, this, list, cat_id)); + // force showing list items that don't match current filter(EXT-7158) + list->setForceShowingUnmatchedItems(true); + // Setting list commit callback to monitor currently selected wearable item. list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1)); @@ -850,6 +853,8 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) restoreOutfitSelection(tab, iter->first); } } + + mAccordion->arrange(); } void LLOutfitsList::applyFilterToTab( @@ -873,7 +878,7 @@ void LLOutfitsList::applyFilterToTab( { // hide tab if its title doesn't pass filter // and it has no visible items - tab->setVisible(list->size() > 0); + tab->setVisible(list->wasLasFilterSuccessfull()); // remove title highlighting because it might // have been previously highlighted by less restrictive filter -- cgit v1.3