From 645811c6ef3134a540fc1bc7d32d7bdb8fa35046 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 1 May 2024 03:16:47 +0300 Subject: Viewer#1301 Implement Inventory Favorites Tab WIP --- indra/newview/llinventorybridge.cpp | 42 ++++++++++++++++++++++ indra/newview/llinventorybridge.h | 39 ++++++++++++++++++++ indra/newview/llinventoryfilter.cpp | 31 ++++++++++++++++ indra/newview/llinventoryfilter.h | 2 ++ indra/newview/llinventorypanel.cpp | 38 ++++++++++++++++++++ indra/newview/llpanelmaininventory.cpp | 14 ++++++++ .../skins/default/xui/en/panel_main_inventory.xml | 16 +++++++++ indra/newview/skins/default/xui/en/strings.xml | 5 +-- 8 files changed, 185 insertions(+), 2 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 1f91ef2772..d7c7c7b552 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -8063,6 +8063,48 @@ LLInvFVBridge* LLRecentInventoryBridgeBuilder::createBridge( return new_listener; } +/************************************************************************/ +/* Favorites Inventory Panel related classes */ +/************************************************************************/ +void LLFavoritesFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) +{ + // todo: consider things that should be disabled + menuentry_vec_t disabled_items, items; + buildContextMenuOptions(flags, items, disabled_items); + + hide_context_entries(menu, items, disabled_items); +} + +LLInvFVBridge* LLFavoritesInventoryBridgeBuilder::createBridge( + LLAssetType::EType asset_type, + LLAssetType::EType actual_asset_type, + LLInventoryType::EType inv_type, + LLInventoryPanel* inventory, + LLFolderViewModelInventory* view_model, + LLFolderView* root, + const LLUUID& uuid, + U32 flags /*= 0x00*/) const +{ + LLInvFVBridge* new_listener = NULL; + if (asset_type == LLAssetType::AT_CATEGORY + && actual_asset_type != LLAssetType::AT_LINK_FOLDER) + { + new_listener = new LLFavoritesFolderBridge(inv_type, inventory, root, uuid); + } + else + { + new_listener = LLInventoryFolderViewModelBuilder::createBridge(asset_type, + actual_asset_type, + inv_type, + inventory, + view_model, + root, + uuid, + flags); + } + return new_listener; +} + LLFolderViewGroupedItemBridge::LLFolderViewGroupedItemBridge() { } diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 5100da15cd..2b30d34d70 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -729,6 +729,45 @@ public: U32 flags = 0x00) const; }; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Favorites Inventory Panel related classes +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +// Overridden version of the Inventory-Folder-View-Bridge for Folders +class LLFavoritesFolderBridge : public LLFolderBridge +{ + friend class LLInvFVBridgeAction; +public: + // Creates context menu for Folders related to Recent Inventory Panel. + // Uses base logic and than removes from visible items "New..." menu items. + LLFavoritesFolderBridge(LLInventoryType::EType type, + LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid) : + LLFolderBridge(inventory, root, uuid) + { + mInvType = type; + } + /*virtual*/ void buildContextMenu(LLMenuGL& menu, U32 flags); +}; + +// Bridge builder to create Inventory-Folder-View-Bridge for Recent Inventory Panel +class LLFavoritesInventoryBridgeBuilder : public LLInventoryFolderViewModelBuilder +{ +public: + LLFavoritesInventoryBridgeBuilder() {} + // Overrides FolderBridge for Recent Inventory Panel. + // It use base functionality for bridges other than FolderBridge. + virtual LLInvFVBridge* createBridge(LLAssetType::EType asset_type, + LLAssetType::EType actual_asset_type, + LLInventoryType::EType inv_type, + LLInventoryPanel* inventory, + LLFolderViewModelInventory* view_model, + LLFolderView* root, + const LLUUID& uuid, + U32 flags = 0x00) const; +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Marketplace Inventory Panel related classes //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 3c654ffd03..cb54645ce5 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -160,6 +160,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) passed = passed && checkAgainstCreator(listener); passed = passed && checkAgainstSearchVisibility(listener); + passed = passed && checkAgainstFilterFavorites(listener->getUUID()); passed = passed && checkAgainstFilterThumbnails(listener->getUUID()); return passed; @@ -222,6 +223,19 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const return false; } + const LLViewerInventoryCategory* cat = gInventory.getCategory(folder_id); + if (cat && cat->getIsFavorite()) + { + if (mFilterOps.mFilterFavorites == FILTER_ONLY_FAVORITES) + { + return true; + } + if (mFilterOps.mFilterFavorites == FILTER_EXCLUDE_FAVORITES) + { + return false; + } + } + // Marketplace folder filtering const U32 filterTypes = mFilterOps.mFilterTypes; const U32 marketplace_filter = FILTERTYPE_MARKETPLACE_ACTIVE | FILTERTYPE_MARKETPLACE_INACTIVE | @@ -273,6 +287,16 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const } } } + + if (filterTypes & FILTERTYPE_NO_TRASH_ITEMS) + { + const LLUUID trash_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + // If not a descendant of the marketplace listings root, then the nesting depth is -1 by definition + if (gInventory.isObjectDescendentOf(folder_id, trash_uuid)) + { + return false; + } + } // show folder links LLViewerInventoryItem* item = gInventory.getItem(folder_id); @@ -601,10 +625,12 @@ bool LLInventoryFilter::checkAgainstFilterFavorites(const LLUUID& object_id) con 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; + return true; } @@ -943,6 +969,11 @@ void LLInventoryFilter::toggleSearchVisibilityLibrary() } } +void LLInventoryFilter::setFilterNoTrashFolder() +{ + mFilterOps.mFilterTypes |= FILTERTYPE_NO_TRASH_ITEMS; +} + void LLInventoryFilter::setFilterNoMarketplaceFolder() { mFilterOps.mFilterTypes |= FILTERTYPE_NO_MARKETPLACE_ITEMS; diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 9f8be17a99..6f794df1bb 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -60,6 +60,7 @@ public: FILTERTYPE_NO_MARKETPLACE_ITEMS = 0x1 << 10, // pass iff folder is not under the marketplace FILTERTYPE_WORN = 0x1 << 11, // pass if item is worn FILTERTYPE_SETTINGS = 0x1 << 12, // pass if the item is a settings object + FILTERTYPE_NO_TRASH_ITEMS = 0x1 << 13, // pass iff folder is not under the marketplace }; enum EFilterDateDirection @@ -243,6 +244,7 @@ public: void setFilterMarketplaceInactiveFolders(); void setFilterMarketplaceUnassociatedFolders(); void setFilterMarketplaceListingFolders(bool select_only_listing_folders); + void setFilterNoTrashFolder(); void setFilterNoMarketplaceFolder(); void setFilterThumbnails(U64 filter_thumbnails); void setFilterFavorites(U64 filter_favorites); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 6a5cd59acb..bdf9e87e60 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -55,11 +55,13 @@ #include "llviewerfoldertype.h" #include "llvoavatarself.h" +class LLInventoryFavoritesItemsPanel; class LLInventoryRecentItemsPanel; class LLAssetFilteredInventoryPanel; static LLDefaultChildRegistry::Register r("inventory_panel"); static LLDefaultChildRegistry::Register t_recent_inventory_panel("recent_inventory_panel"); +static LLDefaultChildRegistry::Register t_favorites_inventory_panel("favorites_inventory_panel"); static LLDefaultChildRegistry::Register t_asset_filtered_inv_panel("asset_filtered_inv_panel"); const std::string LLInventoryPanel::DEFAULT_SORT_ORDER = std::string("InventorySortOrder"); @@ -2225,6 +2227,42 @@ LLInventoryRecentItemsPanel::LLInventoryRecentItemsPanel( const Params& params) mInvFVBridgeBuilder = &RECENT_ITEMS_BUILDER; } +/************************************************************************/ +/* Favorites Inventory Panel related class */ +/************************************************************************/ +static const LLFavoritesInventoryBridgeBuilder FAVORITES_BUILDER; +class LLInventoryFavoritesItemsPanel : public LLInventoryPanel +{ +public: + struct Params : public LLInitParam::Block + {}; + + void initFromParams(const Params& p) + { + LLInventoryPanel::initFromParams(p); + // turn off trash + getFilter().setFilterCategoryTypes(getFilter().getFilterCategoryTypes() | (1ULL << LLFolderType::FT_TRASH)); + getFilter().setFilterNoTrashFolder(); + // turn off marketplace for favorites + getFilter().setFilterNoMarketplaceFolder(); + } + +protected: + LLInventoryFavoritesItemsPanel(const Params&); + friend class LLUICtrlFactory; +}; + +LLInventoryFavoritesItemsPanel::LLInventoryFavoritesItemsPanel(const Params& params) + : LLInventoryPanel(params) +{ + // replace bridge builder to have necessary View bridges. + mInvFVBridgeBuilder = &FAVORITES_BUILDER; +} + +/************************************************************************/ +/* LLInventorySingleFolderPanel */ +/************************************************************************/ + static LLDefaultChildRegistry::Register t_single_folder_inventory_panel("single_folder_inventory_panel"); LLInventorySingleFolderPanel::LLInventorySingleFolderPanel(const Params& params) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 20241aac24..b1bfd52bc6 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -67,6 +67,7 @@ const std::string FILTERS_FILENAME("filters.xml"); const std::string ALL_ITEMS("All Items"); const std::string RECENT_ITEMS("Recent Items"); const std::string WORN_ITEMS("Worn Items"); +const std::string FAVORITES("Favorites"); static LLPanelInjector t_inventory("panel_main_inventory"); @@ -193,6 +194,19 @@ BOOL LLPanelMainInventory::postBuild() worn_filter.markDefault(); mWornItemsPanel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, mWornItemsPanel, _1, _2)); } + + LLInventoryPanel* favorites_panel = getChild(FAVORITES); + if (favorites_panel) + { + favorites_panel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER)); + favorites_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + LLInventoryFilter& favorites_filter = favorites_panel->getFilter(); + favorites_filter.setFilterFavorites(LLInventoryFilter::FILTER_ONLY_FAVORITES); + favorites_filter.setEmptyLookupMessage("InventoryNoMatchingFavorites"); + favorites_filter.markDefault(); + favorites_panel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, favorites_panel, _1, _2)); + } + mSearchTypeCombo = getChild("search_type"); if(mSearchTypeCombo) { diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml index 190ff4ef28..9d55cae28d 100644 --- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml @@ -268,6 +268,22 @@ scroll.reserve_scroll_corner="false"> + + + Didn't find what you're looking for? Try [secondlife:///app/search/all/[SEARCH_TERM] Search]. - Didn't find what you're looking for? Try [secondlife:///app/inventory/filters Show filters]. - To add a place to your landmarks, click the star to the right of the location name. + Didn't find what you're looking for? Try [secondlife:///app/inventory/filters Show filters]. + You haven't marked any items as favorites. + To add a place to your landmarks, click the star to the right of the location name. To add a place to your favorites, click the star to the right of the location name, then save the landmark to "Favorites bar". You have no listings yet. No items found. Check the spelling of your search string and try again. -- cgit v1.2.3