diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-07-01 00:20:01 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-07-01 00:20:01 +0300 |
commit | bbcedf9c847f1f768e6c34e74a6a4373b0e7ae24 (patch) | |
tree | ad4389f34ef391be5eb6ef3fe75cea15160bb34a /indra | |
parent | 924869900ae2646987ce2a8f0b494345701c50a6 (diff) |
SL-19914 Inventory gallery Tab support #2
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llscrollbar.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llscrollbar.h | 4 | ||||
-rw-r--r-- | indra/llui/llscrollcontainer.h | 6 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 39 | ||||
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 9 |
6 files changed, 64 insertions, 18 deletions
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 62be0c28e8..735e2d529e 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -188,12 +188,12 @@ void LLScrollbar::setPageSize( S32 page_size ) } } -BOOL LLScrollbar::isAtBeginning() +bool LLScrollbar::isAtBeginning() const { return mDocPos == 0; } -BOOL LLScrollbar::isAtEnd() +bool LLScrollbar::isAtEnd() const { return mDocPos == getDocPosMax(); } diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h index 5f2f490d81..9be9d22db8 100644 --- a/indra/llui/llscrollbar.h +++ b/indra/llui/llscrollbar.h @@ -105,8 +105,8 @@ public: bool setDocPos( S32 pos, BOOL update_thumb = TRUE ); S32 getDocPos() const { return mDocPos; } - BOOL isAtBeginning(); - BOOL isAtEnd(); + bool isAtBeginning() const; + bool isAtEnd() const; // Setting both at once. void setDocParams( S32 size, S32 pos ); diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index c14099dbd5..dacea2a987 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -98,8 +98,10 @@ public: void pageDown(S32 overlap = 0); void goToTop(); void goToBottom(); - bool isAtTop() { return mScrollbar[VERTICAL]->isAtBeginning(); } - bool isAtBottom() { return mScrollbar[VERTICAL]->isAtEnd(); } + bool isAtTop() const { return mScrollbar[VERTICAL]->isAtBeginning(); } + bool isAtBottom() const { return mScrollbar[VERTICAL]->isAtEnd(); } + S32 getDocPosVertical() const { return mScrollbar[VERTICAL]->getDocPos(); } + S32 getDocPosHorizontal() const { return mScrollbar[HORIZONTAL]->getDocPos(); } S32 getBorderWidth() const; // LLView functionality diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index fa50261c9b..271cc3e037 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1254,12 +1254,26 @@ void LLInventoryGallery::onFocusReceived() // inventory now handles cut/copy/paste/delete gEditMenuHandler = this; - LLPanel::onFocusReceived(); - + // Tab support, when tabbing into this view, select first item if (mSelectedItemID.notNull() && mItemMap[mSelectedItemID]) { - mItemMap[mSelectedItemID]->setSelected(true); + LLInventoryGalleryItem* focus_item = mItemMap[mSelectedItemID]; + focus_item->setSelected(true); + focus_item->setFocus(TRUE); } + else if (mIndexToItemMap.size() > 0) + { + // choose any items from visible rect + S32 vert_offset = mScrollPanel->getDocPosVertical(); + S32 panel_size = mVerticalGap + mRowPanelHeight; + S32 n = llclamp((S32)(vert_offset / panel_size) * mItemsInRow, 0, (S32)(mIndexToItemMap.size() - 1) ); + + LLInventoryGalleryItem* focus_item = mIndexToItemMap[n]; + changeItemSelection(focus_item->getUUID(), true); + focus_item->setFocus(TRUE); + } + + LLPanel::onFocusReceived(); } void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id) diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 95f15c9c55..54f91451ac 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1449,6 +1449,45 @@ void LLInventoryPanel::onFocusReceived() // inventory now handles cut/copy/paste/delete LLEditMenuHandler::gEditMenuHandler = mFolderRoot.get(); + // Tab support, when tabbing into this view, select first item + // (ideally needs to account for scroll) + bool select_first = mSelectThisID.isNull() && mFolderRoot.get() && mFolderRoot.get()->getSelectedCount() == 0; + + if (select_first) + { + LLFolderViewFolder::folders_t::const_iterator folders_it = mFolderRoot.get()->getFoldersBegin(); + LLFolderViewFolder::folders_t::const_iterator folders_end = mFolderRoot.get()->getFoldersEnd(); + + for (; folders_it != folders_end; ++folders_it) + { + const LLFolderViewFolder* folder_view = *folders_it; + if (folder_view->getVisible()) + { + const LLFolderViewModelItemInventory* modelp = static_cast<const LLFolderViewModelItemInventory*>(folder_view->getViewModelItem()); + setSelectionByID(modelp->getUUID(), TRUE); + select_first = false; + break; + } + } + } + + if (select_first) + { + LLFolderViewFolder::items_t::const_iterator items_it = mFolderRoot.get()->getItemsBegin(); + LLFolderViewFolder::items_t::const_iterator items_end = mFolderRoot.get()->getItemsEnd(); + + for (; items_it != items_end; ++items_it) + { + const LLFolderViewItem* item_view = *items_it; + if (item_view->getVisible()) + { + const LLFolderViewModelItemInventory* modelp = static_cast<const LLFolderViewModelItemInventory*>(item_view->getViewModelItem()); + setSelectionByID(modelp->getUUID(), TRUE); + break; + } + } + } + LLPanel::onFocusReceived(); } diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 27c8f10889..b63d6b9308 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -2322,20 +2322,11 @@ void LLPanelMainInventory::onCombinationRootChanged(bool gallery_clicked) void LLPanelMainInventory::onCombinationGallerySelectionChanged(const LLUUID& category_id) { - if(category_id != LLUUID::null) - { - mCombinationInventoryPanel->unSelectAll(); - } } void LLPanelMainInventory::onCombinationInventorySelectionChanged(const std::deque<LLFolderViewItem*>& items, BOOL user_action) { onSelectionChange(mCombinationInventoryPanel, items, user_action); - - if(!items.empty()) - { - mCombinationGalleryPanel->clearSelection(); - } } void LLPanelMainInventory::updatePanelVisibility() |