From 384d694aba523218490ec48c22d97b63acbffd6f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 23 Apr 2024 23:28:58 +0300 Subject: viewer#1300 Inventory favorites context menu --- indra/llinventory/llinventory.cpp | 68 ++++++++++++++++++---- indra/newview/llinventorybridge.cpp | 14 ++++- indra/newview/llinventoryfunctions.cpp | 34 +++++++++++ indra/newview/llinventoryfunctions.h | 1 + indra/newview/llinventorygallerymenu.cpp | 23 ++++++++ .../default/xui/en/menu_gallery_inventory.xml | 16 +++++ .../skins/default/xui/en/menu_inventory.xml | 18 +++++- 7 files changed, 162 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index cef469e11e..2f701f12a0 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -60,6 +60,7 @@ static const std::string INV_LINKED_ID_LABEL("linked_id"); static const std::string INV_SALE_INFO_LABEL("sale_info"); static const std::string INV_FLAGS_LABEL("flags"); static const std::string INV_CREATION_DATE_LABEL("created_at"); +static const std::string INV_TOGGLED_LABEL("toggled"); // key used by agent-inventory-service static const std::string INV_ASSET_TYPE_LABEL_WS("type_default"); @@ -261,9 +262,18 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) { - setFavorite(metadata["favorite"].asBoolean()); + const LLSD& favorite = metadata["favorite"]; + if (favorite.has("toggled")) + { + setFavorite(favorite["toggled"].asBoolean()); + } + else + { + setFavorite(false); + } } else { @@ -757,9 +767,18 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) { - setFavorite(metadata["favorite"].asBoolean()); + const LLSD& favorite = metadata["favorite"]; + if (favorite.has("toggled")) + { + setFavorite(favorite["toggled"].asBoolean()); + } + else + { + setFavorite(false); + } } else { @@ -927,7 +946,7 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const if (mFavorite) { - sd[INV_FAVORITE_LABEL] = mFavorite; + sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite); } U32 mask = mPermissions.getMaskBase(); @@ -972,6 +991,7 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) // TODO - figure out if this should be moved into the noclobber fields above mThumbnailUUID.setNull(); + mFavorite = false; // iterate as map to avoid making unnecessary temp copies of everything LLSD::map_const_iterator i, end; @@ -1019,7 +1039,12 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) if (i->first == INV_FAVORITE_LABEL) { - mFavorite = i->second.asBoolean(); + const LLSD& favorite_map = i->second; + const std::string w = INV_TOGGLED_LABEL; + if (favorite_map.has(w)) + { + mFavorite = favorite_map[w].asBoolean(); + } continue; } @@ -1220,7 +1245,7 @@ LLSD LLInventoryCategory::asLLSD() const if (mFavorite) { - sd[INV_FAVORITE_LABEL] = mFavorite; + sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite); } return sd; @@ -1234,13 +1259,15 @@ LLSD LLInventoryCategory::asAISCreateCatLLSD() const S8 type = static_cast(mPreferredType); sd[INV_ASSET_TYPE_LABEL_WS] = type; sd[INV_NAME_LABEL] = mName; + if (mThumbnailUUID.notNull()) { sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID); } + if (mFavorite) { - sd[INV_FAVORITE_LABEL] = mFavorite; + sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite); } return sd; @@ -1290,10 +1317,16 @@ bool LLInventoryCategory::fromLLSD(const LLSD& sd) mThumbnailUUID = sd[w]; } } + mFavorite = false; w = INV_FAVORITE_LABEL; if (sd.has(w)) { - mFavorite = sd[w].asBoolean(); + const LLSD& favorite_map = sd[w]; + w = INV_TOGGLED_LABEL; + if (favorite_map.has(w)) + { + mFavorite = favorite_map[w].asBoolean(); + } } w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) @@ -1417,9 +1450,18 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) { - setFavorite(metadata["favorite"].asBoolean()); + const LLSD& favorite = metadata["favorite"]; + if (favorite.has("toggled")) + { + setFavorite(favorite["toggled"].asBoolean()); + } + else + { + setFavorite(false); + } } else { @@ -1474,7 +1516,7 @@ LLSD LLInventoryCategory::exportLLSD() const } if (mFavorite) { - cat_data[INV_FAVORITE_LABEL] = mFavorite; + cat_data[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite); } return cat_data; @@ -1510,7 +1552,13 @@ bool LLInventoryCategory::importLLSD(const LLSD& cat_data) } if (cat_data.has(INV_FAVORITE_LABEL)) { - setFavorite(cat_data[INV_FAVORITE_LABEL].asBoolean()); + bool favorite = false; + const LLSD& favorite_data = cat_data[INV_FAVORITE_LABEL]; + if (favorite_data.has(INV_TOGGLED_LABEL)) + { + favorite = favorite_data[INV_ASSET_ID_LABEL].asBoolean(); + } + setFavorite(favorite); } if (cat_data.has(INV_NAME_LABEL)) { diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 93567e6155..17f7f33891 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -852,7 +852,8 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, disabled_items.push_back(std::string("Copy")); } - if (isAgentInventory() && !single_folder_root) + bool is_agent_inventory = isAgentInventory(); + if (is_agent_inventory && !single_folder_root) { items.push_back(std::string("New folder from selected")); items.push_back(std::string("Subfolder Separator")); @@ -865,6 +866,17 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } } + if (getIsFavorite()) + { + items.push_back(std::string("Remove from Favorites")); + } + else if (is_agent_inventory + && gInventory.getRootFolderID() != mUUID + && !gInventory.isObjectDescendentOf(mUUID, gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH))) + { + items.push_back(std::string("Add to Favorites")); + } + if (obj->getIsLinkType()) { items.push_back(std::string("Find Original")); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index ea0566f5c4..b95d75a782 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2344,6 +2344,26 @@ void ungroup_folder_items(const LLUUID& folder_id) gInventory.notifyObservers(); } +void set_favorite(const LLUUID& obj_id, bool favorite) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj->getIsFavorite() != favorite) + { + LLSD updates; + updates["favorite"] = LLSD().with("toggled", favorite); + LLViewerInventoryCategory* view_folder = dynamic_cast(obj); + if (view_folder) + { + update_inventory_category(obj_id, updates, NULL); + } + LLViewerInventoryItem* view_item = dynamic_cast(obj); + if (view_item) + { + update_inventory_item(obj_id, updates, NULL); + } + } +} + std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id) { if (model) @@ -3322,6 +3342,20 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root ungroup_folder_items(*ids.begin()); } } + else if ("add_to_favorites" == action) + { + for (const LLUUID& id : ids) + { + set_favorite(id, true); + } + } + else if ("remove_from_favorites" == action) + { + for (const LLUUID& id : ids) + { + set_favorite(id, false); + } + } else { std::set::iterator set_iter; diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 5a833eab8c..14038967c6 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -114,6 +114,7 @@ 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); +void set_favorite(const LLUUID& obj_id, bool favorite); 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/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 5f4b816b99..6e5d8802a4 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -186,6 +186,20 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata) { ungroup_folder_items(mUUIDs.front()); } + else if ("add_to_favorites" == action) + { + for (const LLUUID& id : mUUIDs) + { + set_favorite(id, true); + } + } + else if ("remove_from_favorites" == action) + { + for (const LLUUID& id : mUUIDs) + { + set_favorite(id, false); + } + } else if ("take_off" == action || "detach" == action) { for (LLUUID& selected_id : mUUIDs) @@ -707,6 +721,15 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("New Folder")); disabled_items.push_back(std::string("upload_def")); } + + if (obj->getIsFavorite()) + { + items.push_back(std::string("Remove from Favorites")); + } + else if (is_agent_inventory) + { + items.push_back(std::string("Add to Favorites")); + } } hide_context_entries(*menu, items, disabled_items); diff --git a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml index c11f1c88cb..929c626947 100644 --- a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml @@ -442,6 +442,22 @@ function="Inventory.DoToSelected" parameter="ungroup_folder_items" /> + + + + + + - + + + + + + + Date: Thu, 25 Apr 2024 04:46:42 +0300 Subject: viewer#1300 'Star' favorites in inventory image is WIP --- indra/llui/llfolderviewitem.cpp | 35 ++++++++++++++++++++++ indra/llui/llfolderviewitem.h | 13 +++++++- indra/llui/llfolderviewmodel.h | 5 +++- indra/newview/llappearancemgr.cpp | 11 ++++--- indra/newview/llappearancemgr.h | 2 +- indra/newview/llconversationmodel.h | 3 ++ indra/newview/llfolderviewmodelinventory.cpp | 28 ++++++++++++----- indra/newview/llinventorybridge.cpp | 18 ++++++++--- indra/newview/llinventorybridge.h | 12 ++++++-- indra/newview/llpanelobjectinventory.cpp | 3 ++ .../skins/default/xui/en/floater_preview_trash.xml | 2 ++ .../default/xui/en/widgets/folder_view_item.xml | 2 ++ .../xui/en/widgets/inbox_folder_view_folder.xml | 2 ++ 13 files changed, 114 insertions(+), 22 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 2bd14f6f6a..84146e5829 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -99,6 +99,8 @@ void LLFolderViewItem::cleanupClass() LLFolderViewItem::Params::Params() : root(), listener(), + favorite_image("favorite_image"), + favorite_content_image("favorite_content_image"), folder_arrow_image("folder_arrow_image"), folder_indentation("folder_indentation"), selection_image("selection_image"), @@ -125,6 +127,8 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) : LLView(p), mLabelWidth(0), mLabelWidthDirty(false), + mIsFavorite(false), + mHasFavorites(false), mSuffixNeedsRefresh(false), mLabelPaddingRight(DEFAULT_LABEL_PADDING_RIGHT), mParentFolder( NULL ), @@ -194,6 +198,8 @@ BOOL LLFolderViewItem::postBuild() // getDisplayName() is expensive (due to internal getLabelSuffix() and name building) // it also sets search strings so it requires a filter reset mLabel = vmi->getDisplayName(); + mIsFavorite = vmi->isFavorite(); + mHasFavorites = vmi->hasFavorites(); setToolTip(vmi->getName()); // Dirty the filter flag of the model from the view (CHUI-849) @@ -307,6 +313,8 @@ void LLFolderViewItem::refresh() LLFolderViewModelItem& vmi = *getViewModelItem(); mLabel = vmi.getDisplayName(); + mIsFavorite = vmi.isFavorite(); + mHasFavorites = vmi.hasFavorites(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -339,6 +347,9 @@ void LLFolderViewItem::refreshSuffix() mIconOpen = vmi->getIconOpen(); mIconOverlay = vmi->getIconOverlay(); + mIsFavorite = vmi->isFavorite(); + mHasFavorites = vmi->hasFavorites(); + if (mRoot->useLabelSuffix()) { // Very Expensive! @@ -754,6 +765,29 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L } } +void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color) +{ + LLUIImage* favorite_image = NULL; + if (mIsFavorite) + { + favorite_image = default_params.favorite_image; + } + else if (mHasFavorites) + { + favorite_image = default_params.favorite_content_image; + } + + if (favorite_image) + { + const S32 PAD = 2; + const S32 image_size = 30; + + gl_draw_scaled_image( + getRect().getWidth() - image_size - PAD, getRect().getHeight() - mItemHeight + PAD, + image_size, image_size, favorite_image->getImage(), fg_color); + } +} + /*virtual*/ bool LLFolderViewItem::isHighlightAllowed() { return mIsSelected; @@ -913,6 +947,7 @@ void LLFolderViewItem::draw() { drawOpenFolderArrow(default_params, sFgColor); } + drawFavoriteIcon(default_params, sFgColor); drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor); diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 5c2a1ecff0..eba3cf4f83 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -49,7 +49,9 @@ class LLFolderViewItem : public LLView public: struct Params : public LLInitParam::Block { - Optional folder_arrow_image, + Optional favorite_image, + favorite_content_image, + folder_arrow_image, selection_image; Mandatory root; Mandatory listener; @@ -92,6 +94,8 @@ protected: std::string mLabel; S32 mLabelWidth; bool mLabelWidthDirty; + bool mIsFavorite; + bool mHasFavorites; S32 mLabelPaddingRight; LLFolderViewFolder* mParentFolder; LLPointer mViewModelItem; @@ -207,6 +211,8 @@ public: // Returns true is this object and all of its children can be moved virtual BOOL isMovable(); + bool isFavorite() const { return mIsFavorite; } + // destroys this item recursively virtual void destroyView(); @@ -297,6 +303,7 @@ public: // virtual void handleDropped(); virtual void draw(); void drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color); + void drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color); void drawHighlight(const BOOL showContent, const BOOL hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, const LLUIColor &outlineColor, const LLUIColor &mouseOverColor); void drawLabel(const LLFontGL * font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -391,6 +398,10 @@ public: // Returns true is this object and all of its children can be moved virtual BOOL isMovable(); + bool isFavorite() const { return mIsFavorite; } + bool hasFavorites() const { return mHasFavorites; } + void setHasFavorites(bool val) { mHasFavorites = val; } + // destroys this folder, and all children virtual void destroyView(); void destroyRoot(); diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 551a60e097..9d46334fc4 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -161,7 +161,10 @@ public: virtual void selectItem(void) = 0; virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0; - + + virtual bool isFavorite() const = 0; + virtual bool hasFavorites() const = 0; + virtual void setHasFavorites(bool val) = 0; virtual BOOL isItemWearable() const { return FALSE; } virtual BOOL isItemRenameable() const = 0; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index c84657cf7a..13f56de60d 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2037,7 +2037,7 @@ bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id) } // Moved from LLWearableList::ContextMenu for wider utility. -bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids) const +bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids, bool warn_on_type_mismarch) const { // TODO: investigate wearables may not be loaded at this point EXT-8231 @@ -2065,9 +2065,12 @@ bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids) const { return isAgentAvatarValid(); } - else - { - LL_WARNS() << "Unexpected wearable type" << LL_ENDL; + else + { + if (warn_on_type_mismarch) + { + LL_WARNS() << "Unexpected wearable type" << LL_ENDL; + } return false; } } diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index da29ceee3a..569fc90e93 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -102,7 +102,7 @@ public: bool getCanReplaceCOF(const LLUUID& outfit_cat_id); // Can we add all referenced items to the avatar? - bool canAddWearables(const uuid_vec_t& item_ids) const; + bool canAddWearables(const uuid_vec_t& item_ids, bool warn_on_type_mismarch = true) const; // Copy all items in a category. void shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id, diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 436c9c00ab..e2eaff12e5 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -79,6 +79,9 @@ public: virtual LLPointer getOpenIcon() const { return getIcon(); } virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual std::string getLabelSuffix() const { return LLStringUtil::null; } + virtual bool isFavorite() const { return false; } + virtual bool hasFavorites() const { return false; } + virtual void setHasFavorites(bool val) {} virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; } virtual BOOL isItemMovable( void ) const { return FALSE; } diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 241aa96bc8..bc5a07abf2 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -68,9 +68,10 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder ) if (!folder->areChildrenInited() || !needsSort(folder->getViewModelItem())) return; - LLFolderViewModelItemInventory* modelp = static_cast(folder->getViewModelItem()); - if (modelp->getUUID().isNull()) return; + LLFolderViewModelItemInventory* sort_modelp = static_cast(folder->getViewModelItem()); + if (sort_modelp->getUUID().isNull()) return; + bool has_favorites = false; for (std::list::iterator it = folder->getFoldersBegin(), end_it = folder->getFoldersEnd(); it != end_it; ++it) @@ -79,11 +80,14 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder ) LLFolderViewFolder* child_folderp = *it; sort(child_folderp); + LLFolderViewModelItemInventory* modelp = static_cast(child_folderp->getViewModelItem()); + has_favorites |= child_folderp->isFavorite() || child_folderp->hasFavorites(); + if (child_folderp->getFoldersCount() > 0) { - time_t most_recent_folder_time = - static_cast((*child_folderp->getFoldersBegin())->getViewModelItem())->getCreationDate(); - LLFolderViewModelItemInventory* modelp = static_cast(child_folderp->getViewModelItem()); + LLFolderViewModelItemInventory* folderp = static_cast((*child_folderp->getFoldersBegin())->getViewModelItem()); + time_t most_recent_folder_time = folderp->getCreationDate(); + if (most_recent_folder_time > modelp->getCreationDate()) { modelp->setCreationDate(most_recent_folder_time); @@ -91,16 +95,24 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder ) } if (child_folderp->getItemsCount() > 0) { - time_t most_recent_item_time = - static_cast((*child_folderp->getItemsBegin())->getViewModelItem())->getCreationDate(); + LLFolderViewModelItemInventory* itemp = static_cast((*child_folderp->getItemsBegin())->getViewModelItem()); + time_t most_recent_item_time = itemp->getCreationDate(); - LLFolderViewModelItemInventory* modelp = static_cast(child_folderp->getViewModelItem()); if (most_recent_item_time > modelp->getCreationDate()) { modelp->setCreationDate(most_recent_item_time); } } } + for (std::list::const_iterator it = folder->getItemsBegin(), end_it = folder->getItemsEnd(); + it != end_it && !has_favorites; + ++it) + { + LLFolderViewItem* child_itemp = *it; + has_favorites |= child_itemp->isFavorite(); + } + folder->setHasFavorites(has_favorites); + sort_modelp->setHasFavorites(has_favorites); base_t::sort(folder); } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 17f7f33891..560a2f265a 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -866,7 +866,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } } - if (getIsFavorite()) + if (isFavorite()) { items.push_back(std::string("Remove from Favorites")); } @@ -2264,7 +2264,7 @@ const LLUUID& LLItemBridge::getThumbnailUUID() const return LLUUID::null; } -bool LLItemBridge::getIsFavorite() const +bool LLItemBridge::isFavorite() const { LLViewerInventoryItem* item = NULL; LLInventoryModel* model = getInventoryModel(); @@ -2424,7 +2424,7 @@ const LLUUID& LLFolderBridge::getThumbnailUUID() const return LLUUID::null; } -bool LLFolderBridge::getIsFavorite() const +bool LLFolderBridge::isFavorite() const { LLViewerInventoryCategory* cat = getCategory(); if (cat) @@ -2434,6 +2434,16 @@ bool LLFolderBridge::getIsFavorite() const return false; } +bool LLFolderBridge::hasFavorites() const +{ + return mHasFavorites; +} + +void LLFolderBridge::setHasFavorites(bool val) +{ + mHasFavorites = val; +} + void LLFolderBridge::update() { // we know we have children but haven't fetched them (doesn't obey filter) @@ -8066,7 +8076,7 @@ void LLFolderViewGroupedItemBridge::groupFilterContextMenu(folder_view_item_dequ menuentry_vec_t disabled_items; if (get_selection_item_uuids(selected_items, ids)) { - if (!LLAppearanceMgr::instance().canAddWearables(ids) && canWearSelected(ids)) + if (!LLAppearanceMgr::instance().canAddWearables(ids, false) && canWearSelected(ids)) { disabled_items.push_back(std::string("Wearable And Object Wear")); disabled_items.push_back(std::string("Wearable Add")); diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index bbc601b34d..8bb4e188e6 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -86,7 +86,7 @@ public: //-------------------------------------------------------------------- virtual const LLUUID& getUUID() const { return mUUID; } virtual const LLUUID& getThumbnailUUID() const { return LLUUID::null; } - virtual bool getIsFavorite() const { return false; } + virtual bool isFavorite() const { return false; } virtual void clearDisplayName() { mDisplayName.clear(); } virtual void restoreItem() {} virtual void restoreToWorld() {} @@ -257,7 +257,9 @@ public: LLViewerInventoryItem* getItem() const; virtual const LLUUID& getThumbnailUUID() const; - virtual bool getIsFavorite() const; + virtual bool isFavorite() const; + virtual bool hasFavorites() const { return false; } + virtual void setHasFavorites(bool val) {} protected: BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response); @@ -279,6 +281,7 @@ public: mCallingCards(FALSE), mWearables(FALSE), mIsLoading(false), + mHasFavorites(false), mShowDescendantsCount(false) {} @@ -304,7 +307,9 @@ public: virtual std::string getLabelSuffix() const; virtual LLFontGL::StyleFlags getLabelStyle() const; virtual const LLUUID& getThumbnailUUID() const; - virtual bool getIsFavorite() const; + virtual bool isFavorite() const; + virtual bool hasFavorites() const; + virtual void setHasFavorites(bool val); void setShowDescendantsCount(bool show_count) {mShowDescendantsCount = show_count;} @@ -392,6 +397,7 @@ protected: bool mWearables; bool mIsLoading; bool mShowDescendantsCount; + bool mHasFavorites; LLTimer mTimeSinceRequestStart; std::string mMessage; LLRootHandle mHandle; diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 632e902d70..e38e2622c9 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -129,6 +129,9 @@ public: virtual void navigateToFolder(bool new_window = false, bool change_mode = false) {} virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); + virtual bool isFavorite() const { return false; } + virtual bool hasFavorites() const { return false; } + virtual void setHasFavorites(bool val) {}; virtual BOOL isItemMovable() const; virtual BOOL isItemRemovable() const; virtual BOOL removeItem(); 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 f1c87c8c5a..f62e04baf2 100644 --- a/indra/newview/skins/default/xui/en/floater_preview_trash.xml +++ b/indra/newview/skins/default/xui/en/floater_preview_trash.xml @@ -29,6 +29,8 @@ bevel_style="none" scroll.reserve_scroll_corner="false"> Date: Sat, 27 Apr 2024 05:01:36 +0300 Subject: viewer#1300 'Star' favorites in inventory #2 --- indra/llui/llfolderviewitem.cpp | 58 ++++++++++++++++++++++++++++++++++ indra/llui/llfolderviewitem.h | 1 + indra/newview/llinventoryfunctions.cpp | 22 +++++++++++-- indra/newview/llinventoryobserver.h | 1 + indra/newview/llinventorypanel.cpp | 35 ++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 84146e5829..be703a1e9a 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -1783,6 +1783,64 @@ BOOL LLFolderViewFolder::isMovable() return TRUE; } +void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) +{ + if (mHasFavorites != new_childs_value) + { + if (new_childs_value) + { + mHasFavorites = new_childs_value; + // propagate up to root + LLFolderViewFolder* parent = getParentFolder(); + while (parent && !parent->hasFavorites()) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + } + else + { + LLFolderViewFolder* parent = this; + while (parent) + { + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) + { + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) + { + has_favorites = true; + break; + } + } + + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) + { + has_favorites = true; + break; + } + } + + if (!has_favorites) + { + parent->mHasFavorites = false; + parent->setHasFavorites(false); + } + else + { + break; + } + parent = parent->getParentFolder(); + } + } + } +} + BOOL LLFolderViewFolder::isRemovable() { diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index eba3cf4f83..5905516023 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -401,6 +401,7 @@ public: bool isFavorite() const { return mIsFavorite; } bool hasFavorites() const { return mHasFavorites; } void setHasFavorites(bool val) { mHasFavorites = val; } + void updateHasFavorites(bool new_childs_value); // destroys this folder, and all children virtual void destroyView(); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index b95d75a782..135dfa3519 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2344,6 +2344,21 @@ void ungroup_folder_items(const LLUUID& folder_id) gInventory.notifyObservers(); } +class LLUpdateFavorite : public LLInventoryCallback +{ +public: + LLUpdateFavorite(const LLUUID& inv_item_id) + : mInvItemID(inv_item_id) + {} + /* 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); @@ -2351,15 +2366,18 @@ void set_favorite(const LLUUID& obj_id, bool favorite) { LLSD updates; updates["favorite"] = LLSD().with("toggled", favorite); + + LLPointer cb = new LLUpdateFavorite(obj_id); + LLViewerInventoryCategory* view_folder = dynamic_cast(obj); if (view_folder) { - update_inventory_category(obj_id, updates, NULL); + update_inventory_category(obj_id, updates, cb); } LLViewerInventoryItem* view_item = dynamic_cast(obj); if (view_item) { - update_inventory_item(obj_id, updates, NULL); + update_inventory_item(obj_id, updates, cb); } } } diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index bec08d2cdf..6cd630bcd2 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -60,6 +60,7 @@ public: CREATE = 512, // With ADD, item has just been created. // unfortunately a particular message is still associated with some unique semantics. UPDATE_CREATE = 1024, // With ADD, item added via UpdateCreateInventoryItem + UPDATE_FAVORITE = 2048, // With ADD, item added via UpdateCreateInventoryItem ALL = 0xffffffff }; LLInventoryObserver(); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index ab04a8589a..4aace2f96e 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -620,6 +620,19 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve } } + if (mask & LLInventoryObserver::UPDATE_FAVORITE) + { + if (view_item) + { + // TODO:: move to idle + LLFolderViewFolder* parent = view_item->getParentFolder(); + if (parent) + { + parent->updateHasFavorites(view_item->isFavorite()); + } + } + } + // We don't typically care which of these masks the item is actually flagged with, since the masks // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks @@ -648,6 +661,16 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve setSelection(item_id, FALSE); } updateFolderLabel(model_item->getParentUUID()); + if (model_item->getIsFavorite()) + { + // TODO:: move to idle + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); + if (new_parent) + { + new_parent->updateHasFavorites(true); + } + } + } ////////////////////////////// @@ -694,6 +717,13 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve updateFolderLabel(viewmodel_folder->getUUID()); } old_parent->getViewModelItem()->dirtyDescendantsFilter(); + + if (view_item->isFavorite()) + { + // TODO:: move to idle + old_parent->updateHasFavorites(false); // favorite was removed + new_parent->updateHasFavorites(true); // favorite was added + } } } } @@ -715,6 +745,11 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve { updateFolderLabel(viewmodel_folder->getUUID()); } + if (view_item->isFavorite()) + { + // TODO:: move to idle + parent->updateHasFavorites(false); // favorite was removed + } } } } -- cgit v1.2.3 From 2add3b49537fb041b880752dc5302ac6b317e601 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Apr 2024 22:07:12 +0300 Subject: viewer#1300 'Star' favorites in inventory #3 --- indra/llui/llfolderviewitem.cpp | 118 +++++++++++++++++++-------- indra/llui/llfolderviewitem.h | 7 ++ indra/llui/llfolderviewmodel.h | 3 +- indra/newview/llconversationmodel.h | 2 - indra/newview/llfolderviewmodelinventory.cpp | 6 +- indra/newview/llinventorybridge.cpp | 10 --- indra/newview/llinventorybridge.h | 6 -- indra/newview/llinventorypanel.cpp | 4 - indra/newview/llpanelobjectinventory.cpp | 2 - 9 files changed, 97 insertions(+), 61 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index be703a1e9a..2accec7a68 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -199,7 +199,6 @@ BOOL LLFolderViewItem::postBuild() // it also sets search strings so it requires a filter reset mLabel = vmi->getDisplayName(); mIsFavorite = vmi->isFavorite(); - mHasFavorites = vmi->hasFavorites(); setToolTip(vmi->getName()); // Dirty the filter flag of the model from the view (CHUI-849) @@ -314,7 +313,6 @@ void LLFolderViewItem::refresh() mLabel = vmi.getDisplayName(); mIsFavorite = vmi.isFavorite(); - mHasFavorites = vmi.hasFavorites(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -348,7 +346,6 @@ void LLFolderViewItem::refreshSuffix() mIconOverlay = vmi->getIconOverlay(); mIsFavorite = vmi->isFavorite(); - mHasFavorites = vmi->hasFavorites(); if (mRoot->useLabelSuffix()) { @@ -1116,7 +1113,8 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mIsFolderComplete(false), // folder might have children that are not loaded yet. mAreChildrenInited(false), // folder might have children that are not built yet. mLastArrangeGeneration( -1 ), - mLastCalculatedWidth(0) + mLastCalculatedWidth(0), + mFavoritesDirtyFlags(0) { } @@ -1142,6 +1140,11 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) // The LLView base class takes care of object destruction. make sure that we // don't have mouse or keyboard focus gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() + + if (mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } } // addToFolder() returns TRUE if it succeeds. FALSE otherwise @@ -1785,60 +1788,109 @@ BOOL LLFolderViewFolder::isMovable() void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) { - if (mHasFavorites != new_childs_value) + if (mFavoritesDirtyFlags == 0) + { + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } + if (new_childs_value) + { + mFavoritesDirtyFlags |= FAVORITE_ADDED; + } + else + { + mFavoritesDirtyFlags |= FAVORITE_REMOVED; + } +} + +void LLFolderViewFolder::onIdleUpdateFavorites(void* data) +{ + LLFolderViewFolder* self = reinterpret_cast(data); + if (self->mFavoritesDirtyFlags == 0) { - if (new_childs_value) + LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + if (self->getViewModelItem()->isItemInTrash()) + { + // do not display favorite-stars in trash + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + LLFolderViewFolder* root_folder = self->getRoot(); + if (self->mFavoritesDirtyFlags == FAVORITE_ADDED) + { + if (!self->mHasFavorites) { - mHasFavorites = new_childs_value; - // propagate up to root - LLFolderViewFolder* parent = getParentFolder(); - while (parent && !parent->hasFavorites()) + // propagate up, exclude root + LLFolderViewFolder* parent = self; + while (parent && !parent->hasFavorites() && root_folder != parent) { parent->setHasFavorites(true); parent = parent->getParentFolder(); } } - else + } + else if (self->mFavoritesDirtyFlags > FAVORITE_ADDED) + { + // full check + LLFolderViewFolder* parent = self; + while (parent && root_folder != parent) { - LLFolderViewFolder* parent = this; - while (parent) + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) { - bool has_favorites = false; - for (items_t::iterator iter = parent->mItems.begin(); - iter != parent->mItems.end();) + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) { - items_t::iterator iit = iter++; - if ((*iit)->isFavorite()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - for (folders_t::iterator iter = parent->mFolders.begin(); - iter != parent->mFolders.end() && !has_favorites;) + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) { - folders_t::iterator fit = iter++; - if ((*fit)->isFavorite() || (*fit)->hasFavorites()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - if (!has_favorites) + if (!has_favorites) + { + if (parent->hasFavorites()) { - parent->mHasFavorites = false; parent->setHasFavorites(false); } else { + // Nothing changed break; } - parent = parent->getParentFolder(); } + else + { + // propagate up, exclude root + while (parent && !parent->hasFavorites() && root_folder != parent) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + break; + } + parent = parent->getParentFolder(); } } + + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); } diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 5905516023..fc19514615 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -402,6 +402,13 @@ public: bool hasFavorites() const { return mHasFavorites; } void setHasFavorites(bool val) { mHasFavorites = val; } void updateHasFavorites(bool new_childs_value); +private: + static void onIdleUpdateFavorites(void* data); + + constexpr static S32 FAVORITE_ADDED = 1; + constexpr static S32 FAVORITE_REMOVED = 2; + S32 mFavoritesDirtyFlags { 0 }; +public: // destroys this folder, and all children virtual void destroyView(); diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 9d46334fc4..152801ec69 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -163,8 +163,6 @@ public: virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0; virtual bool isFavorite() const = 0; - virtual bool hasFavorites() const = 0; - virtual void setHasFavorites(bool val) = 0; virtual BOOL isItemWearable() const { return FALSE; } virtual BOOL isItemRenameable() const = 0; @@ -174,6 +172,7 @@ public: virtual void move( LLFolderViewModelItem* parent_listener ) = 0; virtual BOOL isItemRemovable( void ) const = 0; // Can be destroyed + virtual BOOL isItemInTrash(void) const = 0; virtual BOOL removeItem() = 0; virtual void removeBatch(std::vector& batch) = 0; diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index e2eaff12e5..3b70b9a568 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -80,8 +80,6 @@ public: virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual std::string getLabelSuffix() const { return LLStringUtil::null; } virtual bool isFavorite() const { return false; } - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {} virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; } virtual BOOL isItemMovable( void ) const { return FALSE; } diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index bc5a07abf2..6bf539fc48 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -111,8 +111,10 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder ) LLFolderViewItem* child_itemp = *it; has_favorites |= child_itemp->isFavorite(); } - folder->setHasFavorites(has_favorites); - sort_modelp->setHasFavorites(has_favorites); + if (has_favorites) + { + folder->updateHasFavorites(true); + } base_t::sort(folder); } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 560a2f265a..5620523f24 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2434,16 +2434,6 @@ bool LLFolderBridge::isFavorite() const return false; } -bool LLFolderBridge::hasFavorites() const -{ - return mHasFavorites; -} - -void LLFolderBridge::setHasFavorites(bool val) -{ - mHasFavorites = val; -} - void LLFolderBridge::update() { // we know we have children but haven't fetched them (doesn't obey filter) diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 8bb4e188e6..39cd393fdd 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -258,8 +258,6 @@ public: LLViewerInventoryItem* getItem() const; virtual const LLUUID& getThumbnailUUID() const; virtual bool isFavorite() const; - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {} protected: BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response); @@ -281,7 +279,6 @@ public: mCallingCards(FALSE), mWearables(FALSE), mIsLoading(false), - mHasFavorites(false), mShowDescendantsCount(false) {} @@ -308,8 +305,6 @@ public: virtual LLFontGL::StyleFlags getLabelStyle() const; virtual const LLUUID& getThumbnailUUID() const; virtual bool isFavorite() const; - virtual bool hasFavorites() const; - virtual void setHasFavorites(bool val); void setShowDescendantsCount(bool show_count) {mShowDescendantsCount = show_count;} @@ -397,7 +392,6 @@ protected: bool mWearables; bool mIsLoading; bool mShowDescendantsCount; - bool mHasFavorites; LLTimer mTimeSinceRequestStart; std::string mMessage; LLRootHandle mHandle; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4aace2f96e..6a5cd59acb 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -624,7 +624,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve { if (view_item) { - // TODO:: move to idle LLFolderViewFolder* parent = view_item->getParentFolder(); if (parent) { @@ -663,7 +662,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve updateFolderLabel(model_item->getParentUUID()); if (model_item->getIsFavorite()) { - // TODO:: move to idle LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); if (new_parent) { @@ -720,7 +718,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve if (view_item->isFavorite()) { - // TODO:: move to idle old_parent->updateHasFavorites(false); // favorite was removed new_parent->updateHasFavorites(true); // favorite was added } @@ -747,7 +744,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve } if (view_item->isFavorite()) { - // TODO:: move to idle parent->updateHasFavorites(false); // favorite was removed } } diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index e38e2622c9..3bd93b10ad 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -130,8 +130,6 @@ public: virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); virtual bool isFavorite() const { return false; } - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {}; virtual BOOL isItemMovable() const; virtual BOOL isItemRemovable() const; virtual BOOL removeItem(); -- cgit v1.2.3 From 1e7dc04644367dd7eb1469b36848aac265eb7050 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Apr 2024 22:07:12 +0300 Subject: viewer#1300 'Star' favorites in inventory #4 --- indra/llui/llfolderviewitem.cpp | 39 +++++++++++++++++++++--------- indra/llui/llfolderviewmodel.h | 3 +++ indra/newview/llconversationmodel.h | 2 ++ indra/newview/llfolderviewmodelinventory.h | 3 ++- indra/newview/llinventorybridge.cpp | 13 +++++++--- indra/newview/llinventorybridge.h | 3 ++- 6 files changed, 46 insertions(+), 17 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 2accec7a68..682da226bd 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -198,7 +198,7 @@ BOOL LLFolderViewItem::postBuild() // getDisplayName() is expensive (due to internal getLabelSuffix() and name building) // it also sets search strings so it requires a filter reset mLabel = vmi->getDisplayName(); - mIsFavorite = vmi->isFavorite(); + mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash(); setToolTip(vmi->getName()); // Dirty the filter flag of the model from the view (CHUI-849) @@ -312,7 +312,7 @@ void LLFolderViewItem::refresh() LLFolderViewModelItem& vmi = *getViewModelItem(); mLabel = vmi.getDisplayName(); - mIsFavorite = vmi.isFavorite(); + mIsFavorite = vmi.isFavorite() && !vmi.isItemInTrash(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -345,7 +345,7 @@ void LLFolderViewItem::refreshSuffix() mIconOpen = vmi->getIconOpen(); mIconOverlay = vmi->getIconOverlay(); - mIsFavorite = vmi->isFavorite(); + mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash(); if (mRoot->useLabelSuffix()) { @@ -1808,7 +1808,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) if (self->mFavoritesDirtyFlags == 0) { LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); return; } @@ -1816,20 +1816,26 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) { // do not display favorite-stars in trash self->mFavoritesDirtyFlags = 0; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); return; } - LLFolderViewFolder* root_folder = self->getRoot(); if (self->mFavoritesDirtyFlags == FAVORITE_ADDED) { if (!self->mHasFavorites) { // propagate up, exclude root LLFolderViewFolder* parent = self; - while (parent && !parent->hasFavorites() && root_folder != parent) + while (parent + && (!parent->hasFavorites() || parent->mFavoritesDirtyFlags) + && !parent->getViewModelItem()->isAgentInventoryRoot()) { parent->setHasFavorites(true); + if (parent->mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + parent->mFavoritesDirtyFlags = 0; + } parent = parent->getParentFolder(); } } @@ -1838,7 +1844,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) { // full check LLFolderViewFolder* parent = self; - while (parent && root_folder != parent) + while (parent && !parent->getViewModelItem()->isAgentInventoryRoot()) { bool has_favorites = false; for (items_t::iterator iter = parent->mItems.begin(); @@ -1878,19 +1884,28 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) else { // propagate up, exclude root - while (parent && !parent->hasFavorites() && root_folder != parent) + while (parent + && (!parent->hasFavorites() || parent->mFavoritesDirtyFlags) + && !parent->getViewModelItem()->isAgentInventoryRoot()) { parent->setHasFavorites(true); + if (parent->mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + parent->mFavoritesDirtyFlags = 0; + } parent = parent->getParentFolder(); } break; } + if (parent->mFavoritesDirtyFlags) + { + parent->mFavoritesDirtyFlags = 0; + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + } parent = parent->getParentFolder(); } } - - self->mFavoritesDirtyFlags = 0; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); } diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 152801ec69..b7afdb6aec 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -185,6 +185,9 @@ public: virtual void pasteFromClipboard() = 0; virtual void pasteLinkFromClipboard() = 0; + virtual bool isAgentInventory() const = 0; + virtual bool isAgentInventoryRoot() const = 0; + virtual void buildContextMenu(LLMenuGL& menu, U32 flags) = 0; virtual bool potentiallyVisible() = 0; // is the item definitely visible or we haven't made up our minds yet? diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 3b70b9a568..478daadfda 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -80,6 +80,8 @@ public: virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual std::string getLabelSuffix() const { return LLStringUtil::null; } virtual bool isFavorite() const { return false; } + virtual bool isAgentInventory() const { return false; } + virtual bool isAgentInventoryRoot() const { return false; } virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; } virtual BOOL isItemMovable( void ) const { return FALSE; } diff --git a/indra/newview/llfolderviewmodelinventory.h b/indra/newview/llfolderviewmodelinventory.h index 1649b2eed7..2459cc4f2c 100644 --- a/indra/newview/llfolderviewmodelinventory.h +++ b/indra/newview/llfolderviewmodelinventory.h @@ -47,7 +47,8 @@ public: virtual void showProperties(void) = 0; virtual BOOL isItemInTrash( void) const { return FALSE; } // TODO: make into pure virtual. virtual bool isItemInOutfits() const { return false; } - virtual BOOL isAgentInventory() const { return FALSE; } + virtual bool isAgentInventory() const { return false; } + virtual bool isAgentInventoryRoot() const { return false; } virtual BOOL isUpToDate() const = 0; virtual void addChild(LLFolderViewModelItem* child); virtual bool hasChildren() const = 0; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 5620523f24..1f91ef2772 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1335,7 +1335,7 @@ BOOL LLInvFVBridge::isLinkedObjectMissing() const return FALSE; } -BOOL LLInvFVBridge::isAgentInventory() const +bool LLInvFVBridge::isAgentInventory() const { const LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; @@ -1343,6 +1343,13 @@ BOOL LLInvFVBridge::isAgentInventory() const return model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()); } +bool LLInvFVBridge::isAgentInventoryRoot() const +{ + const LLInventoryModel* model = getInventoryModel(); + if(!model) return false; + return gInventory.getRootFolderID() == mUUID; +} + BOOL LLInvFVBridge::isCOFFolder() const { return LLAppearanceMgr::instance().getIsInCOF(mUUID); @@ -7868,7 +7875,7 @@ protected: BOOL isItemInTrash() const; // return true if the item is in agent inventory. if false, it // must be lost or in the inventory library. - BOOL isAgentInventory() const; + bool isAgentInventory() const; void wearOnAvatar(); }; @@ -7879,7 +7886,7 @@ BOOL LLWearableBridgeAction::isItemInTrash() const return mModel->isObjectDescendentOf(mUUID, trash_id); } -BOOL LLWearableBridgeAction::isAgentInventory() const +bool LLWearableBridgeAction::isAgentInventory() const { if(!mModel) return FALSE; if(gInventory.getRootFolderID() == mUUID) return TRUE; diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 39cd393fdd..5100da15cd 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -172,7 +172,8 @@ protected: BOOL isLinkedObjectInTrash() const; // Is this obj or its baseobj in the trash? BOOL isLinkedObjectMissing() const; // Is this a linked obj whose baseobj is not in inventory? - BOOL isAgentInventory() const; // false if lost or in the inventory library + bool isAgentInventory() const; // false if lost or in the inventory library + bool isAgentInventoryRoot() const; // true if worn by agent BOOL isCOFFolder() const; // true if COF or descendant of BOOL isInboxFolder() const; // true if COF or descendant of marketplace inbox -- cgit v1.2.3 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(-) (limited to 'indra') 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 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/llinventory/llinventory.cpp | 26 +++++- 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 +- 10 files changed, 114 insertions(+), 25 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') diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index 2f701f12a0..0545c6262c 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -874,12 +874,20 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu output_stream << "\t\tparent_id\t" << uuid_str << "\n"; mPermissions.exportLegacyStream(output_stream); - if (mThumbnailUUID.notNull()) + bool needs_metadata = mThumbnailUUID.notNull() || mFavorite; + if (needs_metadata) { // Max length is 255 chars, will have to export differently if it gets more data // Ex: use newline and toNotation (uses {}) for unlimited size LLSD metadata; - metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); + if (mThumbnailUUID.notNull()) + { + metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); + } + if (mFavorite) + { + metadata["favorite"] = LLSD().with("toggled", mFavorite); + } output_stream << "\t\tmetadata\t"; LLSDSerialize::toXML(metadata, output_stream); @@ -1488,11 +1496,21 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) output_stream << "\t\ttype\t" << LLAssetType::lookup(mType) << "\n"; output_stream << "\t\tpref_type\t" << LLFolderType::lookup(mPreferredType) << "\n"; output_stream << "\t\tname\t" << mName.c_str() << "|\n"; - if (mThumbnailUUID.notNull()) + + bool needs_metadata = mThumbnailUUID.notNull() || mFavorite; + if (needs_metadata) { // Only up to 255 chars LLSD metadata; - metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); + if (mThumbnailUUID.notNull()) + { + metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); + } + if (mFavorite) + { + metadata["favorite"] = LLSD().with("toggled", mFavorite); + } + output_stream << "\t\tmetadata\t"; LLSDSerialize::toXML(metadata, output_stream); output_stream << "|\n"; 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"> Date: Thu, 2 May 2024 21:08:41 +0300 Subject: Viewer#1301 Small cleanup notecards do not need to store 'favorite' flag --- indra/llinventory/llinventory.cpp | 26 ++++---------------------- indra/newview/llinventorypanel.cpp | 9 --------- 2 files changed, 4 insertions(+), 31 deletions(-) (limited to 'indra') diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index 0545c6262c..2f701f12a0 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -874,20 +874,12 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu output_stream << "\t\tparent_id\t" << uuid_str << "\n"; mPermissions.exportLegacyStream(output_stream); - bool needs_metadata = mThumbnailUUID.notNull() || mFavorite; - if (needs_metadata) + if (mThumbnailUUID.notNull()) { // Max length is 255 chars, will have to export differently if it gets more data // Ex: use newline and toNotation (uses {}) for unlimited size LLSD metadata; - if (mThumbnailUUID.notNull()) - { - metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); - } - if (mFavorite) - { - metadata["favorite"] = LLSD().with("toggled", mFavorite); - } + metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); output_stream << "\t\tmetadata\t"; LLSDSerialize::toXML(metadata, output_stream); @@ -1496,21 +1488,11 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) output_stream << "\t\ttype\t" << LLAssetType::lookup(mType) << "\n"; output_stream << "\t\tpref_type\t" << LLFolderType::lookup(mPreferredType) << "\n"; output_stream << "\t\tname\t" << mName.c_str() << "|\n"; - - bool needs_metadata = mThumbnailUUID.notNull() || mFavorite; - if (needs_metadata) + if (mThumbnailUUID.notNull()) { // Only up to 255 chars LLSD metadata; - if (mThumbnailUUID.notNull()) - { - metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); - } - if (mFavorite) - { - metadata["favorite"] = LLSD().with("toggled", mFavorite); - } - + metadata["thumbnail"] = LLSD().with("asset_id", mThumbnailUUID); output_stream << "\t\tmetadata\t"; LLSDSerialize::toXML(metadata, output_stream); output_stream << "|\n"; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index f22ac6f775..3892bfee03 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1253,7 +1253,6 @@ 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 @@ -1354,14 +1353,6 @@ 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() { -- cgit v1.2.3 From db3e5afbfbbce73e8f8339e8b4f938f11023ca64 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 May 2024 23:10:51 +0300 Subject: Viewer#1301 Implement Inventory Favorites Tab --- indra/newview/llinventorybridge.cpp | 23 +++- indra/newview/llinventoryfunctions.cpp | 14 +++ indra/newview/llinventoryfunctions.h | 15 +++ indra/newview/llinventorypanel.cpp | 193 ++++++++++++++++++++++++++++++--- indra/newview/llinventorypanel.h | 5 +- indra/newview/llviewerinventory.cpp | 3 +- 6 files changed, 233 insertions(+), 20 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index d7c7c7b552..20b2e1334e 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -838,6 +838,8 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { const LLInventoryObject *obj = getInventoryObject(); bool single_folder_root = (mRoot == NULL); + bool is_cof = isCOFFolder(); + bool is_inbox = isInboxFolder(); if (obj) { @@ -853,7 +855,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } bool is_agent_inventory = isAgentInventory(); - if (is_agent_inventory && !single_folder_root) + if (is_agent_inventory && !single_folder_root && !is_cof && !is_inbox) { items.push_back(std::string("New folder from selected")); items.push_back(std::string("Subfolder Separator")); @@ -889,6 +891,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, if (!isItemMovable() || !isItemRemovable()) { disabled_items.push_back(std::string("Cut")); + disabled_items.push_back(std::string("New folder from selected")); } } else @@ -898,7 +901,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, items.push_back(std::string("Find Links")); } - if (!isInboxFolder() && !single_folder_root) + if (!is_inbox && !single_folder_root) { items.push_back(std::string("Rename")); if (!isItemRenameable() || ((flags & FIRST_SELECTED_ITEM) == 0)) @@ -938,6 +941,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, if (!isItemMovable() || !isItemRemovable()) { disabled_items.push_back(std::string("Cut")); + disabled_items.push_back(std::string("New folder from selected")); } if (canListOnMarketplace() && !isMarketplaceListingsFolder() && !isInboxFolder()) @@ -960,7 +964,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } // Don't allow items to be pasted directly into the COF or the inbox - if (!isCOFFolder() && !isInboxFolder()) + if (!is_cof && !is_inbox) { items.push_back(std::string("Paste")); } @@ -4445,6 +4449,15 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items items.push_back(std::string("Rename")); items.push_back(std::string("thumbnail")); + if (cat->getIsFavorite()) + { + items.push_back(std::string("Remove from Favorites")); + } + else + { + items.push_back(std::string("Add to Favorites")); + } + addDeleteContextMenuOptions(items, disabled_items); // EXT-4030: disallow deletion of currently worn outfit const LLViewerInventoryItem *base_outfit_link = LLAppearanceMgr::instance().getBaseOutfitLink(); @@ -8029,6 +8042,7 @@ void LLRecentItemsFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) buildContextMenuOptions(flags, items, disabled_items); items.erase(std::remove(items.begin(), items.end(), std::string("New Folder")), items.end()); + items.erase(std::remove(items.begin(), items.end(), std::string("New folder from selected")), items.end()); hide_context_entries(menu, items, disabled_items); } @@ -8072,6 +8086,9 @@ void LLFavoritesFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) menuentry_vec_t disabled_items, items; buildContextMenuOptions(flags, items, disabled_items); + items.erase(std::remove(items.begin(), items.end(), std::string("New Folder")), items.end()); + items.erase(std::remove(items.begin(), items.end(), std::string("New folder from selected")), items.end()); + hide_context_entries(menu, items, disabled_items); } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 135dfa3519..81be2c1f24 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2663,6 +2663,20 @@ bool LLIsTypeWithPermissions::operator()(LLInventoryCategory* cat, LLInventoryIt return FALSE; } +bool LLFavoritesCollector::operator()(LLInventoryCategory* cat, + LLInventoryItem* item) +{ + if (item && item->getIsFavorite()) + { + return true; + } + if (cat && cat->getIsFavorite()) + { + return true; + } + return false; +} + bool LLBuddyCollector::operator()(LLInventoryCategory* cat, LLInventoryItem* item) { diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 14038967c6..44f85bfb3e 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -324,6 +324,21 @@ protected: LLUUID mGroupID; }; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLFavoritesCollector +// +// Simple class that collects calling cards that are not null, and not +// the agent. Duplicates are possible. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLFavoritesCollector : public LLInventoryCollectFunctor +{ +public: + LLFavoritesCollector() {} + virtual ~LLFavoritesCollector() {} + virtual bool operator()(LLInventoryCategory* cat, + LLInventoryItem* item); +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLBuddyCollector // diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 3892bfee03..4682f2085b 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -865,7 +865,23 @@ void LLInventoryPanel::idle(void* user_data) bool in_visible_chain = panel->isInVisibleChain(); - if (!panel->mBuildViewsQueue.empty()) + if (!panel->mBuildRootQueue.empty()) + { + const F64 max_time = in_visible_chain ? 0.006f : 0.001f; // 6 ms + F64 curent_time = LLTimer::getTotalSeconds(); + panel->mBuildViewsEndTime = curent_time + max_time; + + while (curent_time < panel->mBuildViewsEndTime + && !panel->mBuildRootQueue.empty()) + { + LLUUID item_id = panel->mBuildRootQueue.back(); + panel->mBuildRootQueue.pop_back(); + panel->findAndInitRootContent(item_id); + + curent_time = LLTimer::getTotalSeconds(); + } + } + else if (!panel->mBuildViewsQueue.empty()) { const F64 max_time = in_visible_chain ? 0.006f : 0.001f; // 6 ms F64 curent_time = LLTimer::getTotalSeconds(); @@ -949,7 +965,7 @@ void LLInventoryPanel::initializeViews(F64 max_time) // init everything initRootContent(); - if (mBuildViewsQueue.empty()) + if (mBuildViewsQueue.empty() && mBuildRootQueue.empty()) { mViewsInitialized = VIEWS_INITIALIZED; } @@ -2252,12 +2268,19 @@ public: getFilter().setFilterNoMarketplaceFolder(); } + void removeItemID(const LLUUID& id) override; + protected: LLInventoryFavoritesItemsPanel(const Params&); friend class LLUICtrlFactory; - void initRootContent(const LLUUID& id); + void findAndInitRootContent(const LLUUID& folder_id) override; void initRootContent() override; + + bool removeFavorite(const LLUUID& id, const LLInventoryObject* model_item); + void itemChanged(const LLUUID& item_id, U32 mask, const LLInventoryObject* model_item) override; + + std::set mRootContentIDs; }; LLInventoryFavoritesItemsPanel::LLInventoryFavoritesItemsPanel(const Params& params) @@ -2267,8 +2290,27 @@ LLInventoryFavoritesItemsPanel::LLInventoryFavoritesItemsPanel(const Params& par mInvFVBridgeBuilder = &FAVORITES_BUILDER; } -void LLInventoryFavoritesItemsPanel::initRootContent(const LLUUID& id) +void LLInventoryFavoritesItemsPanel::removeItemID(const LLUUID& id) +{ + std::set::iterator found = mRootContentIDs.find(id); + if (found != mRootContentIDs.end()) + { + mRootContentIDs.erase(found); + // check content for favorites + mBuildRootQueue.emplace_back(id); + } + + LLInventoryPanel::removeItemID(id); +} + +void LLInventoryFavoritesItemsPanel::findAndInitRootContent(const LLUUID& id) { + F64 curent_time = LLTimer::getTotalSeconds(); + if (mBuildViewsEndTime < curent_time) + { + mBuildRootQueue.emplace_back(id); + return; + } LLViewerInventoryCategory::cat_array_t* categories; LLViewerInventoryItem::item_array_t* items; mInventory->lockDirectDescendentArrays(id, categories, items); @@ -2285,14 +2327,18 @@ void LLInventoryFavoritesItemsPanel::initRootContent(const LLUUID& id) } else if (cat->getIsFavorite()) { - const LLUUID& parent_id = cat->getParentUUID(); - LLFolderViewItem* folder_view_item = getItemByID(cat->getUUID()); // Should be NULL + LLFolderViewItem* folder_view_item = getItemByID(cat->getUUID()); + if (!folder_view_item) + { + const LLUUID& parent_id = cat->getParentUUID(); + mRootContentIDs.emplace(cat->getUUID()); - buildViewsTree(cat->getUUID(), parent_id, cat, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + buildViewsTree(cat->getUUID(), parent_id, cat, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + } } - else // Todo: timelimits + else { - initRootContent(cat->getUUID()); + findAndInitRootContent(cat->getUUID()); } } } @@ -2303,12 +2349,17 @@ void LLInventoryFavoritesItemsPanel::initRootContent(const LLUUID& id) for (S32 i = 0; i < count; ++i) { LLViewerInventoryItem* item = items->at(i); - if (item->getIsFavorite() && typedViewsFilter(id, item)) + const LLUUID item_id = item->getUUID(); + if (item->getIsFavorite() && typedViewsFilter(item_id, item)) { - const LLUUID& parent_id = item->getParentUUID(); - LLFolderViewItem* folder_view_item = getItemByID(id); // Should be NULL + LLFolderViewItem* folder_view_item = getItemByID(id); + if (!folder_view_item) + { + const LLUUID& parent_id = item->getParentUUID(); + mRootContentIDs.emplace(item_id); - buildViewsTree(item->getUUID(), parent_id, item, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + buildViewsTree(item_id, parent_id, item, folder_view_item, mFolderRoot.get(), BUILD_TIMELIMIT); + } } } } @@ -2316,9 +2367,123 @@ void LLInventoryFavoritesItemsPanel::initRootContent(const LLUUID& id) void LLInventoryFavoritesItemsPanel::initRootContent() { - initRootContent(gInventory.getRootFolderID()); // My Inventory + findAndInitRootContent(gInventory.getRootFolderID()); // My Inventory +} + +bool LLInventoryFavoritesItemsPanel::removeFavorite(const LLUUID& id, const LLInventoryObject* model_item) +{ + std::set::iterator found = mRootContentIDs.find(id); + if (found == mRootContentIDs.end()) + { + return false; + } + + mRootContentIDs.erase(found); + + // This item is in root's content, remove item's UI. + LLFolderViewItem* view_item = getItemByID(id); + if (view_item) + { + LLFolderViewFolder* parent = view_item->getParentFolder(); + LLFolderViewModelItemInventory* viewmodel_item = static_cast(view_item->getViewModelItem()); + if (viewmodel_item) + { + removeItemID(viewmodel_item->getUUID()); + } + view_item->destroyView(); + if (parent) + { + parent->getViewModelItem()->dirtyDescendantsFilter(); + LLFolderViewModelItemInventory* viewmodel_folder = static_cast(parent->getViewModelItem()); + if (viewmodel_folder) + { + updateFolderLabel(viewmodel_folder->getUUID()); + } + if (view_item->isFavorite()) + { + parent->updateHasFavorites(false); // favorite was removed + } + } + } + + return true; } +void LLInventoryFavoritesItemsPanel::itemChanged(const LLUUID& id, U32 mask, const LLInventoryObject* model_item) +{ + if (!model_item && !getItemByID(id)) + { + // remove operation, but item is not in panel already + return; + } + + bool handled = false; + + if (mask & (LLInventoryObserver::UPDATE_FAVORITE | + LLInventoryObserver::STRUCTURE | + LLInventoryObserver::ADD | + LLInventoryObserver::REMOVE)) + { + if (model_item && model_item->getIsFavorite()) + { + LLFolderViewItem* view_item = getItemByID(id); + if (!view_item) + { + const LLViewerInventoryCategory* cat = dynamic_cast(model_item); + if (cat) + { + // New favorite folder + if (cat->getPreferredType() != LLFolderType::FT_TRASH) + { + // If any descendants were in the list, remove them + LLFavoritesCollector is_favorite; + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendentsIf(id, cat_array, item_array, FALSE, is_favorite); + for (LLInventoryModel::cat_array_t::const_iterator it = cat_array.begin(); it != cat_array.end(); ++it) + { + removeFavorite((*it)->getUUID(), *it); + } + for (LLInventoryModel::item_array_t::const_iterator it = item_array.begin(); it != item_array.end(); ++it) + { + removeFavorite((*it)->getUUID(), *it); + } + + LLFolderViewItem* folder_view_item = getItemByID(cat->getUUID()); + if (!folder_view_item) + { + const LLUUID& parent_id = cat->getParentUUID(); + mRootContentIDs.emplace(cat->getUUID()); + + buildViewsTree(cat->getUUID(), parent_id, cat, folder_view_item, mFolderRoot.get(), BUILD_ONE_FOLDER); + } + } + } + else + { + // New favorite item + if (model_item->getIsFavorite() && typedViewsFilter(id, model_item)) + { + const LLUUID& parent_id = model_item->getParentUUID(); + mRootContentIDs.emplace(id); + + buildViewsTree(id, parent_id, model_item, NULL, mFolderRoot.get(), BUILD_ONE_FOLDER); + } + } + handled = true; + } + } + else + { + handled = removeFavorite(id, model_item); + } + } + + if (!handled) + { + LLInventoryPanel::itemChanged(id, mask, model_item); + } +} /************************************************************************/ /* LLInventorySingleFolderPanel */ /************************************************************************/ diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index b6d21ea9a8..a03ec15777 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -251,7 +251,7 @@ public: bool reset_filter = false); static void setSFViewAndOpenFolder(const LLInventoryPanel* panel, const LLUUID& folder_id); void addItemID(const LLUUID& id, LLFolderViewItem* itemp); - void removeItemID(const LLUUID& id); + virtual void removeItemID(const LLUUID& id); LLFolderViewItem* getItemByID(const LLUUID& id); LLFolderViewFolder* getFolderByID(const LLUUID& id); void setSelectionByID(const LLUUID& obj_id, BOOL take_keyboard_focus); @@ -335,6 +335,7 @@ protected: // Builds the UI. Call this once the inventory is usable. void initializeViews(F64 max_time); virtual void initRootContent(); + virtual void findAndInitRootContent(const LLUUID& root_id) {}; // Specific inventory colors static bool sColorSetInitialized; @@ -395,7 +396,7 @@ protected: EViewsInitializationState mViewsInitialized; // Whether views have been generated F64 mBuildViewsEndTime; // Stop building views past this timestamp std::deque mBuildViewsQueue; - std::deque mBuildRootContent; + std::deque mBuildRootQueue; }; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index b9a7c9448f..3a4ac96826 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1436,7 +1436,8 @@ void update_inventory_category( if(obj) { if (LLFolderType::lookupIsProtectedType(obj->getPreferredType()) - && (updates.size() != 1 || !updates.has("thumbnail"))) + && (updates.size() != 1 + || !(updates.has("thumbnail") || updates.has("favorite")))) { LLNotificationsUtil::add("CannotModifyProtectedCategories"); return; -- cgit v1.2.3 From 1c170381aea21cfd75d7b8789374f04f3a46d408 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 4 May 2024 01:50:50 +0300 Subject: viewer#1300 Update Inventory Settings --- indra/llui/llfolderviewitem.cpp | 23 ++- indra/llui/llfolderviewitem.h | 2 + indra/newview/app_settings/settings.xml | 33 ++++ indra/newview/llfloaterinventorysettings.cpp | 23 ++- indra/newview/llfloaterinventorysettings.h | 5 + indra/newview/llinventorybridge.cpp | 3 +- indra/newview/skins/default/colors.xml | 3 + .../skins/default/textures/icons/Icon_Pointer.png | Bin 0 -> 294 bytes indra/newview/skins/default/textures/textures.xml | 1 + .../default/xui/en/floater_inventory_settings.xml | 168 +++++++++++++++++---- 10 files changed, 229 insertions(+), 32 deletions(-) create mode 100644 indra/newview/skins/default/textures/icons/Icon_Pointer.png (limited to 'indra') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 682da226bd..b473b3b395 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -58,6 +58,7 @@ LLUIColor LLFolderViewItem::sFilterBGColor; LLUIColor LLFolderViewItem::sFilterTextColor; LLUIColor LLFolderViewItem::sSuffixColor; LLUIColor LLFolderViewItem::sSearchStatusColor; +LLUIColor LLFolderViewItem::sFavoriteColor; // only integers can be initialized in header const F32 LLFolderViewItem::FOLDER_CLOSE_TIME_CONSTANT = 0.02f; @@ -173,6 +174,7 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); + sFavoriteColor = LLUIColorTable::instance().getColor("InventoryFavoriteColor", DEFAULT_WHITE); sColorSetInitialized = true; } @@ -764,6 +766,12 @@ 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; + } + LLUIImage* favorite_image = NULL; if (mIsFavorite) { @@ -1019,7 +1027,20 @@ void LLFolderViewItem::draw() } } - LLColor4 color = (mIsSelected && filled) ? mFontHighlightColor : mFontColor; + static LLUICachedControl highlight_color("InventoryFavoritesColorText", true); + LLColor4 color; + if (mIsSelected && filled) + { + color = mFontHighlightColor; + } + else if (mIsFavorite && highlight_color) + { + color = sFavoriteColor; + } + else + { + color = mFontColor; + } if (isFadeItem()) { diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index fc19514615..462f703a9c 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -149,6 +149,8 @@ protected: static LLUIColor sFilterTextColor; static LLUIColor sSuffixColor; static LLUIColor sSearchStatusColor; + static LLUIColor sFavoriteColor; + // this is an internal method used for adding items to folders. A // no-op at this level, but reimplemented in derived classes. diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2f7c256b49..21afd37a35 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -17405,6 +17405,39 @@ Value 0 + InventoryFavoritesUseStar + + Comment + Show star near favorited items in inventory + Persist + 0 + Type + Boolean + Value + 1 + + InventoryFavoritesColorText + + Comment + render favorite items using InventoryFavoriteText as color + Persist + 0 + Type + Boolean + Value + 1 + + InventoryAddAttachmentBehavior + + Comment + Defines behavior when hitting return on an inventory item + Persist + 0 + Type + Boolean + Value + 0 + StatsReportMaxDuration Comment diff --git a/indra/newview/llfloaterinventorysettings.cpp b/indra/newview/llfloaterinventorysettings.cpp index 29d6e90a33..612953b6df 100644 --- a/indra/newview/llfloaterinventorysettings.cpp +++ b/indra/newview/llfloaterinventorysettings.cpp @@ -28,9 +28,13 @@ #include "llfloaterinventorysettings.h" +#include "llcolorswatch.h" + LLFloaterInventorySettings::LLFloaterInventorySettings(const LLSD& key) : LLFloater(key) { + mCommitCallbackRegistrar.add("ScriptPref.applyUIColor", boost::bind(&LLFloaterInventorySettings::applyUIColor, this, _1, _2)); + mCommitCallbackRegistrar.add("ScriptPref.getUIColor", boost::bind(&LLFloaterInventorySettings::getUIColor, this, _1, _2)); } LLFloaterInventorySettings::~LLFloaterInventorySettings() @@ -38,7 +42,24 @@ LLFloaterInventorySettings::~LLFloaterInventorySettings() BOOL LLFloaterInventorySettings::postBuild() { - getChild("ok_btn")->setCommitCallback(boost::bind(&LLFloater::closeFloater, this, false)); + getChild("favorites_color")->setCommitCallback(boost::bind(&LLFloaterInventorySettings::updateColorSwatch, this)); return TRUE; } +void LLFloaterInventorySettings::updateColorSwatch() +{ + bool val = getChild("favorites_color")->getEnabled(); + getChild("favorites_color")->setEnabled(val); +} + +void LLFloaterInventorySettings::applyUIColor(LLUICtrl* ctrl, const LLSD& param) +{ + LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); +} + +void LLFloaterInventorySettings::getUIColor(LLUICtrl* ctrl, const LLSD& param) +{ + LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*)ctrl; + color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString())); +} + diff --git a/indra/newview/llfloaterinventorysettings.h b/indra/newview/llfloaterinventorysettings.h index 50304276c7..87c61046e2 100644 --- a/indra/newview/llfloaterinventorysettings.h +++ b/indra/newview/llfloaterinventorysettings.h @@ -40,6 +40,11 @@ public: private: LLFloaterInventorySettings(const LLSD& key); ~LLFloaterInventorySettings(); + + void updateColorSwatch(); + + void applyUIColor(LLUICtrl* ctrl, const LLSD& param); + void getUIColor(LLUICtrl* ctrl, const LLSD& param); }; #endif diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 20b2e1334e..20d415cda9 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -7851,7 +7851,8 @@ void LLObjectBridgeAction::attachOrDetach() } else { - LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, false); // Don't replace if adding. + static LLCachedControl inventory_linking(gSavedSettings, "InventoryAddAttachmentBehavior", false); + LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, inventory_linking()); // Don't replace if adding. } } diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index 92f63a1820..60d9a5da23 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -453,6 +453,9 @@ + diff --git a/indra/newview/skins/default/textures/icons/Icon_Pointer.png b/indra/newview/skins/default/textures/icons/Icon_Pointer.png new file mode 100644 index 0000000000..021942a8aa Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Icon_Pointer.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 7f3b9a8cee..c9dcaebeeb 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -907,4 +907,5 @@ with the same filename but different name + 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 156bba6c27..e027d7556f 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="370" - width="370" + height="460" + width="460" name="inventory_settings" title="INVENTORY SETTINGS"> + Clicking on "Show in inventory" or "Find original" @@ -146,10 +156,10 @@ font="SansSerifMedium" left="60" width="300" - height="45" + height="44" name="find_original_settings"> - + + + + + + + diff --git a/indra/newview/skins/default/xui/en/menu_outfit_sort.xml b/indra/newview/skins/default/xui/en/menu_outfit_sort.xml new file mode 100644 index 0000000000..eeee5689a7 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_outfit_sort.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml index 6bd491f7a3..96624e7aa2 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_gallery.xml @@ -35,7 +35,7 @@ - - - - -