aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrolllistctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llscrolllistctrl.cpp')
-rw-r--r--linden/indra/llui/llscrolllistctrl.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/linden/indra/llui/llscrolllistctrl.cpp b/linden/indra/llui/llscrolllistctrl.cpp
index 9e1a573..f5eef29 100644
--- a/linden/indra/llui/llscrolllistctrl.cpp
+++ b/linden/indra/llui/llscrolllistctrl.cpp
@@ -2,6 +2,8 @@
2 * @file llscrolllistctrl.cpp 2 * @file llscrolllistctrl.cpp
3 * @brief LLScrollListCtrl base class 3 * @brief LLScrollListCtrl base class
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 7 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 8 *
7 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
@@ -24,6 +26,7 @@
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE. 28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
27 */ 30 */
28 31
29#include <algorithm> 32#include <algorithm>
@@ -229,7 +232,7 @@ void LLScrollListText::setColor(const LLColor4& color)
229 *mColor = color; 232 *mColor = color;
230} 233}
231 234
232void LLScrollListText::setText(const LLString& text) 235void LLScrollListText::setText(const LLStringExplicit& text)
233{ 236{
234 mText = text; 237 mText = text;
235} 238}
@@ -620,6 +623,7 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllData() const
620 623
621void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) 624void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent )
622{ 625{
626 S32 old_height = mRect.getHeight();
623 LLUICtrl::reshape( width, height, called_from_parent ); 627 LLUICtrl::reshape( width, height, called_from_parent );
624 628
625 S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0); 629 S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0);
@@ -631,9 +635,13 @@ void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent )
631 mRect.getHeight() - 2*( mBorderThickness + LIST_BORDER_PAD ) - heading_size ); 635 mRect.getHeight() - 2*( mBorderThickness + LIST_BORDER_PAD ) - heading_size );
632 636
633 mPageLines = mLineHeight? mItemListRect.getHeight() / mLineHeight : 0; 637 mPageLines = mLineHeight? mItemListRect.getHeight() / mLineHeight : 0;
638 if(old_height < height && getScrollPos() == mScrollbar->getDocPosMax())
639 {
640 setScrollPos(mScrollbar->getDocPosMax());
641 }
634 mScrollbar->setVisible(mPageLines < getItemCount()); 642 mScrollbar->setVisible(mPageLines < getItemCount());
635 mScrollbar->setPageSize( mPageLines ); 643 mScrollbar->setPageSize( mPageLines );
636 644
637 updateColumns(); 645 updateColumns();
638} 646}
639 647
@@ -770,6 +778,7 @@ void LLScrollListCtrl::updateColumns()
770 mColumnsIndexed.resize(mColumns.size()); 778 mColumnsIndexed.resize(mColumns.size());
771 779
772 std::map<LLString, LLScrollListColumn>::iterator column_itor; 780 std::map<LLString, LLScrollListColumn>::iterator column_itor;
781 bool first_dynamic = true;
773 for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) 782 for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor)
774 { 783 {
775 LLScrollListColumn *column = &column_itor->second; 784 LLScrollListColumn *column = &column_itor->second;
@@ -781,6 +790,11 @@ void LLScrollListCtrl::updateColumns()
781 else if (column->mDynamicWidth) 790 else if (column->mDynamicWidth)
782 { 791 {
783 new_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; 792 new_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns;
793 if(first_dynamic)
794 {
795 first_dynamic = false;
796 new_width += (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE);
797 }
784 } 798 }
785 799
786 if (new_width != column->mWidth) 800 if (new_width != column->mWidth)
@@ -810,9 +824,10 @@ void LLScrollListCtrl::updateColumns()
810 LLColumnHeader* last_header = NULL; 824 LLColumnHeader* last_header = NULL;
811 for (column_ordered_it = mColumnsIndexed.begin(); column_ordered_it != mColumnsIndexed.end(); ++column_ordered_it) 825 for (column_ordered_it = mColumnsIndexed.begin(); column_ordered_it != mColumnsIndexed.end(); ++column_ordered_it)
812 { 826 {
813 if ((*column_ordered_it)->mWidth <= 0) 827 if ((*column_ordered_it)->mWidth < 0)
814 { 828 {
815 // skip hidden columns 829 // skip hidden columns
830 continue;
816 } 831 }
817 LLScrollListColumn* column = *column_ordered_it; 832 LLScrollListColumn* column = *column_ordered_it;
818 833
@@ -827,9 +842,8 @@ void LLScrollListCtrl::updateColumns()
827 right += mColumnPadding; 842 right += mColumnPadding;
828 } 843 }
829 right = llmax(left, llmin(mItemListRect.getWidth(), right)); 844 right = llmax(left, llmin(mItemListRect.getWidth(), right));
830
831 S32 header_width = right - left; 845 S32 header_width = right - left;
832 846
833 last_header->reshape(header_width, mHeadingHeight); 847 last_header->reshape(header_width, mHeadingHeight);
834 last_header->translate(left - last_header->getRect().mLeft, top - last_header->getRect().mBottom); 848 last_header->translate(left - last_header->getRect().mLeft, top - last_header->getRect().mBottom);
835 last_header->setVisible(mDisplayColumnHeaders && header_width > 0); 849 last_header->setVisible(mDisplayColumnHeaders && header_width > 0);
@@ -838,12 +852,15 @@ void LLScrollListCtrl::updateColumns()
838 } 852 }
839 853
840 // expand last column header we encountered to full list width 854 // expand last column header we encountered to full list width
855
841 if (last_header) 856 if (last_header)
842 { 857 {
843 S32 header_strip_width = mItemListRect.getWidth() + (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE); 858 S32 header_strip_width = mItemListRect.getWidth() + (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE);
844 S32 new_width = llmax(0, mItemListRect.mLeft + header_strip_width - last_header->getRect().mLeft); 859 S32 new_width = llmax(0, mItemListRect.mLeft + header_strip_width - last_header->getRect().mLeft);
845 last_header->reshape(new_width, last_header->getRect().getHeight()); 860 last_header->reshape(new_width, last_header->getRect().getHeight());
861 last_header->setVisible(mDisplayColumnHeaders && new_width > 0);
846 } 862 }
863
847} 864}
848 865
849void LLScrollListCtrl::setDisplayHeading(BOOL display) 866void LLScrollListCtrl::setDisplayHeading(BOOL display)
@@ -1453,7 +1470,9 @@ void LLScrollListCtrl::drawItems()
1453 LLGLSUIDefault gls_ui; 1470 LLGLSUIDefault gls_ui;
1454 1471
1455 { 1472 {
1456 LLLocalClipRect clip(mItemListRect); 1473 LLRect clip_rect = mItemListRect;
1474 if(!mScrollbar->getVisible()) clip_rect.mRight += SCROLLBAR_SIZE;
1475 LLLocalClipRect clip(clip_rect);
1457 1476
1458 S32 cur_x = x; 1477 S32 cur_x = x;
1459 S32 cur_y = y; 1478 S32 cur_y = y;
@@ -1472,10 +1491,10 @@ void LLScrollListCtrl::drawItems()
1472 item_rect.setOriginAndSize( 1491 item_rect.setOriginAndSize(
1473 cur_x, 1492 cur_x,
1474 cur_y, 1493 cur_y,
1475 mScrollbar->getVisible() ? mItemListRect.getWidth() : mItemListRect.getWidth() + mScrollbar->getRect().getWidth(), 1494 mScrollbar->getVisible() ? mItemListRect.getWidth() : mItemListRect.getWidth() + SCROLLBAR_SIZE,
1476 mLineHeight ); 1495 mLineHeight );
1477 1496
1478 lldebugs << mItemListRect.getWidth() << llendl; 1497 //llinfos << item_rect.getWidth() << llendl;
1479 1498
1480 if (item->getSelected()) 1499 if (item->getSelected())
1481 { 1500 {
@@ -1523,22 +1542,31 @@ void LLScrollListCtrl::drawItems()
1523 S32 cur_col = 0; 1542 S32 cur_col = 0;
1524 S32 dynamic_width = 0; 1543 S32 dynamic_width = 0;
1525 S32 dynamic_remainder = 0; 1544 S32 dynamic_remainder = 0;
1545 bool first_dynamic = true;
1526 if(mNumDynamicWidthColumns > 0) 1546 if(mNumDynamicWidthColumns > 0)
1527 { 1547 {
1528 dynamic_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; 1548 dynamic_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns;
1529 dynamic_remainder = (mItemListRect.getWidth() - mTotalStaticColumnWidth) % mNumDynamicWidthColumns; 1549 dynamic_remainder = (mItemListRect.getWidth() - mTotalStaticColumnWidth) % mNumDynamicWidthColumns;
1530 } 1550 }
1551
1531 for (LLScrollListCell* cell = item->getColumn(0); cur_col < num_cols; cell = item->getColumn(++cur_col)) 1552 for (LLScrollListCell* cell = item->getColumn(0); cur_col < num_cols; cell = item->getColumn(++cur_col))
1532 { 1553 {
1533 S32 cell_width = cell->getWidth(); 1554 S32 cell_width = cell->getWidth();
1555
1534 if(mColumnsIndexed.size() > (U32)cur_col && mColumnsIndexed[cur_col] && mColumnsIndexed[cur_col]->mDynamicWidth) 1556 if(mColumnsIndexed.size() > (U32)cur_col && mColumnsIndexed[cur_col] && mColumnsIndexed[cur_col]->mDynamicWidth)
1535 { 1557 {
1536 cell_width = dynamic_width + (--dynamic_remainder ? 1 : 0); 1558 cell_width = dynamic_width + (--dynamic_remainder ? 1 : 0);
1559 if(first_dynamic)
1560 {
1561 cell_width += mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE;
1562 first_dynamic = false;
1563 }
1537 cell->setWidth(cell_width); 1564 cell->setWidth(cell_width);
1538 } 1565 }
1539 // Two ways a cell could be hidden 1566 // Two ways a cell could be hidden
1540 if (cell_width < 0 1567 if (cell_width < 0
1541 || !cell->getVisible()) continue; 1568 || !cell->getVisible()) continue;
1569
1542 LLUI::pushMatrix(); 1570 LLUI::pushMatrix();
1543 LLUI::translate((F32) cur_x, (F32) cur_y, 0.0f); 1571 LLUI::translate((F32) cur_x, (F32) cur_y, 0.0f);
1544 S32 space_left = mItemListRect.mRight - cur_x; 1572 S32 space_left = mItemListRect.mRight - cur_x;