Viewer#1301 Implement Inventory Favorites Tab WIP

master
Andrey Kleshchev 2024-05-01 03:16:47 +03:00
parent 1e7dc04644
commit 645811c6ef
8 changed files with 185 additions and 2 deletions

View File

@ -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()
{
}

View File

@ -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
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -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;

View File

@ -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);

View File

@ -55,11 +55,13 @@
#include "llviewerfoldertype.h"
#include "llvoavatarself.h"
class LLInventoryFavoritesItemsPanel;
class LLInventoryRecentItemsPanel;
class LLAssetFilteredInventoryPanel;
static LLDefaultChildRegistry::Register<LLInventoryPanel> r("inventory_panel");
static LLDefaultChildRegistry::Register<LLInventoryRecentItemsPanel> t_recent_inventory_panel("recent_inventory_panel");
static LLDefaultChildRegistry::Register<LLInventoryFavoritesItemsPanel> t_favorites_inventory_panel("favorites_inventory_panel");
static LLDefaultChildRegistry::Register<LLAssetFilteredInventoryPanel> 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<Params, LLInventoryPanel::Params>
{};
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<LLInventorySingleFolderPanel> t_single_folder_inventory_panel("single_folder_inventory_panel");
LLInventorySingleFolderPanel::LLInventorySingleFolderPanel(const Params& params)

View File

@ -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<LLPanelMainInventory> 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<LLInventoryPanel>(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<LLComboBox>("search_type");
if(mSearchTypeCombo)
{

View File

@ -268,6 +268,22 @@
scroll.reserve_scroll_corner="false">
<folder double_click_override="true"/>
</inventory_panel>
<favorites_inventory_panel
bg_opaque_color="DkGray2"
bg_alpha_color="DkGray2"
background_visible="true"
border="false"
bevel_style="none"
follows="all"
label="FAVORITES"
help_topic="recent_inventory_tab"
layout="topleft"
name="Favorites"
show_item_link_overlays="true"
preinitialize_views="false"
scroll.reserve_scroll_corner="false">
<folder double_click_override="true"/>
</favorites_inventory_panel>
</tab_container>
</panel>
<panel

View File

@ -2306,8 +2306,9 @@ For AI Character: Get the closest navigable point to the point provided.
<!-- inventory -->
<string name="InventoryNoMatchingItems">Didn't find what you're looking for? Try [secondlife:///app/search/all/[SEARCH_TERM] Search].</string>
<string name="InventoryNoMatchingRecentItems">Didn't find what you're looking for? Try [secondlife:///app/inventory/filters Show filters].</string>
<string name="PlacesNoMatchingItems">To add a place to your landmarks, click the star to the right of the location name.</string>
<string name="InventoryNoMatchingRecentItems">Didn't find what you're looking for? Try [secondlife:///app/inventory/filters Show filters].</string>
<string name="InventoryNoMatchingFavorites">You haven't marked any items as favorites.</string>
<string name="PlacesNoMatchingItems">To add a place to your landmarks, click the star to the right of the location name.</string>
<string name="FavoritesNoMatchingItems">To add a place to your favorites, click the star to the right of the location name, then save the landmark to "Favorites bar".</string>
<string name="MarketplaceNoListing">You have no listings yet.</string>
<string name="MarketplaceNoMatchingItems">No items found. Check the spelling of your search string and try again.</string>