From 7d1597fc98868c73d6de0b95f3c1af4c459a30c8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 May 2024 22:16:20 +0300 Subject: viewer#1424 Favorites in Appearance floater #4 --- indra/newview/app_settings/settings.xml | 22 ++++++++ indra/newview/lloutfitgallery.h | 1 + indra/newview/lloutfitslist.cpp | 66 +++++++++++++++++++--- indra/newview/lloutfitslist.h | 3 + .../skins/default/xui/en/menu_outfit_sort.xml | 10 ++-- 5 files changed, 88 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 21afd37a35..5c2e2978d7 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -15730,6 +15730,28 @@ Value 0 + OutfitListSortOrder + + Comment + How outfit list in Avatar's floater is sorted. 0 - by name 1 - favorites to top + Persist + 1 + Type + S32 + Value + 0 + + OutfitListFilterFullList + + Comment + How outfit list in Avatar's floater is sorted. 0 - by name 1 - favorites to top + Persist + 1 + Type + Boolean + Value + 0 + OutfitOperationsTimeout Comment diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index f530212d26..3d36e9a12f 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -102,6 +102,7 @@ public: /*virtual*/ bool getHasExpandableFolders() { return FALSE; } + /*virtual*/ void onChangeSortOrder(const LLSD& userdata) {}; void updateMessageVisibility(); bool hasDefaultImage(const LLUUID& outfit_cat_id); diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 94e242c3ef..d5e82f4112 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -197,8 +197,9 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_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); + // Depending on settings, force showing list items that don't match current filter(EXT-7158) + LLCachedControl list_filter(gSavedSettings, "OutfitListFilterFullList"); + list->setForceShowingUnmatchedItems(list_filter()); // Setting list commit callback to monitor currently selected wearable item. list->setCommitCallback(boost::bind(&LLOutfitsList::onListSelectionChange, this, _1)); @@ -771,6 +772,41 @@ void LLOutfitsList::handleInvFavColorChange() } } +void LLOutfitsList::onChangeSortOrder(const LLSD& userdata) +{ + std::string sort_data = userdata.asString(); + if (sort_data == "favorites_to_top") + { + // at the moment this is a toggle + S32 val = gSavedSettings.getS32("OutfitListSortOrder"); + gSavedSettings.setS32("OutfitListSortOrder", (val ? 0 : 1)); + + const LLUUID outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + refreshList(outfits); + } + else if (sort_data == "show_entire_outfit") + { + bool new_val = !gSavedSettings.getS32("OutfitListFilterFullList"); + gSavedSettings.setBOOL("OutfitListFilterFullList", new_val); + + if (!getFilterSubString().empty()) + { + for (outfits_map_t::value_type& outfit : mOutfitsMap) + { + LLAccordionCtrlTab* tab = outfit.second; + if (!tab) continue; + + LLWearableItemsList* list = dynamic_cast(tab->getAccordionView()); + if (list) + { + list->setForceShowingUnmatchedItems(new_val); + list->setForceRefresh(true); + } + } + } + + } +} LLToggleableMenu* LLOutfitsList::getSortMenu() { @@ -889,21 +925,35 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id) is_category); // Memorize item names for each UUID - std::map names; + struct SortData + { + SortData(std::string name, bool is_favorite) : mName(name), isFavorite(is_favorite) {} + std::string mName; + bool isFavorite; + }; + std::map sort_data; for (const LLPointer& cat : cat_array) { - names.emplace(std::make_pair(cat->getUUID(), cat->getName())); + sort_data.emplace(std::make_pair(cat->getUUID(), SortData(cat->getName(), cat->getIsFavorite()))); } // Fill added and removed items vectors. mRefreshListState.Added.clear(); mRefreshListState.Removed.clear(); computeDifference(cat_array, mRefreshListState.Added, mRefreshListState.Removed); - // Sort added items vector by item name. + + // Sort added items vector according to settings. + S32 sort_order = gSavedSettings.getS32("OutfitListSortOrder"); std::sort(mRefreshListState.Added.begin(), mRefreshListState.Added.end(), - [names](const LLUUID& a, const LLUUID& b) + [sort_data, sort_order](const LLUUID& a, const LLUUID& b) { - return LLStringUtil::compareDict(names.at(a), names.at(b)) < 0; + const SortData& data_a = sort_data.at(a); + const SortData& data_b = sort_data.at(b); + if (sort_order == 1 && data_a.isFavorite != data_b.isFavorite) + { + return data_a.isFavorite; + } + return LLStringUtil::compareDict(data_a.mName, data_b.mName) < 0; }); // Initialize iterators for added and removed items vectors. mRefreshListState.AddedIterator = mRefreshListState.Added.begin(); @@ -1455,7 +1505,7 @@ LLOutfitListSortMenu::LLOutfitListSortMenu(LLOutfitListBase* parent_panel) registrar.add("Sort.Collapse", boost::bind(&LLOutfitListBase::onCollapseAllFolders, parent_panel)); registrar.add("Sort.Expand", boost::bind(&LLOutfitListBase::onExpandAllFolders, parent_panel)); - registrar.add("Sort.OnAction", boost::bind(&LLOutfitListBase::onAction, parent_panel, _2)); + registrar.add("Sort.OnSort", boost::bind(&LLOutfitListBase::onChangeSortOrder, parent_panel, _2)); enable_registrar.add("Sort.OnEnable", boost::bind(&LLOutfitListBase::isActionEnabled, parent_panel, _2)); mMenu = LLUICtrlFactory::getInstance()->createFromFile( diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 94df963977..9a48f9b99d 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -111,6 +111,8 @@ public: virtual bool getHasExpandableFolders() = 0; + virtual void onChangeSortOrder(const LLSD& userdata) = 0; + virtual void updateMenuItemsVisibility(); virtual LLToggleableMenu* getGearMenu(); virtual bool getTrashMenuVisible() { return true; }; @@ -323,6 +325,7 @@ public: /*virtual*/ bool getHasExpandableFolders() { return TRUE; } + /*virtual*/ void onChangeSortOrder(const LLSD& userdata); virtual LLToggleableMenu* getSortMenu(); void updateMenuItemsVisibility(); diff --git a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml b/indra/newview/skins/default/xui/en/menu_outfit_sort.xml index eeee5689a7..98d6301fbb 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_sort.xml @@ -8,8 +8,7 @@ layout="topleft" name="expand"> + function="Sort.Expand" /> + function="Sort.Collapse" /> @@ -28,7 +26,7 @@ layout="topleft" name="sort_favorites_to_top">