diff options
Diffstat (limited to 'indra/newview/llinventorygallery.cpp')
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 84 |
1 files changed, 82 insertions, 2 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index a6cadea712..1610ef7f34 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -970,11 +970,11 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask) { // Might be better to get item from panel S32 n = mItemIndexMap[item]; - if (n == 0) + n--; + if (n < 0) { n = mItemsAddedCount - 1; } - n--; item = mIndexToItemMap[n]; LLUUID item_id = item->getUUID(); changeItemSelection(item_id, true); @@ -1008,6 +1008,16 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask) handled = TRUE; break; + case KEY_UP: + scrollUp(); + handled = TRUE; + break; + + case KEY_DOWN: + scrollDown(); + handled = TRUE; + break; + default: break; } @@ -1020,6 +1030,50 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask) return handled; } +void LLInventoryGallery::scrollUp() +{ + mFilterSubString.clear(); + + if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + { + LLInventoryGalleryItem* item = getSelectedItem(); + if (item) + { + S32 n = mItemIndexMap[item]; + n -= mItemsInRow; + if (n >= 0) + { + item = mIndexToItemMap[n]; + LLUUID item_id = item->getUUID(); + changeItemSelection(item_id, true); + item->setFocus(TRUE); + } + } + } +} + +void LLInventoryGallery::scrollDown() +{ + mFilterSubString.clear(); + + if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1) + { + LLInventoryGalleryItem* item = getSelectedItem(); + if (item) + { + S32 n = mItemIndexMap[item]; + n += mItemsInRow; + if (n < mItemsAddedCount) + { + item = mIndexToItemMap[n]; + LLUUID item_id = item->getUUID(); + changeItemSelection(item_id, true); + item->setFocus(TRUE); + } + } + } +} + void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id) { if (mInventoryGalleryMenu && item_id.notNull()) @@ -1690,6 +1744,32 @@ BOOL LLInventoryGalleryItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL dro return baseHandleDragAndDrop(mUUID, drop, cargo_type, cargo_data, accept, tooltip_msg); } +BOOL LLInventoryGalleryItem::handleKeyHere(KEY key, MASK mask) +{ + if (!mGallery) + { + return FALSE; + } + + BOOL handled = FALSE; + switch (key) + { + case KEY_UP: + mGallery->scrollUp(); + handled = true; + break; + + case KEY_DOWN: + mGallery->scrollDown(); + handled = true; + break; + + default: + break; + } + return handled; +} + void LLInventoryGalleryItem::setWorn(bool value) { mWorn = value; |