From 3058e6e6fd66ad4abb91fa5354ee11f6b7843a02 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 19 Jul 2023 21:15:52 +0300 Subject: [PATCH 1/5] SL-20015 wait for the outfit items to load before wearing it --- indra/newview/llaisapi.cpp | 36 ++++++++++++++++++++++++++++++ indra/newview/llaisapi.h | 2 ++ indra/newview/llappearancemgr.cpp | 29 ++++++++++++++++++++++++ indra/newview/llappearancemgr.h | 1 + indra/newview/llinventorymodel.cpp | 12 +++++++++- indra/newview/llinventorymodel.h | 4 ++++ indra/newview/llstartup.cpp | 25 ++++++++++++++++++++- indra/newview/llstartup.h | 1 + 8 files changed, 108 insertions(+), 2 deletions(-) diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp index 4ac2acf1d1..f3799361db 100644 --- a/indra/newview/llaisapi.cpp +++ b/indra/newview/llaisapi.cpp @@ -709,6 +709,40 @@ void AISAPI::FetchCOF(completion_t callback) EnqueueAISCommand("FetchCOF", proc); } +void AISAPI::FetchCategoryLinks(const LLUUID &catId, completion_t callback) +{ + std::string cap = getInvCap(); + if (cap.empty()) + { + LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL; + if (callback) + { + callback(LLUUID::null); + } + return; + } + std::string url = cap + std::string("/category/") + catId.asString() + "/links"; + + invokationFn_t getFn = boost::bind( + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. + static_cast + //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders + (&LLCoreHttpUtil::HttpCoroutineAdapter::getAndSuspend), + _1, _2, _3, _5, _6); + + LLCoprocedureManager::CoProcedure_t proc( + boost::bind(&AISAPI::InvokeAISCommandCoro, _1, getFn, url, LLUUID::null, LLSD(), callback, FETCHCATEGORYLINKS)); + + EnqueueAISCommand("FetchCategoryLinks", proc); +} + /*static*/ void AISAPI::FetchOrphans(completion_t callback) { @@ -938,6 +972,7 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht case FETCHCATEGORYCATEGORIES: case FETCHCATEGORYCHILDREN: case FETCHCATEGORYSUBSET: + case FETCHCATEGORYLINKS: case FETCHCOF: if (result.has("category_id")) { @@ -1002,6 +1037,7 @@ AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& || (type == AISAPI::FETCHCATEGORYCATEGORIES) || (type == AISAPI::FETCHCATEGORYSUBSET) || (type == AISAPI::FETCHCOF) + || (type == AISAPI::FETCHCATEGORYLINKS) || (type == AISAPI::FETCHORPHANS); // parse update llsd into stuff to do or parse received items. mFetchDepth = MAX_FOLDER_DEPTH_REQUEST; diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h index 973c82a847..53c74ae078 100644 --- a/indra/newview/llaisapi.h +++ b/indra/newview/llaisapi.h @@ -62,6 +62,7 @@ public: static void FetchCategoryCategories(const LLUUID &catId, ITEM_TYPE type = AISAPI::ITEM_TYPE::INVENTORY, bool recursive = false, completion_t callback = completion_t(), S32 depth = 0); static void FetchCategorySubset(const LLUUID& catId, const uuid_vec_t specificChildren, ITEM_TYPE type = AISAPI::ITEM_TYPE::INVENTORY, bool recursive = false, completion_t callback = completion_t(), S32 depth = 0); static void FetchCOF(completion_t callback = completion_t()); + static void FetchCategoryLinks(const LLUUID &catId, completion_t callback = completion_t()); static void FetchOrphans(completion_t callback = completion_t() ); static void CopyLibraryCategory(const LLUUID& sourceId, const LLUUID& destId, bool copySubfolders, completion_t callback = completion_t()); @@ -81,6 +82,7 @@ public: FETCHCATEGORYSUBSET, FETCHCOF, FETCHORPHANS, + FETCHCATEGORYLINKS } COMMAND_TYPE; private: diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 454ac5d88c..d4fc6a9f9d 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -4612,6 +4612,35 @@ void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb) } } +void callAfterCategoryLinksFetch(const LLUUID &cat_id, nullary_func_t cb) +{ + LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); + if (AISAPI::isAvailable()) + { + // Mark folder (update timer) so that background fetch won't request it + cat->setFetching(LLViewerInventoryCategory::FETCH_RECURSIVE); + // Assume that we have no relevant cache. Fetch folder, and items folder's links point to. + AISAPI::FetchCategoryLinks(cat_id, + [cb, cat_id](const LLUUID &id) + { + cb(); + LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); + if (cat) + { + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + } + }); + } + else + { + LL_WARNS() << "AIS API v3 not available, can't use AISAPI::FetchCOF" << LL_ENDL; + // startup should have marked folder as fetching, remove that + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + callAfterCategoryFetch(cat_id, cb); + } + +} + void add_wearable_type_counts(const uuid_vec_t& ids, S32& clothing_count, S32& bodypart_count, diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index f6aa30d865..43839e47a6 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -340,6 +340,7 @@ LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& // Invoke a given callable after category contents are fully fetched. void callAfterCOFFetch(nullary_func_t cb); void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb); +void callAfterCategoryLinksFetch(const LLUUID &cat_id, nullary_func_t cb); // Wear all items in a uuid vector. void wear_multiple(const uuid_vec_t& ids, bool replace); diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index ed375661b8..586f1388ff 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -79,6 +79,8 @@ const S32 LLInventoryModel::sCurrentInvCacheVersion = 3; BOOL LLInventoryModel::sFirstTimeInViewer2 = TRUE; +S32 LLInventoryModel::sPendingSystemFolders = 0; + ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- @@ -861,8 +863,9 @@ void LLInventoryModel::ensureCategoryForTypeExists(LLFolderType::EType preferred } else { - LL_DEBUGS("Inventory") << "Created category: " << new_cat_id + LL_WARNS("Inventory") << "Created category: " << new_cat_id << " for type: " << preferred_type << LL_ENDL; + sPendingSystemFolders--; } } ); @@ -873,6 +876,10 @@ void LLInventoryModel::ensureCategoryForTypeExists(LLFolderType::EType preferred << " because inventory is not usable" << LL_ENDL; } } + else + { + sPendingSystemFolders--; + } } const LLUUID LLInventoryModel::findCategoryUUIDForTypeInRoot( @@ -3253,6 +3260,9 @@ LLCore::HttpHandle LLInventoryModel::requestPost(bool foreground, void LLInventoryModel::createCommonSystemCategories() { + //amount of System Folder we should wait for + sPendingSystemFolders = 8; + gInventory.ensureCategoryForTypeExists(LLFolderType::FT_TRASH); gInventory.ensureCategoryForTypeExists(LLFolderType::FT_FAVORITE); gInventory.ensureCategoryForTypeExists(LLFolderType::FT_CALLINGCARD); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index db159d480a..a90ed2bf42 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -227,10 +227,14 @@ private: //-------------------------------------------------------------------- public: static BOOL getIsFirstTimeInViewer2(); + static bool isSysFoldersReady() { return (sPendingSystemFolders == 0); } + private: static BOOL sFirstTimeInViewer2; const static S32 sCurrentInvCacheVersion; // expected inventory cache version + static S32 sPendingSystemFolders; + /** Initialization/Setup ** ** *******************************************************************************/ diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 9f9e117760..c925563919 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1912,7 +1912,22 @@ bool idle_startup() LLInventoryModelBackgroundFetch::instance().start(); gInventory.createCommonSystemCategories(); + LLStartUp::setStartupState(STATE_INVENTORY_CALLBACKS ); + display_startup(); + return FALSE; + } + + //--------------------------------------------------------------------- + // STATE_INVENTORY_CALLBACKS + //--------------------------------------------------------------------- + if (STATE_INVENTORY_CALLBACKS == LLStartUp::getStartupState()) + { + if (!LLInventoryModel::isSysFoldersReady()) + { + display_startup(); + return FALSE; + } LLInventoryModelBackgroundFetch::instance().start(); LLUUID cof_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); LLViewerInventoryCategory* cof = gInventory.getCategory(cof_id); @@ -2850,8 +2865,15 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name, bool do_append = false; LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); // Need to fetch cof contents before we can wear. - callAfterCategoryFetch(LLAppearanceMgr::instance().getCOF(), + if (do_copy) + { + callAfterCategoryFetch(LLAppearanceMgr::instance().getCOF(), boost::bind(&LLAppearanceMgr::wearInventoryCategory, LLAppearanceMgr::getInstance(), cat, do_copy, do_append)); + } + else + { + callAfterCategoryLinksFetch(cat_id, boost::bind(&LLAppearanceMgr::wearInventoryCategory, LLAppearanceMgr::getInstance(), cat, do_copy, do_append)); + } LL_DEBUGS() << "initial outfit category id: " << cat_id << LL_ENDL; } @@ -2904,6 +2926,7 @@ std::string LLStartUp::startupStateToString(EStartupState state) RTNENUM( STATE_AGENT_SEND ); RTNENUM( STATE_AGENT_WAIT ); RTNENUM( STATE_INVENTORY_SEND ); + RTNENUM(STATE_INVENTORY_CALLBACKS ); RTNENUM( STATE_MISC ); RTNENUM( STATE_PRECACHE ); RTNENUM( STATE_WEARABLES_WAIT ); diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index fe8e215f76..921f088423 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -71,6 +71,7 @@ typedef enum { STATE_AGENT_SEND, // Connect to a region STATE_AGENT_WAIT, // Wait for region STATE_INVENTORY_SEND, // Do inventory transfer + STATE_INVENTORY_CALLBACKS, // Wait for missing system folders and register callbacks STATE_MISC, // Do more things (set bandwidth, start audio, save location, etc) STATE_PRECACHE, // Wait a bit for textures to download STATE_WEARABLES_WAIT, // Wait for clothing to download From 4fb9a3f469c2cb0197d686acb68827f0fa32b451 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 20 Jul 2023 23:47:05 +0300 Subject: [PATCH 2/5] SL-20040 Fix selection and context menu issues --- indra/newview/llinventorygallery.cpp | 299 ++++++++++++++++--------- indra/newview/llinventorygallery.h | 15 +- indra/newview/llpanelmaininventory.cpp | 20 +- 3 files changed, 218 insertions(+), 116 deletions(-) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 75df5c1043..ca1b2eb09e 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -107,6 +107,7 @@ LLInventoryGallery::LLInventoryGallery(const LLInventoryGallery::Params& p) mIsInitialized(false), mRootDirty(false), mNeedsArrange(false), + mNeedsSelection(false), mSearchType(LLInventoryFilter::SEARCHTYPE_NAME), mSortOrder(LLInventoryFilter::SO_DATE) { @@ -221,6 +222,7 @@ void LLInventoryGallery::setRootFolder(const LLUUID cat_id) mItemToSelect.setNull(); mItemBuildQuery.clear(); mNeedsArrange = false; + mNeedsSelection = false; dirtyRootFolder(); } @@ -829,14 +831,15 @@ void LLInventoryGallery::onIdle(void* userdata) self->updateMessageVisibility(); } - if (self->mItemToSelect.notNull()) + if (self->mNeedsSelection) { LLUUID item_to_select = self->mItemToSelect; self->mItemToSelect = LLUUID::null; + self->mNeedsSelection = false; self->changeItemSelection(item_to_select, true); } - if (self->mItemToSelect.isNull() && self->mItemBuildQuery.empty()) + if (!self->mNeedsSelection && self->mItemBuildQuery.empty()) { gIdleCallbacks.deleteFunction(onIdle, (void*)self); } @@ -908,7 +911,6 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id) LLInventoryGalleryItem* item = buildGalleryItem(name, item_id, obj->getType(), thumbnail_id, inventory_type, misc_flags, obj->getCreationDate(), obj->getIsLinkType(), is_worn); mItemMap.insert(LLInventoryGallery::gallery_item_map_t::value_type(item_id, item)); - item->setRightMouseDownCallback(boost::bind(&LLInventoryGallery::showContextMenu, this, _1, _2, _3, item_id)); item->setFocusReceivedCallback(boost::bind(&LLInventoryGallery::changeItemSelection, this, item_id, false)); if (mGalleryCreated) { @@ -1000,15 +1002,21 @@ void LLInventoryGallery::updateItemThumbnail(LLUUID item_id) BOOL LLInventoryGallery::handleRightMouseDown(S32 x, S32 y, MASK mask) { - if(mItemMap[mSelectedItemID]) + if (mSelectedItemIDs.size() > 0) { - mItemMap[mSelectedItemID]->setFocus(false); - setFocus(true); + selection_deque::iterator iter = mSelectedItemIDs.begin(); + if (mItemMap[*iter]) + { + mItemMap[*iter]->setFocus(false); + setFocus(true); + } } clearSelection(); + + // Scroll is going to always return true BOOL res = LLPanel::handleRightMouseDown(x, y, mask); - if (mSelectedItemID.isNull()) + if (mSelectedItemIDs.empty()) { if (mInventoryGalleryMenu && mFolderID.notNull()) { @@ -1029,20 +1037,21 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask) { case KEY_RETURN: // Open selected items if enter key hit on the inventory panel - if (mask == MASK_NONE && mInventoryGalleryMenu && mSelectedItemID.notNull()) + if (mask == MASK_NONE && mInventoryGalleryMenu && mSelectedItemIDs.size() == 1) { - LLViewerInventoryCategory* category = gInventory.getCategory(mSelectedItemID); + selection_deque::iterator iter = mSelectedItemIDs.begin(); + LLViewerInventoryCategory* category = gInventory.getCategory(*iter); if (category) { - setRootFolder(mSelectedItemID); + setRootFolder(*iter); handled = TRUE; } else { - LLViewerInventoryItem* item = gInventory.getItem(mSelectedItemID); + LLViewerInventoryItem* item = gInventory.getItem(*iter); if (item) { - LLInvFVBridgeAction::doAction(item->getType(), mSelectedItemID, &gInventory); + LLInvFVBridgeAction::doAction(item->getType(), *iter, &gInventory); } } } @@ -1063,9 +1072,10 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask) case KEY_F2: mFilterSubString.clear(); - if (mInventoryGalleryMenu && mSelectedItemID.notNull()) + if (mInventoryGalleryMenu && mSelectedItemIDs.size() == 1) { - mInventoryGalleryMenu->doToSelected("rename", mSelectedItemID); + selection_deque::iterator iter = mSelectedItemIDs.begin(); + mInventoryGalleryMenu->doToSelected("rename", *iter); } handled = TRUE; break; @@ -1142,9 +1152,9 @@ void LLInventoryGallery::moveUp() { mFilterSubString.clear(); - if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = getSelectedItem(); + LLInventoryGalleryItem* item = getFirstSelectedItem(); if (item) { S32 n = mItemIndexMap[item]; @@ -1165,9 +1175,9 @@ void LLInventoryGallery::moveDown() { mFilterSubString.clear(); - if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = getSelectedItem(); + LLInventoryGalleryItem* item = getFirstSelectedItem(); if (item) { S32 n = mItemIndexMap[item]; @@ -1188,9 +1198,9 @@ void LLInventoryGallery::moveLeft() { mFilterSubString.clear(); - if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = getSelectedItem(); + LLInventoryGalleryItem* item = getFirstSelectedItem(); if (item) { // Might be better to get item from panel @@ -1213,9 +1223,9 @@ void LLInventoryGallery::moveRight() { mFilterSubString.clear(); - if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = getSelectedItem(); + LLInventoryGalleryItem* item = getFirstSelectedItem(); if (item) { S32 n = mItemIndexMap[item]; @@ -1243,9 +1253,12 @@ void LLInventoryGallery::onFocusLost() LLPanel::onFocusLost(); - if (mSelectedItemID.notNull() && mItemMap[mSelectedItemID]) + for (const LLUUID& id : mSelectedItemIDs) { - mItemMap[mSelectedItemID]->setSelected(false); + if (mItemMap[id]) + { + mItemMap[id]->setSelected(false); + } } } @@ -1255,13 +1268,19 @@ void LLInventoryGallery::onFocusReceived() gEditMenuHandler = this; // Tab support, when tabbing into this view, select first item - if (mSelectedItemID.notNull() && mItemMap[mSelectedItemID]) + if (mSelectedItemIDs.size() > 0) { - LLInventoryGalleryItem* focus_item = mItemMap[mSelectedItemID]; - focus_item->setSelected(true); - focus_item->setFocus(TRUE); + for (const LLUUID& id : mSelectedItemIDs) + { + if (mItemMap[id]) + { + LLInventoryGalleryItem* focus_item = mItemMap[id]; + focus_item->setSelected(true); + focus_item->setFocus(TRUE); + } + } } - else if (mIndexToItemMap.size() > 0 && mItemToSelect.isNull()) + else if (mIndexToItemMap.size() > 0 && !mNeedsSelection) { // choose any items from visible rect S32 vert_offset = mScrollPanel->getDocPosVertical(); @@ -1280,6 +1299,11 @@ void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLU { if (mInventoryGalleryMenu && item_id.notNull()) { + if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end()) + { + mSelectedItemIDs.clear(); + mSelectedItemIDs.push_back(item_id); + } uuid_vec_t selected_uuids; selected_uuids.push_back(item_id); mInventoryGalleryMenu->show(ctrl, selected_uuids, x, y); @@ -1291,32 +1315,32 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ if ((mItemMap.count(item_id) == 0) || mNeedsArrange) { mItemToSelect = item_id; + mNeedsSelection = true; return; } - if (mSelectedItemID == item_id) + if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end()) { return; } - if (mNeedsArrange && item_id.notNull()) - { - mItemToSelect = item_id; - return; - } - if (mItemMap[mSelectedItemID]) + for (const LLUUID& id : mSelectedItemIDs) { - mItemMap[mSelectedItemID]->setSelected(FALSE); + if (mItemMap[id]) + { + mItemMap[id]->setSelected(FALSE); + } } + if (mItemMap[item_id]) { mItemMap[item_id]->setSelected(TRUE); } - mSelectedItemID = item_id; + mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); if (scroll_to_selection) { - scrollToShowItem(mSelectedItemID); + scrollToShowItem(item_id); } } @@ -1347,31 +1371,45 @@ void LLInventoryGallery::scrollToShowItem(const LLUUID& item_id) } } -LLInventoryGalleryItem* LLInventoryGallery::getSelectedItem() +LLInventoryGalleryItem* LLInventoryGallery::getFirstSelectedItem() { - return mItemMap[mSelectedItemID]; + if (mSelectedItemIDs.size() > 0) + { + selection_deque::iterator iter = mSelectedItemIDs.begin(); + return mItemMap[*iter]; + } + return NULL; } void LLInventoryGallery::copy() { - LLClipboard::instance().reset(); - if (getVisible() && getEnabled() && mSelectedItemID.notNull()) + if (!getVisible() || !getEnabled()) { - LLClipboard::instance().addToClipboard(mSelectedItemID); + return; + } + + LLClipboard::instance().reset(); + + for (const LLUUID& id : mSelectedItemIDs) + { + LLClipboard::instance().addToClipboard(id); } mFilterSubString.clear(); } BOOL LLInventoryGallery::canCopy() const { - if (!getVisible() || !getEnabled() || mSelectedItemID.isNull()) + if (!getVisible() || !getEnabled() || mSelectedItemIDs.empty()) { return FALSE; } - if (!isItemCopyable(mSelectedItemID)) + for (const LLUUID& id : mSelectedItemIDs) { - return FALSE; + if (!isItemCopyable(id)) + { + return FALSE; + } } return TRUE; @@ -1379,36 +1417,45 @@ BOOL LLInventoryGallery::canCopy() const void LLInventoryGallery::cut() { + if (!getVisible() || !getEnabled()) + { + return; + } + // clear the inventory clipboard LLClipboard::instance().reset(); - if (getVisible() && getEnabled() && mSelectedItemID.notNull()) + LLClipboard::instance().setCutMode(true); + for (const LLUUID& id : mSelectedItemIDs) { // todo: fade out selected item - LLClipboard::instance().setCutMode(true); - LLClipboard::instance().addToClipboard(mSelectedItemID); + LLClipboard::instance().addToClipboard(id); } + mFilterSubString.clear(); } BOOL LLInventoryGallery::canCut() const { - if (!getVisible() || !getEnabled() || mSelectedItemID.isNull()) + if (!getVisible() || !getEnabled() || mSelectedItemIDs.empty()) { return FALSE; } - LLViewerInventoryCategory* cat = gInventory.getCategory(mSelectedItemID); - if (cat) + for (const LLUUID& id : mSelectedItemIDs) { - if (!get_is_category_removable(&gInventory, mSelectedItemID)) + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + if (cat) + { + if (!get_is_category_removable(&gInventory, id)) + { + return FALSE; + } + } + else if (!get_is_item_removable(&gInventory, id)) { return FALSE; } } - else if (!get_is_item_removable(&gInventory, mSelectedItemID)) - { - return FALSE; - } return TRUE; } @@ -1421,14 +1468,20 @@ void LLInventoryGallery::paste() } const LLUUID& marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); - if (!mSelectedItemID.isNull() && gInventory.isObjectDescendentOf(mSelectedItemID, marketplacelistings_id)) + if (mSelectedItemIDs.size() == 1 && gInventory.isObjectDescendentOf(*mSelectedItemIDs.begin(), marketplacelistings_id)) { return; } - LLInventoryObject* obj = gInventory.getObject(mSelectedItemID); + LLUUID first_selected_id; + if (mSelectedItemIDs.size() > 0) + { + first_selected_id = *mSelectedItemIDs.begin(); + } + + LLInventoryObject* obj = gInventory.getObject(first_selected_id); bool is_folder = obj && (obj->getType() == LLAssetType::AT_CATEGORY); - LLUUID dest = is_folder ? mSelectedItemID : mFolderID; + LLUUID dest = is_folder ? first_selected_id : mFolderID; bool is_cut_mode = LLClipboard::instance().isCutMode(); std::vector objects; @@ -1463,6 +1516,7 @@ void LLInventoryGallery::paste() gInventory.changeCategoryParent(cat, dest, false); // Don't select immediately, wait for item to arrive mItemToSelect = item_id; + mNeedsSelection = true; } else { @@ -1479,6 +1533,7 @@ void LLInventoryGallery::paste() gInventory.changeItemParent(item, dest, false); // Don't select immediately, wait for item to arrive mItemToSelect = item_id; + mNeedsSelection = true; } else { @@ -1535,28 +1590,31 @@ BOOL LLInventoryGallery::canPaste() const return TRUE; } -void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id) +void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response, const selection_deque selected_ids) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { - LLInventoryObject* obj = gInventory.getObject(selected_id); - if (!obj) + for (const LLUUID& id : selected_ids) { - return; - } - if (obj->getType() == LLAssetType::AT_CATEGORY) - { - if (get_is_category_removable(&gInventory, selected_id)) + LLInventoryObject* obj = gInventory.getObject(id); + if (!obj) { - gInventory.removeCategory(selected_id); + return; } - } - else - { - if (get_is_item_removable(&gInventory, selected_id)) + if (obj->getType() == LLAssetType::AT_CATEGORY) { - gInventory.removeItem(selected_id); + if (get_is_category_removable(&gInventory, id)) + { + gInventory.removeCategory(id); + } + } + else + { + if (get_is_item_removable(&gInventory, id)) + { + gInventory.removeItem(id); + } } } } @@ -1572,31 +1630,39 @@ void LLInventoryGallery::deleteSelection() LLSD args; args["QUESTION"] = LLTrans::getString("DeleteItem"); - LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemID)); + LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemIDs)); } bool LLInventoryGallery::canDeleteSelection() { - if (mSelectedItemID.isNull()) - { - return false; - } - - LLViewerInventoryCategory* cat = gInventory.getCategory(mSelectedItemID); - if (cat) - { - if (!get_is_category_removable(&gInventory, mSelectedItemID)) - { - return false; - } - } - else if (!get_is_item_removable(&gInventory, mSelectedItemID)) + if (mSelectedItemIDs.empty()) { return false; } const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - return !gInventory.isObjectDescendentOf(mSelectedItemID, trash_id); + if (mFolderID == trash_id || gInventory.isObjectDescendentOf(mFolderID, trash_id)) + { + return false; + } + + for (const LLUUID& id : mSelectedItemIDs) + { + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + if (cat) + { + if (!get_is_category_removable(&gInventory, id)) + { + return false; + } + } + else if (!get_is_item_removable(&gInventory, id)) + { + return false; + } + } + + return true; } void LLInventoryGallery::pasteAsLink() @@ -1611,12 +1677,12 @@ void LLInventoryGallery::pasteAsLink() const LLUUID& my_outifts_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); LLUUID dest; - LLInventoryObject* obj = gInventory.getObject(mSelectedItemID); - if (obj && obj->getType() == LLAssetType::AT_CATEGORY) + if (mSelectedItemIDs.size() > 0) { - dest = mSelectedItemID; + dest = *mSelectedItemIDs.begin(); } - else + LLInventoryObject* obj = gInventory.getObject(dest); + if (!obj || obj->getType() != LLAssetType::AT_CATEGORY) { dest = mFolderID; } @@ -1894,18 +1960,35 @@ void LLInventoryGallery::onGesturesChanged() void LLInventoryGallery::deselectItem(const LLUUID& category_id) { // Reset selection if the item is selected. - if (category_id == mSelectedItemID) + LLInventoryGalleryItem* item = mItemMap[category_id]; + if (item && item->isSelected()) { - mSelectedItemID = LLUUID::null; - signalSelectionItemID(mSelectedItemID); + mItemMap[category_id]->setSelected(FALSE); + setFocus(true); + // Todo: support multiselect + signalSelectionItemID(LLUUID::null); + } + + selection_deque::iterator found = std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), category_id); + if (found != mSelectedItemIDs.end()) + { + mSelectedItemIDs.erase(found); } } void LLInventoryGallery::clearSelection() { - if(mSelectedItemID != LLUUID::null) + for (const LLUUID& id: mSelectedItemIDs) { - changeItemSelection(LLUUID::null); + if (mItemMap[id]) + { + mItemMap[id]->setSelected(FALSE); + } + } + if (!mSelectedItemIDs.empty()) + { + mSelectedItemIDs.clear(); + signalSelectionItemID(LLUUID::null); } } @@ -1919,6 +2002,15 @@ boost::signals2::connection LLInventoryGallery::setSelectionChangeCallback(selec return mSelectionChangeSignal.connect(cb); } +LLUUID LLInventoryGallery::getFirstSelectedItemID() +{ + if (mSelectedItemIDs.size() > 0) + { + return *mSelectedItemIDs.begin(); + } + return LLUUID::null; +} + LLUUID LLInventoryGallery::getOutfitImageID(LLUUID outfit_id) { LLUUID thumbnail_id; @@ -2284,6 +2376,10 @@ BOOL LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) setFocus(TRUE); mGallery->claimEditHandler(); + //S32 gal_x, gal_y; + //localPointToOtherView(x, y, &gal_x, &gal_y, mGallery); + mGallery->showContextMenu(this, x, y, mUUID); + LLUICtrl::handleRightMouseDown(x, y, mask); return TRUE; } @@ -2532,6 +2628,7 @@ BOOL LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, { // Don't select immediately, wait for item to arrive mItemToSelect = inv_item->getUUID(); + mNeedsSelection = true; } break; case DAD_LINK: @@ -2553,6 +2650,7 @@ BOOL LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, if (accepted && drop && inv_item) { mItemToSelect = inv_item->getUUID(); + mNeedsSelection = true; } break; case DAD_CATEGORY: @@ -2567,6 +2665,7 @@ BOOL LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, if (accepted && drop) { mItemToSelect = cat_ptr->getUUID(); + mNeedsSelection = true; } } break; diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index 5f9c191fc5..42bda59c5a 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -51,6 +51,7 @@ public: typedef boost::signals2::signal selection_change_signal_t; typedef boost::function selection_change_callback_t; + typedef std::deque selection_deque; struct Params : public LLInitParam::Block @@ -132,7 +133,7 @@ public: void scrollToShowItem(const LLUUID& item_id); void signalSelectionItemID(const LLUUID& category_id); boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb); - LLUUID getSelectedItemID() { return mSelectedItemID; } + LLUUID getFirstSelectedItemID(); void setSearchType(LLInventoryFilter::ESearchType type); LLInventoryFilter::ESearchType getSearchType() { return mSearchType; } @@ -142,7 +143,7 @@ public: bool hasVisibleItems(); void handleModifiedFilter(); LLScrollContainer* getScrollableContainer() { return mScrollPanel; } - LLInventoryGalleryItem* getSelectedItem(); + LLInventoryGalleryItem* getFirstSelectedItem(); // Copy & paste (LLEditMenuHandler) void copy() override; @@ -155,7 +156,7 @@ public: BOOL canPaste() const override; // Copy & paste & delete - static void onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id); + static void onDelete(const LLSD& notification, const LLSD& response, const selection_deque selected_ids); void deleteSelection(); bool canDeleteSelection(); void pasteAsLink(); @@ -170,10 +171,10 @@ public: BOOL baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); -protected: - void showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id); +protected: + bool applyFilter(LLInventoryGalleryItem* item, const std::string& filter_substring); bool checkAgainstFilters(LLInventoryGalleryItem* item, const std::string& filter_substring); static void onIdle(void* userdata); @@ -183,8 +184,9 @@ protected: LLThumbnailsObserver* mThumbnailsObserver; LLGalleryGestureObserver* mGestureObserver; LLInventoryObserver* mInventoryObserver; - LLUUID mSelectedItemID; + selection_deque mSelectedItemIDs; LLUUID mItemToSelect; + bool mNeedsSelection; bool mIsInitialized; bool mRootDirty; @@ -300,6 +302,7 @@ public: LLFontGL* getTextFont(); void setItemName(std::string name); + bool isSelected() { return mSelected; } void setSelected(bool value); void setWorn(bool value); void setUUID(LLUUID id) {mUUID = id;} diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index b63d6b9308..30f301027c 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1750,7 +1750,7 @@ void LLPanelMainInventory::saveTexture(const LLSD& userdata) LLUUID item_id; if(mSingleFolderMode && isGalleryViewMode()) { - item_id = mCombinationGalleryPanel->getSelectedItemID(); + item_id = mCombinationGalleryPanel->getFirstSelectedItemID(); if (item_id.isNull()) return; } else @@ -1848,7 +1848,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) { if(mSingleFolderMode && isGalleryViewMode()) { - LLInventoryObject *obj = gInventory.getObject(mCombinationGalleryPanel->getSelectedItemID()); + LLInventoryObject *obj = gInventory.getObject(mCombinationGalleryPanel->getFirstSelectedItemID()); if (obj && obj->getIsLinkType()) { show_item_original(obj->getUUID()); @@ -1878,7 +1878,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) LLPanelMainInventory* main_inventory = sidepanel_inventory->getMainInventoryPanel(); if (main_inventory) { - LLInventoryObject *obj = gInventory.getObject(mCombinationGalleryPanel->getSelectedItemID()); + LLInventoryObject *obj = gInventory.getObject(mCombinationGalleryPanel->getFirstSelectedItemID()); if (obj) { main_inventory->findLinks(obj->getUUID(), obj->getName()); @@ -1905,7 +1905,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) LLSD params; if(mSingleFolderMode && isGalleryViewMode()) { - params = LLSD(mCombinationGalleryPanel->getSelectedItemID()); + params = LLSD(mCombinationGalleryPanel->getFirstSelectedItemID()); } else { @@ -1965,7 +1965,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) { if(mSingleFolderMode && isGalleryViewMode()) { - std::set uuids{ mCombinationGalleryPanel->getSelectedItemID()}; + std::set uuids{ mCombinationGalleryPanel->getFirstSelectedItemID()}; LLAvatarActions::shareWithAvatars(uuids, gFloaterView->getParentFloater(this)); } else @@ -2009,7 +2009,7 @@ bool LLPanelMainInventory::isSaveTextureEnabled(const LLSD& userdata) LLViewerInventoryItem *inv_item = NULL; if(mSingleFolderMode && isGalleryViewMode()) { - inv_item = gInventory.getItem(mCombinationGalleryPanel->getSelectedItemID()); + inv_item = gInventory.getItem(mCombinationGalleryPanel->getFirstSelectedItemID()); } else { @@ -2059,7 +2059,7 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) LLUUID item_id; if(mSingleFolderMode && isGalleryViewMode()) { - item_id = mCombinationGalleryPanel->getSelectedItemID(); + item_id = mCombinationGalleryPanel->getFirstSelectedItemID(); } else{ LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); @@ -2079,7 +2079,7 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) LLUUID item_id; if(mSingleFolderMode && isGalleryViewMode()) { - item_id = mCombinationGalleryPanel->getSelectedItemID(); + item_id = mCombinationGalleryPanel->getFirstSelectedItemID(); } else{ LLFolderView* root = getActivePanel()->getRootFolder(); @@ -2114,7 +2114,7 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) { if(mSingleFolderMode && isGalleryViewMode()) { - return can_share_item(mCombinationGalleryPanel->getSelectedItemID()); + return can_share_item(mCombinationGalleryPanel->getFirstSelectedItemID()); } else{ LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); @@ -2626,7 +2626,7 @@ void LLPanelMainInventory::setGallerySelection(const LLUUID& item_id, bool new_w void LLPanelMainInventory::scrollToGallerySelection() { - mCombinationGalleryPanel->scrollToShowItem(mCombinationGalleryPanel->getSelectedItemID()); + mCombinationGalleryPanel->scrollToShowItem(mCombinationGalleryPanel->getFirstSelectedItemID()); } void LLPanelMainInventory::scrollToInvPanelSelection() From 0941fcd5a48e9d4d95fb88750db3b964aa983486 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 21 Jul 2023 00:47:14 +0300 Subject: [PATCH 3/5] SL-20047 Indicate when gallery items are being cut --- indra/newview/llinventorygallery.cpp | 40 +++++++++++++++++++++++----- indra/newview/llinventorygallery.h | 4 +++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index ca1b2eb09e..99bd772773 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2230,7 +2230,9 @@ LLInventoryGalleryItem::LLInventoryGalleryItem(const Params& p) mHidden(false), mGallery(NULL), mType(LLAssetType::AT_NONE), - mSortGroup(SG_ITEM) + mSortGroup(SG_ITEM), + mCutGeneration(0), + mSelectedForCut(false) { buildFromFile("panel_inventory_gallery_item.xml"); } @@ -2328,13 +2330,24 @@ void LLInventoryGalleryItem::setThumbnail(LLUUID id) void LLInventoryGalleryItem::draw() { - LLPanel::draw(); + if (isFadeItem()) + { + // Fade out to indicate it's being cut + LLViewDrawContext context(0.5f); + LLPanel::draw(); + } + else + { + LLPanel::draw(); + + // Draw border + LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "MenuItemHighlightBgColor" : "TextFgTentativeColor", LLColor4::white); + LLRect border = getChildView("preview_thumbnail")->getRect(); + border.mRight = border.mRight + 1; + gl_rect_2d(border, border_color.get(), FALSE); + } + - // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "MenuItemHighlightBgColor" : "TextFgTentativeColor", LLColor4::white); - LLRect border = getChildView("preview_thumbnail")->getRect(); - border.mRight = border.mRight + 1; - gl_rect_2d(border, border_color.get(), FALSE); } void LLInventoryGalleryItem::setItemName(std::string name) @@ -2543,6 +2556,19 @@ void LLInventoryGalleryItem::updateNameText() getChild("preview_thumbnail")->setToolTip(mItemName + mPermSuffix + mWornSuffix); } +bool LLInventoryGalleryItem::isFadeItem() +{ + LLClipboard& clipboard = LLClipboard::instance(); + if (mCutGeneration == clipboard.getGeneration()) + { + return mSelectedForCut; + } + + mCutGeneration = clipboard.getGeneration(); + mSelectedForCut = clipboard.isCutMode() && clipboard.isOnClipboard(mUUID); + return mSelectedForCut; +} + //----------------------------- // LLThumbnailsObserver //----------------------------- diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index 42bda59c5a..f2e5e38940 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -335,6 +335,8 @@ public: void updateNameText(); private: + bool isFadeItem(); + LLUUID mUUID; LLTextBox* mNameText; LLPanel* mTextBgPanel; @@ -344,6 +346,8 @@ private: bool mHidden; bool mIsFolder; bool mIsLink; + S32 mCutGeneration; + bool mSelectedForCut; std::string mAssetIDStr; std::string mDesc; From d237b9ee1b0bbcdb3431f8afc873af4ee9e21a4e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 21 Jul 2023 17:19:04 +0300 Subject: [PATCH 4/5] SL-20040 Fix selection callback --- indra/newview/llinventorygallery.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 99bd772773..87dba5f100 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1302,7 +1302,7 @@ void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLU if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end()) { mSelectedItemIDs.clear(); - mSelectedItemIDs.push_back(item_id); + changeItemSelection(item_id, false); } uuid_vec_t selected_uuids; selected_uuids.push_back(item_id); @@ -1318,8 +1318,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ mNeedsSelection = true; return; } - if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end()) + if (mSelectedItemIDs.size() == 1 + && std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) != mSelectedItemIDs.end()) { + // Already selected return; } @@ -1330,6 +1332,7 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ mItemMap[id]->setSelected(FALSE); } } + mSelectedItemIDs.clear(); if (mItemMap[item_id]) { @@ -2388,9 +2391,6 @@ BOOL LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); mGallery->claimEditHandler(); - - //S32 gal_x, gal_y; - //localPointToOtherView(x, y, &gal_x, &gal_y, mGallery); mGallery->showContextMenu(this, x, y, mUUID); LLUICtrl::handleRightMouseDown(x, y, mask); From 7b9206dfd15ee90fde421525254b0a29d94f1ef2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 22 Jul 2023 00:22:35 +0300 Subject: [PATCH 5/5] SL-20045 Texture picker should apply the exact texture inventory item --- .../newview/llfloaterchangeitemthumbnail.cpp | 6 +- indra/newview/llfloaterchangeitemthumbnail.h | 2 +- indra/newview/llpanelprofile.cpp | 36 +---- indra/newview/lltexturectrl.cpp | 145 ++++++++++++------ indra/newview/lltexturectrl.h | 13 +- 5 files changed, 118 insertions(+), 84 deletions(-) diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp index 1ad235ac0a..d7fbf1384b 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.cpp +++ b/indra/newview/llfloaterchangeitemthumbnail.cpp @@ -698,11 +698,11 @@ void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id) { //texture_floaterp->setTextureSelectedCallback(); //texture_floaterp->setOnUpdateImageStatsCallback(); - texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLUUID id) + texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLPickerSource, const LLUUID&, const LLUUID&) { if (op == LLTextureCtrl::TEXTURE_SELECT) { - onTexturePickerCommit(id); + onTexturePickerCommit(); } } ); @@ -722,7 +722,7 @@ void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id) floaterp->setFocus(TRUE); } -void LLFloaterChangeItemThumbnail::onTexturePickerCommit(LLUUID id) +void LLFloaterChangeItemThumbnail::onTexturePickerCommit() { LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mPickerHandle.get(); diff --git a/indra/newview/llfloaterchangeitemthumbnail.h b/indra/newview/llfloaterchangeitemthumbnail.h index de2a20bf2a..02f934337b 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.h +++ b/indra/newview/llfloaterchangeitemthumbnail.h @@ -92,7 +92,7 @@ private: void* userdata); void showTexturePicker(const LLUUID &thumbnail_id); - void onTexturePickerCommit(LLUUID id); + void onTexturePickerCommit(); void setThumbnailId(const LLUUID &new_thumbnail_id); static void setThumbnailId(const LLUUID& new_thumbnail_id, const LLUUID& object_id); diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index c67be5bb28..b6c2d1f0fd 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -1956,25 +1956,11 @@ void LLPanelProfileSecondLife::onShowTexturePicker() mFloaterTexturePickerHandle = texture_floaterp->getHandle(); - texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLUUID id) + texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLPickerSource source, const LLUUID& asset_id, const LLUUID&) { if (op == LLTextureCtrl::TEXTURE_SELECT) { - LLUUID image_asset_id; - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterTexturePickerHandle.get(); - if (floaterp) - { - if (id.notNull()) - { - image_asset_id = id; - } - else - { - image_asset_id = floaterp->getAssetID(); - } - } - - onCommitProfileImage(image_asset_id); + onCommitProfileImage(asset_id); } }); texture_floaterp->setLocalTextureEnabled(FALSE); @@ -2297,25 +2283,11 @@ void LLPanelProfileFirstLife::onChangePhoto() mFloaterTexturePickerHandle = texture_floaterp->getHandle(); - texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLUUID id) + texture_floaterp->setOnFloaterCommitCallback([this](LLTextureCtrl::ETexturePickOp op, LLPickerSource source, const LLUUID& asset_id, const LLUUID&) { if (op == LLTextureCtrl::TEXTURE_SELECT) { - LLUUID image_asset_id; - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterTexturePickerHandle.get(); - if (floaterp) - { - if (id.notNull()) - { - image_asset_id = id; - } - else - { - image_asset_id = floaterp->getAssetID(); - } - } - - onCommitPhoto(image_asset_id); + onCommitPhoto(asset_id); } }); texture_floaterp->setLocalTextureEnabled(FALSE); diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 21bb855704..36fa4e9a37 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -713,17 +713,76 @@ PermissionMask LLFloaterTexturePicker::getFilterPermMask() void LLFloaterTexturePicker::commitIfImmediateSet() { - if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply) + if (!mNoCopyTextureSelected && mCanApply) { - mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, LLUUID::null); + commitCallback(); } } +void LLFloaterTexturePicker::commitCallback() +{ + if (!mOnFloaterCommitCallback) + { + return; + } + LLUUID asset_id = mImageAssetID; + LLUUID inventory_id; + LLPickerSource mode = (LLPickerSource)mModeSelector->getValue().asInteger(); + + switch (mode) + { + case PICKER_INVENTORY: + { + LLFolderView* root_folder = mInventoryPanel->getRootFolder(); + if (root_folder && root_folder->getCurSelectedItem()) + { + LLFolderViewItem* last_selected = root_folder->getCurSelectedItem(); + LLFolderViewModelItemInventory* inv_view = static_cast(last_selected->getViewModelItem()); + + LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID()); + if (itemp && itemp->getAssetUUID() == mImageAssetID) + { + inventory_id = inv_view->getUUID(); + } + else + { + mode = PICKER_UNKNOWN; // source of id unknown + } + } + else + { + mode = PICKER_UNKNOWN; // source of id unknown + } + break; + } + case PICKER_LOCAL: + { + if (!mLocalScrollCtrl->getAllSelected().empty()) + { + LLUUID temp_id = mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID(); + asset_id = LLLocalBitmapMgr::getInstance()->getWorldID(temp_id); + } + else + { + asset_id = mImageAssetID; + mode = PICKER_UNKNOWN; // source of id unknown + } + break; + } + case PICKER_BAKE: + break; + default: + mode = PICKER_UNKNOWN; // source of id unknown + break; + } + + mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, mode, asset_id, inventory_id); +} void LLFloaterTexturePicker::commitCancel() { if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply) { - mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); + mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, PICKER_UNKNOWN, mOriginalImageAssetID, LLUUID::null); } } @@ -776,7 +835,7 @@ void LLFloaterTexturePicker::onBtnCancel(void* userdata) self->setImageID( self->mOriginalImageAssetID ); if (self->mOnFloaterCommitCallback) { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); + self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, PICKER_UNKNOWN, self->mOriginalImageAssetID, LLUUID::null); } self->mViewModel->resetDirty(); self->closeFloater(); @@ -786,20 +845,7 @@ void LLFloaterTexturePicker::onBtnCancel(void* userdata) void LLFloaterTexturePicker::onBtnSelect(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - LLUUID local_id = LLUUID::null; - if (self->mOwner) - { - if (self->mLocalScrollCtrl->getVisible() && !self->mLocalScrollCtrl->getAllSelected().empty()) - { - LLUUID temp_id = self->mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID(); - local_id = LLLocalBitmapMgr::getInstance()->getWorldID(temp_id); - } - } - - if (self->mOnFloaterCommitCallback) - { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_SELECT, local_id); - } + self->commitCallback(); self->closeFloater(); } @@ -861,25 +907,25 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata) LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; int index = self->mModeSelector->getValue().asInteger(); - self->mDefaultBtn->setVisible(index == 0 ? TRUE : FALSE); - self->mBlankBtn->setVisible(index == 0 ? TRUE : FALSE); - self->mNoneBtn->setVisible(index == 0 ? TRUE : FALSE); - self->mPipetteBtn->setVisible(index == 0 ? TRUE : FALSE); - self->getChild("inventory search editor")->setVisible(index == 0 ? TRUE : FALSE); - self->getChild("inventory panel")->setVisible(index == 0 ? TRUE : FALSE); + self->mDefaultBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + self->mBlankBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + self->mNoneBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + self->mPipetteBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + self->getChild("inventory search editor")->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + self->getChild("inventory panel")->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); /*self->getChild("show_folders_check")->setVisible(mode); no idea under which conditions the above is even shown, needs testing. */ - self->getChild("l_add_btn")->setVisible(index == 1 ? TRUE : FALSE); - self->getChild("l_rem_btn")->setVisible(index == 1 ? TRUE : FALSE); - self->getChild("l_upl_btn")->setVisible(index == 1 ? TRUE : FALSE); - self->getChild("l_name_list")->setVisible(index == 1 ? TRUE : FALSE); + self->getChild("l_add_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); + self->getChild("l_rem_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); + self->getChild("l_upl_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); + self->getChild("l_name_list")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); - self->getChild("l_bake_use_texture_combo_box")->setVisible(index == 2 ? TRUE : FALSE); + self->getChild("l_bake_use_texture_combo_box")->setVisible(index == PICKER_BAKE ? TRUE : FALSE); self->getChild("hide_base_mesh_region")->setVisible(FALSE);// index == 2 ? TRUE : FALSE); - if (index == 2) + if (index == PICKER_BAKE) { self->stopUsingPipette(); @@ -1020,7 +1066,7 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) { if (self->mOnFloaterCommitCallback) { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, inworld_id); + self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, PICKER_LOCAL, inworld_id, LLUUID::null); } } } @@ -1457,7 +1503,7 @@ void LLTextureCtrl::showPicker(BOOL take_focus) } if (texture_floaterp) { - texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); + texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2, _3, _4)); } if (texture_floaterp) { @@ -1574,7 +1620,7 @@ void LLTextureCtrl::onFloaterClose() mFloaterHandle.markDead(); } -void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id) +void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLPickerSource source, const LLUUID& asset_id, const LLUUID& inv_id) { LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); @@ -1588,22 +1634,29 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id) else if (mCommitOnSelection || op == TEXTURE_SELECT) mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? - if(floaterp->isDirty() || id.notNull()) // mModelView->setDirty does not work. + if(floaterp->isDirty() || asset_id.notNull()) // mModelView->setDirty does not work. { setTentative( FALSE ); - if (id.notNull()) - { - mImageItemID = id; - mImageAssetID = id; - } - else - { - mImageItemID = floaterp->findItemID(floaterp->getAssetID(), FALSE); - LL_DEBUGS() << "mImageItemID: " << mImageItemID << LL_ENDL; - mImageAssetID = floaterp->getAssetID(); - LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << LL_ENDL; - } + switch(source) + { + case PICKER_INVENTORY: + mImageItemID = inv_id; + mImageAssetID = asset_id; + break; + case PICKER_BAKE: + case PICKER_LOCAL: + mImageItemID = LLUUID::null; + mImageAssetID = asset_id; + break; + case PICKER_UNKNOWN: + default: + mImageItemID = floaterp->findItemID(asset_id, FALSE); + mImageAssetID = asset_id; + break; + } + + LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << ", mImageItemID: " << mImageItemID << LL_ENDL; if (op == TEXTURE_SELECT && mOnSelectCallback) { diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 8ef6d9bee7..3cf8861075 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -63,6 +63,14 @@ bool get_is_predefined_texture(LLUUID asset_id); LLUUID get_copy_free_item_by_asset_id(LLUUID image_id, bool no_trans_perm = false); bool get_can_copy_texture(LLUUID image_id); +enum LLPickerSource +{ + PICKER_INVENTORY, + PICKER_LOCAL, + PICKER_BAKE, + PICKER_UNKNOWN, // on cancel, default ids +}; + ////////////////////////////////////////////////////////////////////////////////////////// // LLTextureCtrl @@ -188,7 +196,7 @@ public: void closeDependentFloater(); void onFloaterClose(); - void onFloaterCommit(ETexturePickOp op, LLUUID id); + void onFloaterCommit(ETexturePickOp op, LLPickerSource source, const LLUUID& local_id, const LLUUID& inv_id); // This call is returned when a drag is detected. Your callback // should return TRUE if the drag is acceptable. @@ -256,7 +264,7 @@ private: ////////////////////////////////////////////////////////////////////////////////////////// // LLFloaterTexturePicker -typedef boost::function floater_commit_callback; +typedef boost::function floater_commit_callback; typedef boost::function floater_close_callback; typedef boost::function set_image_asset_id_callback; typedef boost::function texture)> set_on_update_image_stats_callback; @@ -309,6 +317,7 @@ public: void updateFilterPermMask(); void commitIfImmediateSet(); + void commitCallback(); void commitCancel(); void onFilterEdit(const std::string& search_string);