From fc5e5327bca83846bb97cb7ff578b0dcb3a8892e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 May 2024 03:05:41 +0300 Subject: Viewer#1301 Implement Inventory Favorites Tab WIP#2 --- indra/newview/llinventorypanel.cpp | 93 ++++++++++++++++++--- indra/newview/llinventorypanel.h | 4 +- indra/newview/llpanelmaininventory.cpp | 2 - .../textures/icons/Inv_Favorite_Star_Content.png | Bin 0 -> 474 bytes .../textures/icons/Inv_Favorite_Star_Full.png | Bin 0 -> 582 bytes indra/newview/skins/default/textures/textures.xml | 2 + .../skins/default/xui/en/floater_preview_trash.xml | 4 +- .../default/xui/en/widgets/folder_view_item.xml | 4 +- .../xui/en/widgets/inbox_folder_view_folder.xml | 4 +- 9 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Content.png create mode 100644 indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Full.png (limited to 'indra/newview') diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index bdf9e87e60..f22ac6f775 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -947,18 +947,7 @@ void LLInventoryPanel::initializeViews(F64 max_time) mBuildViewsEndTime = curent_time + max_time; // init everything - LLUUID root_id = getRootFolderID(); - if (root_id.notNull()) - { - buildNewViews(getRootFolderID()); - } - else - { - // Default case: always add "My Inventory" root first, "Library" root second - // If we run out of time, this still should create root folders - buildNewViews(gInventory.getRootFolderID()); // My Inventory - buildNewViews(gInventory.getLibraryRootFolderID()); // Library - } + initRootContent(); if (mBuildViewsQueue.empty()) { @@ -991,6 +980,22 @@ void LLInventoryPanel::initializeViews(F64 max_time) } } +void LLInventoryPanel::initRootContent() +{ + LLUUID root_id = getRootFolderID(); + if (root_id.notNull()) + { + buildNewViews(getRootFolderID()); + } + else + { + // Default case: always add "My Inventory" root first, "Library" root second + // If we run out of time, this still should create root folders + buildNewViews(gInventory.getRootFolderID()); // My Inventory + buildNewViews(gInventory.getLibraryRootFolderID()); // Library + } +} + LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * bridge, bool allow_drop) { @@ -1248,6 +1253,7 @@ LLFolderViewItem* LLInventoryPanel::buildViewsTree(const LLUUID& id, { LLViewerInventoryCategory::cat_array_t* categories; LLViewerInventoryItem::item_array_t* items; + //collectInventoryDescendants(id, categories, items); mInventory->lockDirectDescendentArrays(id, categories, items); // Make sure panel won't lock in a loop over existing items if @@ -1348,6 +1354,14 @@ LLFolderViewItem* LLInventoryPanel::buildViewsTree(const LLUUID& id, return folder_view_item; } + +/*void LLInventoryPanel::collectInventoryDescendants(const LLUUID& id, + LLViewerInventoryCategory::cat_array_t*& categories, + LLViewerInventoryItem::item_array_t*& items); +{ + mInventory->lockDirectDescendentArrays(id, categories, items); +}*/ + // bit of a hack to make sure the inventory is open. void LLInventoryPanel::openStartFolderOrMyInventory() { @@ -2250,6 +2264,9 @@ public: protected: LLInventoryFavoritesItemsPanel(const Params&); friend class LLUICtrlFactory; + + void initRootContent(const LLUUID& id); + void initRootContent() override; }; LLInventoryFavoritesItemsPanel::LLInventoryFavoritesItemsPanel(const Params& params) @@ -2259,6 +2276,58 @@ LLInventoryFavoritesItemsPanel::LLInventoryFavoritesItemsPanel(const Params& par mInvFVBridgeBuilder = &FAVORITES_BUILDER; } +void LLInventoryFavoritesItemsPanel::initRootContent(const LLUUID& id) +{ + LLViewerInventoryCategory::cat_array_t* categories; + LLViewerInventoryItem::item_array_t* items; + mInventory->lockDirectDescendentArrays(id, categories, items); + + if (categories) + { + S32 count = categories->size(); + for (S32 i = 0; i < count; ++i) + { + LLViewerInventoryCategory* cat = categories->at(i); + if (cat->getPreferredType() == LLFolderType::FT_TRASH) + { + continue; + } + else if (cat->getIsFavorite()) + { + const LLUUID& parent_id = cat->getParentUUID(); + LLFolderViewItem* folder_view_item = getItemByID(cat->getUUID()); // Should be NULL + + buildViewsTree(cat->getUUID(), parent_id, cat, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + } + else // Todo: timelimits + { + initRootContent(cat->getUUID()); + } + } + } + + if (items) + { + S32 count = items->size(); + for (S32 i = 0; i < count; ++i) + { + LLViewerInventoryItem* item = items->at(i); + if (item->getIsFavorite() && typedViewsFilter(id, item)) + { + const LLUUID& parent_id = item->getParentUUID(); + LLFolderViewItem* folder_view_item = getItemByID(id); // Should be NULL + + buildViewsTree(item->getUUID(), parent_id, item, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + } + } + } +} + +void LLInventoryFavoritesItemsPanel::initRootContent() +{ + initRootContent(gInventory.getRootFolderID()); // My Inventory +} + /************************************************************************/ /* LLInventorySingleFolderPanel */ /************************************************************************/ diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 97300596f9..b6d21ea9a8 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -334,6 +334,7 @@ public: protected: // Builds the UI. Call this once the inventory is usable. void initializeViews(F64 max_time); + virtual void initRootContent(); // Specific inventory colors static bool sColorSetInitialized; @@ -371,7 +372,7 @@ protected: virtual LLFolderViewItem* createFolderViewItem(LLInvFVBridge * bridge); boost::function& items, BOOL user_action)> mSelectionCallback; -private: +protected: // buildViewsTree does not include some checks and is meant // for recursive use, use buildNewViews() for first call LLFolderViewItem* buildViewsTree(const LLUUID& id, @@ -394,6 +395,7 @@ private: EViewsInitializationState mViewsInitialized; // Whether views have been generated F64 mBuildViewsEndTime; // Stop building views past this timestamp std::deque mBuildViewsQueue; + std::deque mBuildRootContent; }; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index b1bfd52bc6..c41fedec20 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -199,9 +199,7 @@ BOOL LLPanelMainInventory::postBuild() 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)); diff --git a/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Content.png b/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Content.png new file mode 100644 index 0000000000..bf7ec1599a Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Content.png differ diff --git a/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Full.png b/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Full.png new file mode 100644 index 0000000000..916b57f3c5 Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Inv_Favorite_Star_Full.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index c733d3feaf..7f3b9a8cee 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -304,6 +304,8 @@ with the same filename but different name + + diff --git a/indra/newview/skins/default/xui/en/floater_preview_trash.xml b/indra/newview/skins/default/xui/en/floater_preview_trash.xml index f62e04baf2..ebb5cd9251 100644 --- a/indra/newview/skins/default/xui/en/floater_preview_trash.xml +++ b/indra/newview/skins/default/xui/en/floater_preview_trash.xml @@ -29,8 +29,8 @@ bevel_style="none" scroll.reserve_scroll_corner="false">