diff options
author | Monroe Williams <monroe@lindenlab.com> | 2007-08-02 01:18:34 +0000 |
---|---|---|
committer | Monroe Williams <monroe@lindenlab.com> | 2007-08-02 01:18:34 +0000 |
commit | 7138fb673ac3df46b9cb5f23d0d74e70fdd2b6b3 (patch) | |
tree | 3c34a3a180b5275bd4166b0056765c5868f56447 /indra/llui/llscrolllistctrl.cpp | |
parent | f6a10b3214d79df4e8f5768acaa68edbd2de5620 (diff) |
Merge down from Branch_1-18-1:
svn merge --ignore-ancestry svn+ssh://svn.lindenlab.com/svn/linden/release@66449 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-18-1@67131
Diffstat (limited to 'indra/llui/llscrolllistctrl.cpp')
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 1d07d3f36b..e802b3426b 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -31,7 +31,7 @@ #include "llkeyboard.h" #include "llresizebar.h" -const S32 LIST_BORDER_PAD = 2; // white space inside the border and to the left of the scrollbar +const S32 LIST_BORDER_PAD = 0; // white space inside the border and to the left of the scrollbar const S32 MIN_COLUMN_WIDTH = 20; const S32 LIST_SNAP_PADDING = 5; @@ -397,6 +397,7 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, mCommitOnKeyboardMovement(TRUE), mCommitOnSelectionChange(FALSE), mSelectionChanged(FALSE), + mNeedsScroll(FALSE), mCanSelect(TRUE), mDisplayColumnHeaders(FALSE), mCollapseEmptyColumns(FALSE), @@ -1419,14 +1420,16 @@ void LLScrollListCtrl::drawItems() S32 x = mItemListRect.mLeft; S32 y = mItemListRect.mTop - mLineHeight; - S32 num_page_lines = mPageLines; + // allow for partial line at bottom + S32 num_page_lines = mPageLines + 1; LLRect item_rect; LLGLSUIDefault gls_ui; { - + LLLocalClipRect clip(mItemListRect); + S32 cur_x = x; S32 cur_y = y; @@ -1538,6 +1541,11 @@ void LLScrollListCtrl::draw() { if( getVisible() ) { + if (mNeedsScroll) + { + scrollToShowSelected(); + mNeedsScroll = FALSE; + } LLRect background(0, mRect.getHeight(), mRect.getWidth(), 0); // Draw background if (mBackgroundVisible) @@ -1690,6 +1698,7 @@ BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask) gFocusMgr.setMouseCapture(this); selectItemAt(x, y, mask); + mNeedsScroll = TRUE; } return TRUE; @@ -1699,17 +1708,16 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask) { if (hasMouseCapture()) { + // release mouse capture immediately so + // scroll to show selected logic will work + gFocusMgr.setMouseCapture(NULL); if(mask == MASK_NONE) { selectItemAt(x, y, mask); + mNeedsScroll = TRUE; } } - if (hasMouseCapture()) - { - gFocusMgr.setMouseCapture(NULL); - } - // always commit when mouse operation is completed inside list if (mItemListRect.pointInRect(x,y)) { @@ -1750,7 +1758,8 @@ LLScrollListItem* LLScrollListCtrl::hitItem( S32 x, S32 y ) mItemListRect.getWidth(), mLineHeight ); - int num_page_lines = mPageLines; + // allow for partial line at bottom + S32 num_page_lines = mPageLines + 1; S32 line = 0; item_list::iterator iter; @@ -1783,6 +1792,7 @@ BOOL LLScrollListCtrl::handleHover(S32 x,S32 y,MASK mask) if(mask == MASK_NONE) { selectItemAt(x, y, mask); + mNeedsScroll = TRUE; } } else if (mCanSelect) @@ -1830,7 +1840,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent { // commit implicit in call selectPrevItem(FALSE); - scrollToShowSelected(); + mNeedsScroll = TRUE; handled = TRUE; } break; @@ -1839,7 +1849,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent { // commit implicit in call selectNextItem(FALSE); - scrollToShowSelected(); + mNeedsScroll = TRUE; handled = TRUE; } break; @@ -1847,7 +1857,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent if (mAllowKeyboardMovement || hasFocus()) { selectNthItem(getFirstSelectedIndex() - (mScrollbar->getPageSize() - 1)); - scrollToShowSelected(); + mNeedsScroll = TRUE; if (mCommitOnKeyboardMovement && !mCommitOnSelectionChange) { @@ -1860,7 +1870,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent if (mAllowKeyboardMovement || hasFocus()) { selectNthItem(getFirstSelectedIndex() + (mScrollbar->getPageSize() - 1)); - scrollToShowSelected(); + mNeedsScroll = TRUE; if (mCommitOnKeyboardMovement && !mCommitOnSelectionChange) { @@ -1873,7 +1883,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent if (mAllowKeyboardMovement || hasFocus()) { selectFirstItem(); - scrollToShowSelected(); + mNeedsScroll = TRUE; if (mCommitOnKeyboardMovement && !mCommitOnSelectionChange) { @@ -1886,7 +1896,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent if (mAllowKeyboardMovement || hasFocus()) { selectNthItem(getItemCount() - 1); - scrollToShowSelected(); + mNeedsScroll = TRUE; if (mCommitOnKeyboardMovement && !mCommitOnSelectionChange) { @@ -1925,6 +1935,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent } else if (selectSimpleItemByPrefix(wstring_to_utf8str(mSearchString), FALSE)) { + mNeedsScroll = TRUE; // update search string only on successful match mSearchTimer.reset(); @@ -1964,6 +1975,7 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_ if (selectSimpleItemByPrefix(wstring_to_utf8str(mSearchString + (llwchar)uni_char), FALSE)) { // update search string only on successful match + mNeedsScroll = TRUE; mSearchString += uni_char; mSearchTimer.reset(); @@ -2009,6 +2021,7 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_ if (item->getEnabled() && LLStringOps::toLower(item_label[0]) == uni_char) { selectItem(item); + mNeedsScroll = TRUE; cellp->highlightText(0, 1); mSearchTimer.reset(); @@ -2030,8 +2043,6 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_ } } - // make sure selected item is on screen - scrollToShowSelected(); return TRUE; } @@ -2183,6 +2194,13 @@ void LLScrollListCtrl::setScrollPos( S32 pos ) void LLScrollListCtrl::scrollToShowSelected() { + // don't scroll automatically when capturing mouse input + // as that will change what is currently under the mouse cursor + if (hasMouseCapture()) + { + return; + } + S32 index = getFirstSelectedIndex(); if (index < 0) { @@ -3013,8 +3031,9 @@ LLColumnHeader::LLColumnHeader(const LLString& label, const LLRect &rect, LLScro const S32 RESIZE_BAR_THICKNESS = 3; mResizeBar = new LLResizeBar( "resizebar", + this, LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), - MIN_COLUMN_WIDTH, mRect.getHeight(), LLResizeBar::RIGHT ); + MIN_COLUMN_WIDTH, S32_MAX, LLResizeBar::RIGHT ); addChild(mResizeBar); mResizeBar->setEnabled(FALSE); |