diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-16 17:08:26 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-16 17:18:07 +0300 |
commit | 98f7d73d46fdc045759023eda6409e8c791f5cb2 (patch) | |
tree | f2513de5957516e39b79d14ce469c638b566f55f /indra | |
parent | 738cf84c340d8ade3ab462340d1444c4e70ef9f5 (diff) |
viewer#1424 Finish menus
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 8 | ||||
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 135 | ||||
-rw-r--r-- | indra/newview/lloutfitgallery.h | 23 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llwearableitemslist.cpp | 18 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_outfit_gallery_sort.xml | 42 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_outfit_gear.xml | 16 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_outfit_list_sort.xml (renamed from indra/newview/skins/default/xui/en/menu_outfit_sort.xml) | 0 |
8 files changed, 187 insertions, 67 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5c2e2978d7..48c251240f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -15719,14 +15719,14 @@ <key>Value</key> <integer>1</integer> </map> - <key>OutfitGallerySortByName</key> + <key>OutfitGallerySortOrder</key> <map> <key>Comment</key> - <string>Always sort outfits by name in Outfit Gallery</string> + <string>Gallery sorting: 0 - sort outfits by name, 1 - images frst, 2 - favorites first</string> <key>Persist</key> <integer>1</integer> <key>Type</key> - <string>Boolean</string> + <string>S32</string> <key>Value</key> <integer>0</integer> </map> @@ -15744,7 +15744,7 @@ <key>OutfitListFilterFullList</key> <map> <key>Comment</key> - <string>How outfit list in Avatar's floater is sorted. 0 - by name 1 - favorites to top</string> + <string> 0 - show all items in outfit as long as outfit or item inside matches. 1 - show only matches</string> <key>Persist</key> <integer>1</integer> <key>Type</key> diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 318f0545ea..54a468d029 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -81,7 +81,8 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mItemsInRow(p.items_in_row), mRowPanWidthFactor(p.row_panel_width_factor), mGalleryWidthFactor(p.gallery_width_factor), - mTextureSelected(NULL) + mTextureSelected(NULL), + mSortMenu(nullptr) { updateGalleryWidth(); } @@ -416,18 +417,28 @@ void LLOutfitGallery::updateRowsIfNeeded() bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2) { - if(gSavedSettings.getBOOL("OutfitGallerySortByName") || - ((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage()))) + LLCachedControl<S32> sort_by_name(gSavedSettings, "OutfitGallerySortOrder", 0); + switch (sort_by_name()) { - std::string name1 = item1->getItemName(); - std::string name2 = item2->getItemName(); - - return (LLStringUtil::compareDict(name1, name2) < 0); - } - else - { - return item2->isDefaultImage(); + case 2: + if (item1->isFavorite() != item2->isFavorite()) + { + return item1->isFavorite(); + } + break; + case 1: + if (item1->isDefaultImage() != item2->isDefaultImage()) + { + return item2->isDefaultImage(); + } + break; + default: + break; } + + std::string name1 = item1->getItemName(); + std::string name2 = item2->getItemName(); + return (LLStringUtil::compareDict(name1, name2) < 0); } void LLOutfitGallery::reArrangeRows(S32 row_diff) @@ -1216,24 +1227,9 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility() if (!mMenu) return; bool have_selection = getSelectedOutfitID().notNull(); mMenu->setItemVisible("thumbnail", have_selection); - mMenu->setItemVisible("inventory_settings", false); - mMenu->setItemVisible("inv_settings_separator", false); - mMenu->setItemVisible("sort_order_separator", true); - mMenu->setItemVisible("sort_order_by_image", true); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } -void LLOutfitGalleryGearMenu::onChangeSortOrder() -{ - bool sort_by_name = !gSavedSettings.getBOOL("OutfitGallerySortByName"); - gSavedSettings.setBOOL("OutfitGallerySortByName", sort_by_name); - LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mOutfitList); - if (gallery) - { - gallery->reArrangeRows(); - } -} - bool LLOutfitGalleryGearMenu::hasDefaultImage() { LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mOutfitList); @@ -1336,7 +1332,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) LLToggleableMenu* LLOutfitGallery::getSortMenu() { - return nullptr; + if (!mSortMenu) + { + mSortMenu = new LLOutfitGallerySortMenu(this); + } + return mSortMenu->getMenu(); } LLUUID LLOutfitGallery::getPhotoAssetId(const LLUUID& outfit_id) @@ -1354,3 +1354,84 @@ LLUUID LLOutfitGallery::getDefaultPhoto() return LLUUID(); } + +//////////////////// LLOutfitGallerySortMenu //////////////////// + +LLOutfitGallerySortMenu::LLOutfitGallerySortMenu(LLOutfitListBase* parent_panel) + : mPanelHandle(parent_panel->getHandle()) +{ + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + registrar.add("Sort.OnSort", boost::bind(&LLOutfitGallerySortMenu::onSort, this, _2)); + enable_registrar.add("Sort.OnEnable", boost::bind(&LLOutfitGallerySortMenu::onEnable, this, _2)); + + mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>( + "menu_outfit_gallery_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + llassert(mMenu); +} + + +LLToggleableMenu* LLOutfitGallerySortMenu::getMenu() +{ + return mMenu; +} + +void LLOutfitGallerySortMenu::updateItemsVisibility() +{ + onUpdateItemsVisibility(); +} + +void LLOutfitGallerySortMenu::onUpdateItemsVisibility() +{ + if (!mMenu) return; +} + +bool LLOutfitGallerySortMenu::onEnable(LLSD::String param) +{ + LLCachedControl<S32> sort_order(gSavedSettings, "OutfitGallerySortOrder", 0); + if ("favorites_to_top" == param) + { + return sort_order == 2; + } + else if ("images_to_top" == param) + { + return sort_order == 1; + } + else if ("by_name" == param) + { + return sort_order == 0; + } + + return false; +} + +void LLOutfitGallerySortMenu::onSort(LLSD::String param) +{ + S32 sort_order = gSavedSettings.getS32("OutfitGallerySortOrder"); + S32 new_sort_order = 0; + if ("favorites_to_top" == param) + { + new_sort_order = 2; + } + else if ("images_to_top" == param) + { + new_sort_order = 1; + } + else if ("by_name" == param) + { + new_sort_order = 0; + } + if (sort_order == new_sort_order) + { + new_sort_order = sort_order ? 0 : 1; + } + gSavedSettings.setS32("OutfitGallerySortOrder", new_sort_order); + + LLOutfitGallery* gallery = dynamic_cast<LLOutfitGallery*>(mPanelHandle.get()); + if (gallery) + { + gallery->reArrangeRows(); + } +} + diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 9c6568ce59..de02b0d4be 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -42,11 +42,13 @@ class LLOutfitGalleryItem; class LLOutfitListGearMenuBase; class LLOutfitGalleryGearMenu; class LLOutfitGalleryContextMenu; +class LLOutfitGallerySortMenu; class LLOutfitGallery : public LLOutfitListBase { public: friend class LLOutfitGalleryGearMenu; + friend class LLOutfitGallerySortMenu; friend class LLOutfitGalleryContextMenu; friend class LLUpdateGalleryOnPhotoLinked; @@ -177,6 +179,7 @@ private: int mGalleryWidthFactor; LLListContextMenu* mOutfitGalleryMenu; + LLOutfitGallerySortMenu* mSortMenu; typedef std::map<LLUUID, LLOutfitGalleryItem*> outfit_map_t; typedef outfit_map_t::value_type outfit_map_value_t; @@ -214,8 +217,6 @@ public: protected: /*virtual*/ void onUpdateItemsVisibility(); private: - /*virtual*/ void onChangeSortOrder(); - bool hasDefaultImage(); }; @@ -252,6 +253,7 @@ public: std::string getItemName() {return mOutfitName;} bool isDefaultImage() {return mDefaultImage;} + bool isFavorite() { return mFavorite; } bool isHidden() {return mHidden;} void setHidden(bool hidden) {mHidden = hidden;} @@ -277,4 +279,21 @@ private: static LLUIColor sDefaultFavoriteColor; }; +class LLOutfitGallerySortMenu +{ +public: + LLOutfitGallerySortMenu(LLOutfitListBase* parent_panel); + + LLToggleableMenu* getMenu(); + void updateItemsVisibility(); + +private: + void onUpdateItemsVisibility(); + bool onEnable(LLSD::String param); + void onSort(LLSD::String param); + + LLToggleableMenu* mMenu; + LLHandle<LLPanel> mPanelHandle; +}; + #endif // LL_LLOUTFITGALLERYCTRL_H diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 31cb338687..16cd3935a3 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -1457,10 +1457,6 @@ bool LLOutfitListGearMenuBase::onEnable(LLSD::String param) { return LLAppearanceMgr::instance().getCanReplaceCOF(mOutfitList->getSelectedOutfitUUID()); } - if ("sort_by_image" == param) - { - return !gSavedSettings.getBOOL("OutfitGallerySortByName"); - } return mOutfitList->isActionEnabled(param); } @@ -1516,10 +1512,6 @@ void LLOutfitListGearMenu::onUpdateItemsVisibility() if (!mMenu) return; mMenu->setItemVisible("thumbnail", getSelectedOutfitID().notNull()); mMenu->setItemVisible("favorite", getSelectedOutfitID().notNull()); - mMenu->setItemVisible("inventory_settings", true); - mMenu->setItemVisible("inv_settings_separator", true); - mMenu->setItemVisible("sort_order_separator", false); - mMenu->setItemVisible("sort_order_by_image", false); LLOutfitListGearMenuBase::onUpdateItemsVisibility(); } @@ -1537,7 +1529,7 @@ LLOutfitListSortMenu::LLOutfitListSortMenu(LLOutfitListBase* parent_panel) enable_registrar.add("Sort.OnEnable", boost::bind(&LLOutfitListSortMenu::onEnable, this, _2)); mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>( - "menu_outfit_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + "menu_outfit_list_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); llassert(mMenu); } @@ -1574,7 +1566,7 @@ bool LLOutfitListSortMenu::onEnable(LLSD::String param) return !filter_mode; } - return true; + return false; } diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 0576862dfb..8e44271efb 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -968,9 +968,10 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu U32 n_links = 0; // number of links among the selected items U32 n_editable = 0; // number of editable items among the selected ones U32 n_touchable = 0; // number of touchable items among the selected ones - U32 n_favorites = 0; // number of favorite items among the selected ones bool can_be_worn = true; + bool can_favorite = false; + bool can_unfavorite = false; for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) { @@ -995,7 +996,8 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu LLUUID linked_id = item->getLinkedUUID(); LLViewerInventoryItem* linked_item = gInventory.getItem(linked_id); - const bool is_favorite = linked_item->getIsFavorite(); + can_favorite |= !linked_item->getIsFavorite(); + can_unfavorite |= linked_item->getIsFavorite(); if (is_worn) { @@ -1017,10 +1019,6 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu { ++n_already_worn; } - if (is_favorite) - { - ++n_favorites; - } if (can_be_worn) { @@ -1045,10 +1043,10 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu setMenuItemVisible(menu, "create_new", mask & (MASK_CLOTHING|MASK_BODYPART) && n_items == 1); setMenuItemEnabled(menu, "create_new", LLAppearanceMgr::instance().canAddWearables(ids)); setMenuItemVisible(menu, "show_original", !standalone); - setMenuItemEnabled(menu, "show_original", n_items == 1 && n_links == n_items); - setMenuItemVisible(menu, "favorites_add", n_favorites < n_items); - setMenuItemVisible(menu, "favorites_remove", n_favorites > 0); - setMenuItemVisible(menu, "take_off", mask == MASK_CLOTHING && n_worn == n_items); + setMenuItemEnabled(menu, "show_original", n_items == 1 && n_links == n_items); + setMenuItemVisible(menu, "favorites_add", can_favorite); + setMenuItemVisible(menu, "favorites_remove", can_unfavorite); + setMenuItemVisible(menu, "take_off", mask == MASK_CLOTHING && n_worn == n_items); setMenuItemVisible(menu, "detach", mask == MASK_ATTACHMENT && n_worn == n_items); setMenuItemVisible(menu, "take_off_or_detach", mask == (MASK_ATTACHMENT|MASK_CLOTHING)); setMenuItemEnabled(menu, "take_off_or_detach", n_worn == n_items); diff --git a/indra/newview/skins/default/xui/en/menu_outfit_gallery_sort.xml b/indra/newview/skins/default/xui/en/menu_outfit_gallery_sort.xml new file mode 100644 index 0000000000..aa4cd1483d --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_outfit_gallery_sort.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu + layout="topleft" + visible="false" + name="Sort Outfit"> + <menu_item_check + label="Sort favorites to top" + layout="topleft" + visible="true" + name="sort_favorites_to_top"> + <on_click + function="Sort.OnSort" + parameter="favorites_to_top" /> + <on_check + function="Sort.OnEnable" + parameter="favorites_to_top" /> + </menu_item_check> + <menu_item_check + label="Sort images to top" + layout="topleft" + visible="true" + name="sort_images_to_top"> + <on_click + function="Sort.OnSort" + parameter="images_to_top" /> + <on_check + function="Sort.OnEnable" + parameter="images_to_top" /> + </menu_item_check> + <menu_item_check + label="Sort by name" + layout="topleft" + visible="true" + name="sort_by_name"> + <on_click + function="Sort.OnSort" + parameter="by_name" /> + <on_check + function="Sort.OnEnable" + parameter="by_name" /> + </menu_item_check> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml index bd0c49309d..e333b05d3e 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -109,18 +109,6 @@ function="Gear.OnVisible" parameter="delete" /> </menu_item_call> - <menu_item_separator - name="sort_order_separator"/> - <menu_item_check - label="Show outfits with images first" - layout="topleft" - name="sort_order_by_image"> - <on_click - function="Gear.SortByImage" /> - <on_check - function="Gear.OnEnable" - parameter="sort_by_image" /> - </menu_item_check> <menu_item_separator/> <!-- copied (with minor modifications) from menu_inventory_add.xml --> <!-- *TODO: generate dynamically? --> @@ -282,12 +270,12 @@ </menu> <!-- copied from menu_inventory_add.xml --> - <menu_item_separator - name="inv_settings_separator"/> + <menu_item_separator/> <menu_item_check label="Inventory settings..." layout="topleft" + visible="true" name="inventory_settings"> <menu_item_check.on_check function="Floater.Visible" diff --git a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml b/indra/newview/skins/default/xui/en/menu_outfit_list_sort.xml index 0a4d1ea877..0a4d1ea877 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_list_sort.xml |