From 215f423cbe18fe9ca14a26caef918d303bad28ff Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:11 -0500 Subject: Second Life viewer sources 1.18.4.0-RC --- linden/indra/llui/llscrolllistctrl.cpp | 46 +++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'linden/indra/llui/llscrolllistctrl.cpp') 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 @@ * @file llscrolllistctrl.cpp * @brief LLScrollListCtrl base class * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * * Copyright (c) 2001-2007, Linden Research, Inc. * * Second Life Viewer Source Code @@ -24,6 +26,7 @@ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ */ #include @@ -229,7 +232,7 @@ void LLScrollListText::setColor(const LLColor4& color) *mColor = color; } -void LLScrollListText::setText(const LLString& text) +void LLScrollListText::setText(const LLStringExplicit& text) { mText = text; } @@ -620,6 +623,7 @@ std::vector LLScrollListCtrl::getAllData() const void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) { + S32 old_height = mRect.getHeight(); LLUICtrl::reshape( width, height, called_from_parent ); S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0); @@ -631,9 +635,13 @@ void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) mRect.getHeight() - 2*( mBorderThickness + LIST_BORDER_PAD ) - heading_size ); mPageLines = mLineHeight? mItemListRect.getHeight() / mLineHeight : 0; + if(old_height < height && getScrollPos() == mScrollbar->getDocPosMax()) + { + setScrollPos(mScrollbar->getDocPosMax()); + } mScrollbar->setVisible(mPageLines < getItemCount()); mScrollbar->setPageSize( mPageLines ); - + updateColumns(); } @@ -770,6 +778,7 @@ void LLScrollListCtrl::updateColumns() mColumnsIndexed.resize(mColumns.size()); std::map::iterator column_itor; + bool first_dynamic = true; for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) { LLScrollListColumn *column = &column_itor->second; @@ -781,6 +790,11 @@ void LLScrollListCtrl::updateColumns() else if (column->mDynamicWidth) { new_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; + if(first_dynamic) + { + first_dynamic = false; + new_width += (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE); + } } if (new_width != column->mWidth) @@ -810,9 +824,10 @@ void LLScrollListCtrl::updateColumns() LLColumnHeader* last_header = NULL; for (column_ordered_it = mColumnsIndexed.begin(); column_ordered_it != mColumnsIndexed.end(); ++column_ordered_it) { - if ((*column_ordered_it)->mWidth <= 0) + if ((*column_ordered_it)->mWidth < 0) { - // skip hidden columns + // skip hidden columns + continue; } LLScrollListColumn* column = *column_ordered_it; @@ -827,9 +842,8 @@ void LLScrollListCtrl::updateColumns() right += mColumnPadding; } right = llmax(left, llmin(mItemListRect.getWidth(), right)); - S32 header_width = right - left; - + last_header->reshape(header_width, mHeadingHeight); last_header->translate(left - last_header->getRect().mLeft, top - last_header->getRect().mBottom); last_header->setVisible(mDisplayColumnHeaders && header_width > 0); @@ -838,12 +852,15 @@ void LLScrollListCtrl::updateColumns() } // expand last column header we encountered to full list width + if (last_header) { S32 header_strip_width = mItemListRect.getWidth() + (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE); S32 new_width = llmax(0, mItemListRect.mLeft + header_strip_width - last_header->getRect().mLeft); last_header->reshape(new_width, last_header->getRect().getHeight()); + last_header->setVisible(mDisplayColumnHeaders && new_width > 0); } + } void LLScrollListCtrl::setDisplayHeading(BOOL display) @@ -1453,7 +1470,9 @@ void LLScrollListCtrl::drawItems() LLGLSUIDefault gls_ui; { - LLLocalClipRect clip(mItemListRect); + LLRect clip_rect = mItemListRect; + if(!mScrollbar->getVisible()) clip_rect.mRight += SCROLLBAR_SIZE; + LLLocalClipRect clip(clip_rect); S32 cur_x = x; S32 cur_y = y; @@ -1472,10 +1491,10 @@ void LLScrollListCtrl::drawItems() item_rect.setOriginAndSize( cur_x, cur_y, - mScrollbar->getVisible() ? mItemListRect.getWidth() : mItemListRect.getWidth() + mScrollbar->getRect().getWidth(), + mScrollbar->getVisible() ? mItemListRect.getWidth() : mItemListRect.getWidth() + SCROLLBAR_SIZE, mLineHeight ); - lldebugs << mItemListRect.getWidth() << llendl; + //llinfos << item_rect.getWidth() << llendl; if (item->getSelected()) { @@ -1523,22 +1542,31 @@ void LLScrollListCtrl::drawItems() S32 cur_col = 0; S32 dynamic_width = 0; S32 dynamic_remainder = 0; + bool first_dynamic = true; if(mNumDynamicWidthColumns > 0) { dynamic_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; dynamic_remainder = (mItemListRect.getWidth() - mTotalStaticColumnWidth) % mNumDynamicWidthColumns; } + for (LLScrollListCell* cell = item->getColumn(0); cur_col < num_cols; cell = item->getColumn(++cur_col)) { S32 cell_width = cell->getWidth(); + if(mColumnsIndexed.size() > (U32)cur_col && mColumnsIndexed[cur_col] && mColumnsIndexed[cur_col]->mDynamicWidth) { cell_width = dynamic_width + (--dynamic_remainder ? 1 : 0); + if(first_dynamic) + { + cell_width += mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE; + first_dynamic = false; + } cell->setWidth(cell_width); } // Two ways a cell could be hidden if (cell_width < 0 || !cell->getVisible()) continue; + LLUI::pushMatrix(); LLUI::translate((F32) cur_x, (F32) cur_y, 0.0f); S32 space_left = mItemListRect.mRight - cur_x; -- cgit v1.1