diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-04-18 21:27:25 +0300 |
---|---|---|
committer | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-04-18 21:27:25 +0300 |
commit | ce2aaab15912693d51383274dc1dfebb20c0b6a2 (patch) | |
tree | 9568d0a74c69aa7bf9448fb6e6897ffc5181b6f0 /indra | |
parent | 5554686b9117901cddb3d36f237622442c1d7a8d (diff) |
SL-19604 FIXED Creating new folders and items in gallery or combination views does not highlight created item
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 64 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.h | 4 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 2 |
6 files changed, 73 insertions, 18 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index f6a1f49306..b4a23f7c55 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -728,7 +728,7 @@ void LLInventoryGallery::updateAddedItem(LLUUID item_id) LLInventoryGalleryItem* item = buildGalleryItem(name, item_id, obj->getType(), thumbnail_id, inventory_type, misc_flags, 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)); + item->setFocusReceivedCallback(boost::bind(&LLInventoryGallery::changeItemSelection, this, item_id, false)); if (mGalleryCreated) { applyFilter(item, mFilterSubString); @@ -816,21 +816,60 @@ void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLU } } -void LLInventoryGallery::changeItemSelection(const LLUUID& item_id) +void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_to_selection) { - if ((mItemMap.count(item_id) == 0) || (mSelectedItemID == item_id)) + if ((mItemMap.count(item_id) == 0)) + { + mItemToSelect = item_id; return; - - if (mItemMap[mSelectedItemID]) + } + if (mSelectedItemID != item_id) { - mItemMap[mSelectedItemID]->setSelected(FALSE); + + if (mItemMap[mSelectedItemID]) + { + mItemMap[mSelectedItemID]->setSelected(FALSE); + } + if (mItemMap[item_id]) + { + mItemMap[item_id]->setSelected(TRUE); + } + mSelectedItemID = item_id; + signalSelectionItemID(item_id); + + mItemToSelect = LLUUID::null; + if(scroll_to_selection) + { + scrollToShowItem(mSelectedItemID); + } } - if (mItemMap[item_id]) +} + +void LLInventoryGallery::scrollToShowItem(const LLUUID& item_id) +{ + LLInventoryGalleryItem* item = mItemMap[item_id]; + if(item) { - mItemMap[item_id]->setSelected(TRUE); + const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); + + LLRect item_rect; + item->localRectToOtherView(item->getLocalRect(), &item_rect, this); + LLRect overlap_rect(item_rect); + overlap_rect.intersectWith(visible_content_rect); + + //Scroll when the selected item is outside the visible area + if (overlap_rect.getHeight() + 5 < item->getRect().getHeight()) + { + LLRect content_rect = mScrollPanel->getContentWindowRect(); + LLRect constraint_rect; + constraint_rect.setOriginAndSize(0, 0, content_rect.getWidth(), content_rect.getHeight()); + + LLRect item_doc_rect; + item->localRectToOtherView(item->getLocalRect(), &item_doc_rect, this); + + mScrollPanel->scrollToShowRect( item_doc_rect, constraint_rect ); + } } - mSelectedItemID = item_id; - signalSelectionItemID(item_id); } void LLInventoryGallery::updateMessageVisibility() @@ -886,6 +925,11 @@ void LLInventoryGallery::refreshList(const LLUUID& category_id) updateChangedItemName(*items_iter, obj->getName()); } + + if(mItemToSelect.notNull()) + { + changeItemSelection(mItemToSelect, true); + } updateMessageVisibility(); } diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index fdab616720..07613b20aa 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -116,7 +116,8 @@ public: void computeDifference(const LLInventoryModel::cat_array_t vcats, const LLInventoryModel::item_array_t vitems, uuid_vec_t& vadded, uuid_vec_t& vremoved); void deselectItem(const LLUUID& category_id); - void changeItemSelection(const LLUUID& item_id); + void changeItemSelection(const LLUUID& item_id, bool scroll_to_selection = false); + 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; } @@ -138,6 +139,7 @@ protected: LLThumbnailsObserver* mThumbnailsObserver; LLGalleryGestureObserver* mGestureObserver; LLUUID mSelectedItemID; + LLUUID mItemToSelect; bool mIsInitialized; selection_change_signal_t mSelectionChangeSignal; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 2193743a38..4b525b09d1 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1801,7 +1801,7 @@ void LLInventoryPanel::openInventoryPanelAndSetSelection(BOOL auto_open, const L { LLSidepanelInventory *inventory_panel = inventory_floater->findChild<LLSidepanelInventory>("main_panel"); LLPanelMainInventory* main_panel = inventory_panel->getMainInventoryPanel(); - if(main_panel->isSingleFolderMode() && (main_panel->isGalleryViewMode() || main_panel->isCombinationViewMode())) + if(main_panel->isSingleFolderMode() && main_panel->isGalleryViewMode()) { main_panel->setGallerySelection(obj_id); return; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index f67b09d121..9d1e861344 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -497,7 +497,7 @@ void LLPanelMainInventory::doCreate(const LLSD& userdata) reset_inventory_filter(); if(mSingleFolderMode) { - if(isListViewMode()) + if(isListViewMode() || isCombinationViewMode()) { LLFolderViewItem* current_folder = getActivePanel()->getRootFolder(); if (current_folder) @@ -508,7 +508,12 @@ void LLPanelMainInventory::doCreate(const LLSD& userdata) } else { - menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata); + std::function<void(const LLUUID&)> callback_cat_created = [this](const LLUUID &new_category_id) + { + gInventory.notifyObservers(); + setGallerySelection(new_category_id); + }; + menu_create_inventory_item(NULL, getCurrentSFVRoot(), userdata, LLUUID::null, callback_cat_created); } } else @@ -2350,13 +2355,13 @@ void LLPanelMainInventory::setGallerySelection(const LLUUID& item_id) { if(mSingleFolderMode && isGalleryViewMode()) { - mInventoryGalleryPanel->changeItemSelection(item_id); + mInventoryGalleryPanel->changeItemSelection(item_id, true); } else if(mSingleFolderMode && isCombinationViewMode()) { if(mCombinationGalleryPanel->getFilter().checkAgainstFilterThumbnails(item_id)) { - mCombinationGalleryPanel->changeItemSelection(item_id); + mCombinationGalleryPanel->changeItemSelection(item_id, true); } else { diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 01ad4f0f09..8b0d14b3e9 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1727,7 +1727,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, menu_create_inventory_item(panel, bridge ? bridge->getUUID() : LLUUID::null, userdata, default_parent_uuid); } -void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid) +void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid, std::function<void(const LLUUID&)> folder_created_cb) { std::string type_name = userdata.asString(); @@ -1763,6 +1763,10 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L } }; } + else if(folder_created_cb != NULL) + { + callback_cat_created = folder_created_cb; + } gInventory.createNewCategory( parent_id, preferred_type, diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 95a4c84999..d788f23d0c 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -456,7 +456,7 @@ void menu_create_inventory_item(LLInventoryPanel* root, const LLSD& userdata, const LLUUID& default_parent_uuid = LLUUID::null); -void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid = LLUUID::null); +void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const LLSD& userdata, const LLUUID& default_parent_uuid = LLUUID::null, std::function<void(const LLUUID&)> folder_created_cb = NULL); void slam_inventory_folder(const LLUUID& folder_id, const LLSD& contents, |