From b678d2888c5da04cf4d778b29a60a78c8c1aff5f Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Wed, 2 Jun 2010 16:16:26 +0300 Subject: EXT-7239 FIXED Added wearing double-clicked item or uutfit. - Added outfit list item with double click support. - Added wearing/detaching single item on double click. - Added replacing current outfit with an outfit from double clicked accordion tab. Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/493/. --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 52 +++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 8f189a1e9f..66002d4044 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -49,6 +49,8 @@ #include "llvoavatarself.h" #include "llwearableitemslist.h" +static bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y); + ////////////////////////////////////////////////////////////////////////// class OutfitContextMenu : public LLListContextMenu @@ -176,8 +178,6 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) static LLXMLNodePtr accordionXmlNode = getAccordionTabXMLNode(); LLAccordionCtrlTab* tab = LLUICtrlFactory::defaultBuilder(accordionXmlNode, NULL, NULL); - tab->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onAccordionTabRightClick, this, - _1, _2, _3, cat_id)); tab->setName(name); tab->setTitle(name); @@ -198,6 +198,12 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) // Map the new tab with outfit category UUID. mOutfitsMap.insert(LLOutfitsList::outfits_map_value_t(cat_id, tab)); + tab->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onAccordionTabRightClick, this, + _1, _2, _3, cat_id)); + + tab->setDoubleClickCallback(boost::bind(&LLOutfitsList::onAccordionTabDoubleClick, this, + _1, _2, _3, cat_id)); + // Setting tab focus callback to monitor currently selected outfit. tab->setFocusReceivedCallback(boost::bind(&LLOutfitsList::changeOutfitSelection, this, list, cat_id)); @@ -510,22 +516,30 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) void LLOutfitsList::onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id) { LLAccordionCtrlTab* tab = dynamic_cast(ctrl); - if(mOutfitMenu && tab && tab->getHeaderVisible() && cat_id.notNull()) + if(mOutfitMenu && is_tab_header_clicked(tab, y) && cat_id.notNull()) { - S32 header_bottom = tab->getLocalRect().getHeight() - tab->getHeaderHeight(); - if(y >= header_bottom) + // Focus tab header to trigger tab selection change. + LLUICtrl* header = tab->findChild("dd_header"); + if (header) { - // Focus tab header to trigger tab selection change. - LLUICtrl* header = tab->findChild("dd_header"); - if (header) - { - header->setFocus(TRUE); - } - - uuid_vec_t selected_uuids; - selected_uuids.push_back(cat_id); - mOutfitMenu->show(ctrl, selected_uuids, x, y); + header->setFocus(TRUE); } + + uuid_vec_t selected_uuids; + selected_uuids.push_back(cat_id); + mOutfitMenu->show(ctrl, selected_uuids, x, y); + } +} + +void LLOutfitsList::onAccordionTabDoubleClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id) +{ + LLAccordionCtrlTab* tab = dynamic_cast(ctrl); + if(is_tab_header_clicked(tab, y) && cat_id.notNull()) + { + LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); + if (!cat) return; + + LLAppearanceMgr::instance().wearInventoryCategory( cat, FALSE, FALSE ); } } @@ -551,4 +565,12 @@ void LLOutfitsList::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y) LLWearableItemsList::ContextMenu::instance().show(list, selected_uuids, x, y); } + +bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y) +{ + if(!tab || !tab->getHeaderVisible()) return false; + + S32 header_bottom = tab->getLocalRect().getHeight() - tab->getHeaderHeight(); + return y >= header_bottom; +} // EOF -- cgit v1.2.3 From 4896da3598d00095f573fddde21a84b05661aa79 Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Wed, 2 Jun 2010 16:16:29 +0300 Subject: EXT-7587 FIXED Fixed applying filter highlighting to outfit titles. Reviewed by Neal Orman and Mike Antipov at https://codereview.productengine.com/secondlife/r/496/. --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 66002d4044..98ec272e96 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -432,6 +432,10 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) // hide tab if its title doesn't pass filter // and it has no visible items tab->setVisible(list->size() != 0); + + // remove title highlighting because it might + // have been previously highlighted by less restrictive filter + tab->setTitle(tab->getTitle()); } else { @@ -484,6 +488,10 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) // hide tab if its title doesn't pass filter // and it has no visible items tab->setVisible(list->size() != 0); + + // remove title highlighting because it might + // have been previously highlighted by less restrictive filter + tab->setTitle(tab->getTitle()); } else { -- cgit v1.2.3 From 671625695fc44adc430a7ddf3be158ce26a61cc6 Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Wed, 2 Jun 2010 20:46:16 +0300 Subject: EXT-6726 WIP Added more menus to the Appearance SP. Done: - Implemented creating new wearables via My Outfits gear menu. - Implemented renaming/removing/editing an outfit via My Outfits context menu. - Implemented "Attach to..." / "Attach to HUD..." context submenus. - Now disabling (instead of hiding) irrelevant wearable context menu items. - Added "Take Off / Detach" context menu item that's shown for clothes and attachments. Useful if you selected a bunch of items and want to take them all off. - Fixed taking off an outfit (not all wearables were taken off because of a wrong inventory collector). - Fixed crash when editing a skirt (reference to a missing string). - In LLWearableItemsList::ContextMenu::updateItemsVisibility renamed variables and introduced MASK_UNKNOWN per Nyx's request. Known issues: - "Attach to..." context menus may be displayed partially off-screen (there is the same bug in the inventory panel). - The way we invoke wearable editing panel after the wearable gets created is currently a hack. TODO: - Wear / take off / rename / delete an outfit via My Outfits gear menu (currently not implemented because of missing selection support in My Outfits). - Add "Create new..." to body part / clothing context menu in Edit Outfit. - Add "Create new..." submenus to the Edit Outfit gear menu. Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/466/ --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 142 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 3 deletions(-) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 98ec272e96..5c8b3d1894 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -43,6 +43,8 @@ #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lllistcontextmenu.h" +#include "llnotificationsutil.h" +#include "llsidetray.h" #include "lltransutil.h" #include "llviewermenu.h" #include "llvoavatar.h" @@ -53,6 +55,28 @@ static bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y); ////////////////////////////////////////////////////////////////////////// +// Collect non-removable folders and items. +class LLFindNonRemovableObjects : public LLInventoryCollectFunctor +{ +public: + virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) + { + if (item) + { + return !get_is_item_removable(&gInventory, item->getUUID()); + } + if (cat) + { + return !get_is_category_removable(&gInventory, cat->getUUID()); + } + + llwarns << "Not a category and not an item?" << llendl; + return false; + } +}; + +////////////////////////////////////////////////////////////////////////// + class OutfitContextMenu : public LLListContextMenu { protected: @@ -68,12 +92,124 @@ protected: boost::bind(&LLAppearanceMgr::addCategoryToCurrentOutfit, &LLAppearanceMgr::instance(), selected_id)); registrar.add("Outfit.TakeOff", boost::bind(&LLAppearanceMgr::takeOffOutfit, &LLAppearanceMgr::instance(), selected_id)); - // *TODO: implement this - // registrar.add("Outfit.Rename", boost::bind()); - // registrar.add("Outfit.Delete", boost::bind()); + registrar.add("Outfit.Edit", boost::bind(editOutfit)); + 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)); return createFromFile("menu_outfit_tab.xml"); } + + bool onEnable(const LLSD& data) + { + std::string param = data.asString(); + LLUUID outfit_cat_id = mUUIDs.back(); + bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == outfit_cat_id; + + if ("wear_replace" == param) + { + return !is_worn; + } + else if ("wear_add" == param) + { + return !is_worn; + } + else if ("take_off" == param) + { + return is_worn; + } + else if ("edit" == param) + { + return is_worn; + } + else if ("rename" == param) + { + return get_is_category_renameable(&gInventory, outfit_cat_id); + } + else if ("delete" == param) + { + return canDeleteOutfit(outfit_cat_id); + } + + return true; + } + + static void editOutfit() + { + LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_outfit")); + } + + static void renameOutfit(const LLUUID& outfit_cat_id) + { + LLViewerInventoryCategory* outfit_cat = gInventory.getCategory(outfit_cat_id); + llassert(outfit_cat); + if (!outfit_cat) return; + + LLSD args; + args["NAME"] = outfit_cat->getName(); + + LLSD payload; + payload["cat_id"] = outfit_cat_id; + + LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onRename, _1, _2)); + } + + // User typed new outfit name. + static void onRename(const LLSD& notification, const LLSD& response) + { + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return; // canceled + + std::string outfit_name = response["new_name"].asString(); + LLStringUtil::trim(outfit_name); + if (!outfit_name.empty()) + { + LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); + rename_category(&gInventory, cat_id, outfit_name); + } + } + + static bool canDeleteOutfit(const LLUUID& outfit_cat_id) + { + // Disallow removing the base outfit. + if (outfit_cat_id == LLAppearanceMgr::instance().getBaseOutfitUUID()) + { + return false; + } + + // Check if the outfit folder itself is removable. + if (!get_is_category_removable(&gInventory, outfit_cat_id)) + { + return false; + } + + // Check if the folder contains worn items. + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + LLFindWorn filter_worn; + gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_worn); + if (!items.empty()) + { + return false; + } + + // Check for the folder's non-removable descendants. + LLFindNonRemovableObjects filter_non_removable; + LLInventoryModel::item_array_t::const_iterator it; + gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); + if (!cats.empty() || !items.empty()) + { + return false; + } + + return true; + } + + static void deleteOutfit(const LLUUID& outfit_cat_id) + { + remove_category(&gInventory, outfit_cat_id); + } }; ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 142a6c3b8fa9e286c0336236d1eccd9a6725f06a Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Wed, 2 Jun 2010 20:46:16 +0300 Subject: EXT-6726 WIP Added missing menu items to the Appearance SP. - Hooked up Wear / Take off / Rename / Delete items in the My Outfits gear menu. - Added "Create new..." to body part / clothing context menu in Edit Outfit. - Added "Create new..." submenus to the Edit Outfit gear menu. - Disabling the "Take Off" menu item of the clothing context menu in the Edit Outfit panel when it's irrelevant. Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/494/ --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 92 ++++------------------------------------- 1 file changed, 7 insertions(+), 85 deletions(-) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 5c8b3d1894..94bf2f4c7a 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -55,28 +55,6 @@ static bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y); ////////////////////////////////////////////////////////////////////////// -// Collect non-removable folders and items. -class LLFindNonRemovableObjects : public LLInventoryCollectFunctor -{ -public: - virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) - { - if (item) - { - return !get_is_item_removable(&gInventory, item->getUUID()); - } - if (cat) - { - return !get_is_category_removable(&gInventory, cat->getUUID()); - } - - llwarns << "Not a category and not an item?" << llendl; - return false; - } -}; - -////////////////////////////////////////////////////////////////////////// - class OutfitContextMenu : public LLListContextMenu { protected: @@ -129,7 +107,7 @@ protected: } else if ("delete" == param) { - return canDeleteOutfit(outfit_cat_id); + return LLAppearanceMgr::instance().getCanRemoveOutfit(outfit_cat_id); } return true; @@ -142,68 +120,7 @@ protected: static void renameOutfit(const LLUUID& outfit_cat_id) { - LLViewerInventoryCategory* outfit_cat = gInventory.getCategory(outfit_cat_id); - llassert(outfit_cat); - if (!outfit_cat) return; - - LLSD args; - args["NAME"] = outfit_cat->getName(); - - LLSD payload; - payload["cat_id"] = outfit_cat_id; - - LLNotificationsUtil::add("RenameOutfit", args, payload, boost::bind(onRename, _1, _2)); - } - - // User typed new outfit name. - static void onRename(const LLSD& notification, const LLSD& response) - { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) return; // canceled - - std::string outfit_name = response["new_name"].asString(); - LLStringUtil::trim(outfit_name); - if (!outfit_name.empty()) - { - LLUUID cat_id = notification["payload"]["cat_id"].asUUID(); - rename_category(&gInventory, cat_id, outfit_name); - } - } - - static bool canDeleteOutfit(const LLUUID& outfit_cat_id) - { - // Disallow removing the base outfit. - if (outfit_cat_id == LLAppearanceMgr::instance().getBaseOutfitUUID()) - { - return false; - } - - // Check if the outfit folder itself is removable. - if (!get_is_category_removable(&gInventory, outfit_cat_id)) - { - return false; - } - - // Check if the folder contains worn items. - LLInventoryModel::cat_array_t cats; - LLInventoryModel::item_array_t items; - LLFindWorn filter_worn; - gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_worn); - if (!items.empty()) - { - return false; - } - - // Check for the folder's non-removable descendants. - LLFindNonRemovableObjects filter_non_removable; - LLInventoryModel::item_array_t::const_iterator it; - gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); - if (!cats.empty() || !items.empty()) - { - return false; - } - - return true; + LLAppearanceMgr::instance().renameOutfit(outfit_cat_id); } static void deleteOutfit(const LLUUID& outfit_cat_id) @@ -443,6 +360,10 @@ void LLOutfitsList::performAction(std::string action) { LLAppearanceMgr::instance().wearInventoryCategory( cat, FALSE, TRUE ); } + else if ("rename_outfit" == action) + { + LLAppearanceMgr::instance().renameOutfit(mSelectedOutfitUUID); + } } void LLOutfitsList::setFilterSubString(const std::string& string) @@ -717,4 +638,5 @@ bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y) S32 header_bottom = tab->getLocalRect().getHeight() - tab->getHeaderHeight(); return y >= header_bottom; } + // EOF -- cgit v1.2.3 From 86c230e4902ec06bb65e81b638d60e6b80b51613 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 3 Jun 2010 11:26:38 +0300 Subject: EXT-7503 WIP Made first inventory fetch in My Outfits panel only on first panel opening. * LLOutfitsList is not Inventory Observer anymore * Content is fetched in onOpen now * Added call of the LLOutfitsList::onOpen when "My Outfits" tab is switched on in My Appearance panel Reviewed by Brad Payne at https://codereview.productengine.com/secondlife/r/456/ --HG-- branch : product-engine --- indra/newview/lloutfitslist.cpp | 55 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'indra/newview/lloutfitslist.cpp') diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 98ec272e96..7bf41b0f92 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -84,11 +84,9 @@ LLOutfitsList::LLOutfitsList() : LLPanel() , mAccordion(NULL) , mListCommands(NULL) + , mIsInitialized(false) { mCategoriesObserver = new LLInventoryCategoriesObserver(); - gInventory.addObserver(mCategoriesObserver); - - gInventory.addObserver(this); mOutfitMenu = new OutfitContextMenu(); } @@ -102,11 +100,6 @@ LLOutfitsList::~LLOutfitsList() gInventory.removeObserver(mCategoriesObserver); delete mCategoriesObserver; } - - if (gInventory.containsObserver(this)) - { - gInventory.removeObserver(this); - } } BOOL LLOutfitsList::postBuild() @@ -117,32 +110,36 @@ BOOL LLOutfitsList::postBuild() } //virtual -void LLOutfitsList::changed(U32 mask) +void LLOutfitsList::onOpen(const LLSD& /*info*/) { - if (!gInventory.isInventoryUsable()) - return; + if (!mIsInitialized) + { + // *TODO: I'm not sure is this check necessary but it never match while developing. + if (!gInventory.isInventoryUsable()) + return; - const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - LLViewerInventoryCategory* category = gInventory.getCategory(outfits); - if (!category) - return; + const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + + // *TODO: I'm not sure is this check necessary but it never match while developing. + LLViewerInventoryCategory* category = gInventory.getCategory(outfits); + if (!category) + return; + + gInventory.addObserver(mCategoriesObserver); - // Start observing changes in "My Outfits" category. - mCategoriesObserver->addCategory(outfits, + // Start observing changes in "My Outfits" category. + mCategoriesObserver->addCategory(outfits, boost::bind(&LLOutfitsList::refreshList, this, outfits)); - // Fetch "My Outfits" 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(); - refreshList(outfits); - - // This observer is used to start the initial outfits fetch - // when inventory becomes usable. It is no longer needed because - // "My Outfits" category is now observed by - // LLInventoryCategoriesObserver. - gInventory.removeObserver(this); + // Fetch "My Outfits" 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(); + refreshList(outfits); + + mIsInitialized = true; + } } void LLOutfitsList::refreshList(const LLUUID& category_id) -- cgit v1.2.3