From 98f7d73d46fdc045759023eda6409e8c791f5cb2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 16 May 2024 17:08:26 +0300 Subject: viewer#1424 Finish menus --- indra/newview/app_settings/settings.xml | 8 +- indra/newview/lloutfitgallery.cpp | 135 ++++++++++++++++----- indra/newview/lloutfitgallery.h | 23 +++- indra/newview/lloutfitslist.cpp | 12 +- indra/newview/llwearableitemslist.cpp | 18 ++- .../default/xui/en/menu_outfit_gallery_sort.xml | 42 +++++++ .../skins/default/xui/en/menu_outfit_gear.xml | 16 +-- .../skins/default/xui/en/menu_outfit_list_sort.xml | 49 ++++++++ .../skins/default/xui/en/menu_outfit_sort.xml | 49 -------- 9 files changed, 236 insertions(+), 116 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/menu_outfit_gallery_sort.xml create mode 100644 indra/newview/skins/default/xui/en/menu_outfit_list_sort.xml delete mode 100644 indra/newview/skins/default/xui/en/menu_outfit_sort.xml (limited to 'indra') 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 @@ Value 1 - OutfitGallerySortByName + OutfitGallerySortOrder Comment - Always sort outfits by name in Outfit Gallery + Gallery sorting: 0 - sort outfits by name, 1 - images frst, 2 - favorites first Persist 1 Type - Boolean + S32 Value 0 @@ -15744,7 +15744,7 @@ OutfitListFilterFullList Comment - How outfit list in Avatar's floater is sorted. 0 - by name 1 - favorites to top + 0 - show all items in outfit as long as outfit or item inside matches. 1 - show only matches Persist 1 Type 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 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(mOutfitList); - if (gallery) - { - gallery->reArrangeRows(); - } -} - bool LLOutfitGalleryGearMenu::hasDefaultImage() { LLOutfitGallery* gallery = dynamic_cast(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( + "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 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(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 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 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( - "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 @@ + + + + + + + + + + + + + + + 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" /> - - - - - @@ -282,12 +270,12 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml b/indra/newview/skins/default/xui/en/menu_outfit_sort.xml deleted file mode 100644 index 0a4d1ea877..0000000000 --- a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From 382b45cf227d5ec2063b39e50c4d68d4a5c4dd67 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 16 May 2024 17:58:39 +0300 Subject: viewer#1424 Favorite support in galleries #2 --- indra/newview/lloutfitgallery.cpp | 33 +++++++++++++++++++++++++++++---- indra/newview/lloutfitgallery.h | 3 +++ 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 54a468d029..c428a4ea92 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -85,6 +85,12 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mSortMenu(nullptr) { updateGalleryWidth(); + + LLControlVariable* ctrl = gSavedSettings.getControl("InventoryFavoritesColorText"); + if (ctrl) + { + mSavedSettingInvFavColor = ctrl->getSignal()->connect(boost::bind(&LLOutfitGallery::handleInvFavColorChange, this)); + } } LLOutfitGallery::Params::Params() @@ -481,6 +487,20 @@ void LLOutfitGallery::updateGalleryWidth() mGalleryWidth = mGalleryWidthFactor * mItemsInRow - mItemHorizontalGap; } +void LLOutfitGallery::handleInvFavColorChange() +{ + for (outfit_map_t::iterator iter = mOutfitMap.begin(); + iter != mOutfitMap.end(); + ++iter) + { + if (!iter->second) continue; + LLOutfitGalleryItem* item = (LLOutfitGalleryItem*)iter->second; + + // refresh font color + item->setOutfitFavorite(item->isFavorite()); + } +} + LLPanel* LLOutfitGallery::addLastRow() { mRowCount++; @@ -1001,8 +1021,9 @@ void LLOutfitGalleryItem::draw() mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); } } - - if(mFavorite) + + static LLUICachedControl draw_star("InventoryFavoritesUseStar", true); + if(mFavorite && draw_star()) { const S32 HPAD = 3; const S32 VPAD = 6; // includes padding for text and for the image @@ -1025,7 +1046,9 @@ void LLOutfitGalleryItem::setOutfitName(std::string name) void LLOutfitGalleryItem::setOutfitFavorite(bool is_favorite) { mFavorite = is_favorite; - mOutfitNameText->setReadOnlyColor(mFavorite ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); + + LLCachedControl use_color(gSavedSettings, "InventoryFavoritesColorText"); + mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); } void LLOutfitGalleryItem::setOutfitWorn(bool value) @@ -1034,11 +1057,13 @@ void LLOutfitGalleryItem::setOutfitWorn(bool value) LLStringUtil::format_map_t worn_string_args; std::string worn_string = getString("worn_string", worn_string_args); mOutfitWornText->setReadOnlyColor(sDefaultTextColor.get()); - mOutfitNameText->setReadOnlyColor(mFavorite ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); mOutfitWornText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitNameText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitWornText->setValue(value ? worn_string : ""); mOutfitNameText->setText(mOutfitName); // refresh LLTextViewModel to pick up font changes + + LLCachedControl use_color(gSavedSettings, "InventoryFavoritesColorText"); + mOutfitNameText->setReadOnlyColor((mFavorite && use_color()) ? sDefaultFavoriteColor.get() : sDefaultTextColor.get()); } void LLOutfitGalleryItem::setSelected(bool value) diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index de02b0d4be..b333847093 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -137,6 +137,7 @@ private: void reArrangeRows(S32 row_diff = 0); void updateRowsIfNeeded(); void updateGalleryWidth(); + void handleInvFavColorChange(); LLOutfitGalleryItem* buildGalleryItem(std::string name, LLUUID outfit_id, bool is_favorite); LLOutfitGalleryItem* getSelectedItem(); @@ -191,6 +192,8 @@ private: LLInventoryCategoriesObserver* mOutfitsObserver; + + boost::signals2::connection mSavedSettingInvFavColor; }; class LLOutfitGalleryContextMenu : public LLOutfitContextMenu { -- cgit v1.2.3 From 3066cce1996ae680501dd2166dcf9773a4e75585 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 May 2024 17:23:47 +0300 Subject: viewer#1300 Small menu adjustment --- indra/newview/llinventorybridge.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 20d415cda9..e930af2d27 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -872,11 +872,13 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { items.push_back(std::string("Remove from Favorites")); } - else if (is_agent_inventory - && gInventory.getRootFolderID() != mUUID - && !gInventory.isObjectDescendentOf(mUUID, gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) + else if (is_agent_inventory && !gInventory.isObjectDescendentOf(mUUID, gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) { items.push_back(std::string("Add to Favorites")); + if (gInventory.getRootFolderID() == mUUID) + { + disabled_items.push_back(std::string("Add to Favorites")); + } } if (obj->getIsLinkType()) -- cgit v1.2.3 From f2358a2d4d441dc0c70d0449bc33038a396fba36 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 May 2024 19:11:46 +0300 Subject: viewer#1425 Sorting in Appearance floater #2 --- indra/newview/app_settings/settings.xml | 2 +- indra/newview/lloutfitslist.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 48c251240f..565d20daa1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -15744,7 +15744,7 @@ OutfitListFilterFullList Comment - 0 - show all items in outfit as long as outfit or item inside matches. 1 - show only matches + 0 - show only matches. 1 - show all items in outfit as long as outfit or item inside matches. Persist 1 Type diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 16cd3935a3..c0f13cc75f 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -784,7 +784,6 @@ void LLOutfitsList::onOutfitRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUI } } - void LLOutfitsList::handleInvFavColorChange() { for (outfits_map_t::iterator iter = mOutfitsMap.begin(); @@ -1563,7 +1562,7 @@ bool LLOutfitListSortMenu::onEnable(LLSD::String param) else if ("show_entire_outfit" == param) { LLCachedControl filter_mode(gSavedSettings, "OutfitListFilterFullList", 0); - return !filter_mode; + return filter_mode; } return false; -- cgit v1.2.3 From 4c676acedd3c99234e599b77bcfdec6ad3274efb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 May 2024 20:47:19 +0300 Subject: viewer#1300 More favorite settings --- indra/llui/llfolderviewitem.cpp | 9 +++------ indra/newview/app_settings/settings.xml | 11 +++++++++++ .../default/xui/en/floater_inventory_settings.xml | 19 ++++++++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 0131ab1085..03e3c84ca1 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -767,17 +767,14 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color) { static LLUICachedControl draw_star("InventoryFavoritesUseStar", true); - if (!draw_star) - { - return; - } + static LLUICachedControl draw_hollow_star("InventoryFavoritesUseHollowStar", true); LLUIImage* favorite_image = NULL; - if (mIsFavorite) + if (draw_star && mIsFavorite) { favorite_image = default_params.favorite_image; } - else if (mHasFavorites && !isOpen()) + else if (draw_hollow_star && mHasFavorites && !isOpen()) { favorite_image = default_params.favorite_content_image; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 565d20daa1..a37b334a22 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -17438,6 +17438,17 @@ Value 1 + InventoryFavoritesUseHollowStar + + Comment + Show star near folders that contain favorites + Persist + 0 + Type + Boolean + Value + 1 + InventoryFavoritesColorText Comment diff --git a/indra/newview/skins/default/xui/en/floater_inventory_settings.xml b/indra/newview/skins/default/xui/en/floater_inventory_settings.xml index e027d7556f..08b7a7af05 100644 --- a/indra/newview/skins/default/xui/en/floater_inventory_settings.xml +++ b/indra/newview/skins/default/xui/en/floater_inventory_settings.xml @@ -4,8 +4,8 @@ can_minimize="true" can_resize="false" save_rect="true" - height="460" - width="460" + height="483" + width="483" name="inventory_settings" title="INVENTORY SETTINGS"> + Date: Fri, 17 May 2024 22:22:45 +0300 Subject: viewer#1424 Proper links support for favorites --- indra/newview/llinventorybridge.cpp | 4 +- indra/newview/llinventoryfilter.cpp | 13 ++-- indra/newview/llinventoryfunctions.cpp | 117 ++++++++++++++++++------------- indra/newview/llinventoryfunctions.h | 3 +- indra/newview/llinventorygallery.cpp | 5 +- indra/newview/llinventorygallerymenu.cpp | 6 +- indra/newview/llinventorypanel.cpp | 7 +- indra/newview/llpanelwearing.cpp | 2 +- indra/newview/llwearableitemslist.cpp | 2 +- 9 files changed, 94 insertions(+), 65 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index e930af2d27..aa6d747622 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2283,11 +2283,11 @@ bool LLItemBridge::isFavorite() const LLInventoryModel* model = getInventoryModel(); if (model) { - item = (LLViewerInventoryItem*)model->getItem(mUUID); + item = model->getItem(mUUID); } if (item) { - return item->getIsFavorite(); + return get_is_favorite(item); } return false; } diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index cb54645ce5..52d03e302e 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -624,12 +624,15 @@ bool LLInventoryFilter::checkAgainstFilterFavorites(const LLUUID& object_id) con const LLInventoryObject* object = gInventory.getObject(object_id); if (!object) return true; - const bool is_favorite = object->getIsFavorite(); - if (is_favorite && (mFilterOps.mFilterFavorites == FILTER_EXCLUDE_FAVORITES)) - return false; - if (!is_favorite && (mFilterOps.mFilterFavorites == FILTER_ONLY_FAVORITES)) - return false; + if (mFilterOps.mFilterFavorites != FILTER_INCLUDE_FAVORITES) + { + bool is_favorite = get_is_favorite(object); + if (is_favorite && (mFilterOps.mFilterFavorites == FILTER_EXCLUDE_FAVORITES)) + return false; + if (!is_favorite && (mFilterOps.mFilterFavorites == FILTER_ONLY_FAVORITES)) + return false; + } return true; } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 3e19bf885d..930e9e48ea 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2353,58 +2353,40 @@ public: /* virtual */ void fire(const LLUUID& inv_item_id) override { gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, mInvItemID); - gInventory.notifyObservers(); - } -private: - LLUUID mInvItemID; -}; -void set_favorite(const LLUUID& obj_id, bool favorite) -{ - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj->getIsFavorite() != favorite) - { - LLSD val; - if (favorite) - { - val = true; - } // else leave undefined to remove unneeded metadata field + LLInventoryModel::item_array_t items; + LLInventoryModel::cat_array_t cat_array; + LLLinkedItemIDMatches matches(mInvItemID); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + items, + LLInventoryModel::INCLUDE_TRASH, + matches); - LLSD updates; - if (favorite) + std::set link_ids; + for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); ++it) { - updates["favorite"] = LLSD().with("toggled", true); - } - else - { - updates["favorite"] = LLSD(); - } + LLPointer item = *it; - LLPointer cb = new LLUpdateFavorite(obj_id); - - LLViewerInventoryCategory* view_folder = dynamic_cast(obj); - if (view_folder) - { - update_inventory_category(obj_id, updates, cb); - } - LLViewerInventoryItem* view_item = dynamic_cast(obj); - if (view_item) - { - update_inventory_item(obj_id, updates, cb); + gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, item->getUUID()); } + + gInventory.notifyObservers(); } -} +private: + LLUUID mInvItemID; +}; -void toggle_favorite(const LLUUID& obj_id) +void favorite_send(LLInventoryObject* obj, const LLUUID& obj_id, bool favorite) { - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (!obj) + LLSD val; + if (favorite) { - return; - } + val = true; + } // else leave undefined to remove unneeded metadata field LLSD updates; - if (!obj->getIsFavorite()) + if (favorite) { updates["favorite"] = LLSD().with("toggled", true); } @@ -2427,17 +2409,56 @@ void toggle_favorite(const LLUUID& obj_id) } } -void toggle_linked_favorite(const LLUUID& obj_id) +bool get_is_favorite(const LLInventoryObject* object) { - LLViewerInventoryItem* item = gInventory.getItem(obj_id); - if (!item) + if (object->getIsLinkType()) { - LL_WARNS() << "Invalid item" << LL_ENDL; - return; + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); + } + + return object->getIsFavorite(); +} + +bool get_is_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* object = gInventory.getObject(obj_id); + if (object && object->getIsLinkType()) + { + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); + } + + return object->getIsFavorite(); +} + +void set_favorite(const LLUUID& obj_id, bool favorite) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + + if (obj && obj->getIsLinkType()) + { + obj = gInventory.getObject(obj_id); + } + + if (obj && obj->getIsFavorite() != favorite) + { + favorite_send(obj, obj_id, favorite); + } +} + +void toggle_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj && obj->getIsLinkType()) + { + obj = gInventory.getObject(obj_id); } - LLUUID linked_id = item->getLinkedUUID(); - toggle_favorite(linked_id); + if (obj) + { + favorite_send(obj, obj_id, !obj->getIsFavorite()); + } } std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id) diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 681d5e1611..d90198d59b 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -114,9 +114,10 @@ bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_ca std::string get_localized_folder_name(LLUUID cat_uuid); void new_folder_window(const LLUUID& folder_id); void ungroup_folder_items(const LLUUID& folder_id); +bool get_is_favorite(const LLInventoryObject* object); +bool get_is_favorite(const LLUUID& obj_id); void set_favorite(const LLUUID& obj_id, bool favorite); void toggle_favorite(const LLUUID& obj_id); -void toggle_linked_favorite(const LLUUID& obj_id); std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id); std::string get_searchable_creator_name(LLInventoryModel* model, const LLUUID& item_id); std::string get_searchable_UUID(LLInventoryModel* model, const LLUUID& item_id); diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 5991697ab7..d2f1257444 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -929,6 +929,7 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id) } bool res = false; + bool is_favorite = get_is_favorite(obj); LLInventoryGalleryItem* item = buildGalleryItem( name, @@ -940,7 +941,7 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id) obj->getCreationDate(), obj->getIsLinkType(), is_worn, - obj->getIsFavorite()); + is_favorite); mItemMap.insert(LLInventoryGallery::gallery_item_map_t::value_type(item_id, item)); if (mGalleryCreated) { @@ -2154,7 +2155,7 @@ void LLInventoryGallery::refreshList(const LLUUID& category_id) return; } - updateChangedItemData(*items_iter, obj->getName(), obj->getIsFavorite()); + updateChangedItemData(*items_iter, obj->getName(), get_is_favorite(obj)); mNeedsArrange = true; } diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index de7ebd5ca8..00c8b191f5 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -549,7 +549,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men if (!is_trash && !is_in_trash && gInventory.getRootFolderID() != selected_id) { - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } @@ -601,7 +601,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Cut")); if (!is_in_trash) { - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } @@ -745,7 +745,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("upload_def")); } - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4682f2085b..8450c344a7 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -626,10 +626,11 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve { if (view_item) { + view_item->refresh(); LLFolderViewFolder* parent = view_item->getParentFolder(); if (parent) { - parent->updateHasFavorites(view_item->isFavorite()); + parent->updateHasFavorites(get_is_favorite(model_item)); } } } @@ -662,7 +663,8 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve setSelection(item_id, FALSE); } updateFolderLabel(model_item->getParentUUID()); - if (model_item->getIsFavorite()) + + if (get_is_favorite(model_item)) { LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); if (new_parent) @@ -2424,6 +2426,7 @@ void LLInventoryFavoritesItemsPanel::itemChanged(const LLUUID& id, U32 mask, con LLInventoryObserver::ADD | LLInventoryObserver::REMOVE)) { + // specifically exlude links and not get_is_favorite(model_item) if (model_item && model_item->getIsFavorite()) { LLFolderViewItem* view_item = getItemByID(id); diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index aecdf13495..dbabe935f5 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -113,7 +113,7 @@ protected: boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); registrar.add("Wearing.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); - registrar.add("Wearing.Favorite", boost::bind(toggle_linked_favorite, mUUIDs.front())); + registrar.add("Wearing.Favorite", boost::bind(toggle_favorite, mUUIDs.front())); LLContextMenu* menu = createFromFile("menu_wearing_tab.xml"); updateMenuItemsVisibility(menu); diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 8e44271efb..71b765ce71 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -936,7 +936,7 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu() // Register handlers for attachments. registrar.add("Attachment.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids)); - registrar.add("Attachment.Favorite", boost::bind(toggle_linked_favorite, selected_id)); + registrar.add("Attachment.Favorite", boost::bind(toggle_favorite, selected_id)); registrar.add("Attachment.Touch", boost::bind(handle_attachment_touch, selected_id)); registrar.add("Attachment.Profile", boost::bind(show_item_profile, selected_id)); registrar.add("Object.Attach", boost::bind(LLViewerAttachMenu::attachObjects, ids, _2)); -- cgit v1.2.3