diff options
Diffstat (limited to 'linden/indra/newview/llfolderview.cpp')
-rw-r--r-- | linden/indra/newview/llfolderview.cpp | 106 |
1 files changed, 56 insertions, 50 deletions
diff --git a/linden/indra/newview/llfolderview.cpp b/linden/indra/newview/llfolderview.cpp index 4b487ce..8cefd5b 100644 --- a/linden/indra/newview/llfolderview.cpp +++ b/linden/indra/newview/llfolderview.cpp | |||
@@ -116,8 +116,34 @@ LLColor4 LLFolderViewItem::sFilterBGColor; | |||
116 | LLColor4 LLFolderViewItem::sFilterTextColor; | 116 | LLColor4 LLFolderViewItem::sFilterTextColor; |
117 | LLColor4 LLFolderViewItem::sSuffixColor; | 117 | LLColor4 LLFolderViewItem::sSuffixColor; |
118 | LLColor4 LLFolderViewItem::sSearchStatusColor; | 118 | LLColor4 LLFolderViewItem::sSearchStatusColor; |
119 | LLUIImagePtr LLFolderViewItem::sArrowImage; | ||
120 | LLUIImagePtr LLFolderViewItem::sBoxImage; | ||
121 | |||
122 | //static | ||
123 | void LLFolderViewItem::initClass() | ||
124 | { | ||
125 | sFont = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); | ||
126 | sSmallFont = LLResMgr::getInstance()->getRes( LLFONT_SMALL ); | ||
127 | sFgColor = gColors.getColor( "MenuItemEnabledColor" ); | ||
128 | sHighlightBgColor = gColors.getColor( "MenuItemHighlightBgColor" ); | ||
129 | sHighlightFgColor = gColors.getColor( "MenuItemHighlightFgColor" ); | ||
130 | sFilterBGColor = gColors.getColor( "FilterBackgroundColor" ); | ||
131 | sFilterTextColor = gColors.getColor( "FilterTextColor" ); | ||
132 | sSuffixColor = gColors.getColor( "InventoryItemSuffixColor" ); | ||
133 | sSearchStatusColor = gColors.getColor( "InventorySearchStatusColor" ); | ||
134 | sArrowImage = LLUI::getUIImage("folder_arrow.tga"); | ||
135 | sBoxImage = LLUI::getUIImage("rounded_square.tga"); | ||
136 | } | ||
137 | |||
138 | //static | ||
139 | void LLFolderViewItem::cleanupClass() | ||
140 | { | ||
141 | sArrowImage = NULL; | ||
142 | sBoxImage = NULL; | ||
143 | } | ||
119 | 144 | ||
120 | // Default constructor | 145 | // Default constructor |
146 | // NOTE: Optimize this, we call it a *lot* when opening a large inventory | ||
121 | LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon, | 147 | LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon, |
122 | S32 creation_date, | 148 | S32 creation_date, |
123 | LLFolderView* root, | 149 | LLFolderView* root, |
@@ -132,6 +158,7 @@ LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon, | |||
132 | mIsCurSelection( FALSE ), | 158 | mIsCurSelection( FALSE ), |
133 | mSelectPending(FALSE), | 159 | mSelectPending(FALSE), |
134 | mLabelStyle( LLFontGL::NORMAL ), | 160 | mLabelStyle( LLFontGL::NORMAL ), |
161 | mIcon(icon), | ||
135 | mHasVisibleChildren(FALSE), | 162 | mHasVisibleChildren(FALSE), |
136 | mIndentation(0), | 163 | mIndentation(0), |
137 | mNumDescendantsSelected(0), | 164 | mNumDescendantsSelected(0), |
@@ -143,31 +170,7 @@ LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon, | |||
143 | mDragAndDropTarget(FALSE), | 170 | mDragAndDropTarget(FALSE), |
144 | mIsLoading(FALSE) | 171 | mIsLoading(FALSE) |
145 | { | 172 | { |
146 | setIcon(icon); | 173 | refresh(); // possible opt: only call refreshFromListener() |
147 | if( !LLFolderViewItem::sFont ) | ||
148 | { | ||
149 | LLFolderViewItem::sFont = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); | ||
150 | } | ||
151 | |||
152 | if (!LLFolderViewItem::sSmallFont) | ||
153 | { | ||
154 | LLFolderViewItem::sSmallFont = LLResMgr::getInstance()->getRes( LLFONT_SMALL ); | ||
155 | } | ||
156 | |||
157 | // HACK: Can't be set above because gSavedSettings might not be constructed. | ||
158 | LLFolderViewItem::sFgColor = gColors.getColor( "MenuItemEnabledColor" ); | ||
159 | LLFolderViewItem::sHighlightBgColor = gColors.getColor( "MenuItemHighlightBgColor" ); | ||
160 | LLFolderViewItem::sHighlightFgColor = gColors.getColor( "MenuItemHighlightFgColor" ); | ||
161 | LLFolderViewItem::sFilterBGColor = gColors.getColor( "FilterBackgroundColor" ); | ||
162 | LLFolderViewItem::sFilterTextColor = gColors.getColor( "FilterTextColor" ); | ||
163 | LLFolderViewItem::sSuffixColor = gColors.getColor( "InventoryItemSuffixColor" ); | ||
164 | LLFolderViewItem::sSearchStatusColor = gColors.getColor( "InventorySearchStatusColor" ); | ||
165 | |||
166 | |||
167 | mArrowImage = LLUI::getUIImage("folder_arrow.tga"); | ||
168 | mBoxImage = LLUI::getUIImage("rounded_square.tga"); | ||
169 | |||
170 | refresh(); | ||
171 | setTabStop(FALSE); | 174 | setTabStop(FALSE); |
172 | } | 175 | } |
173 | 176 | ||
@@ -176,8 +179,6 @@ LLFolderViewItem::~LLFolderViewItem( void ) | |||
176 | { | 179 | { |
177 | delete mListener; | 180 | delete mListener; |
178 | mListener = NULL; | 181 | mListener = NULL; |
179 | mArrowImage = NULL; | ||
180 | mBoxImage = NULL; | ||
181 | } | 182 | } |
182 | 183 | ||
183 | LLFolderView* LLFolderViewItem::getRoot() | 184 | LLFolderView* LLFolderViewItem::getRoot() |
@@ -276,7 +277,7 @@ void LLFolderViewItem::setIcon(LLUIImagePtr icon) | |||
276 | } | 277 | } |
277 | 278 | ||
278 | // refresh information from the listener | 279 | // refresh information from the listener |
279 | void LLFolderViewItem::refresh() | 280 | void LLFolderViewItem::refreshFromListener() |
280 | { | 281 | { |
281 | if(mListener) | 282 | if(mListener) |
282 | { | 283 | { |
@@ -290,30 +291,35 @@ void LLFolderViewItem::refresh() | |||
290 | } | 291 | } |
291 | mLabelStyle = mListener->getLabelStyle(); | 292 | mLabelStyle = mListener->getLabelStyle(); |
292 | mLabelSuffix = mListener->getLabelSuffix(); | 293 | mLabelSuffix = mListener->getLabelSuffix(); |
294 | } | ||
295 | } | ||
293 | 296 | ||
294 | std::string searchable_label(mLabel); | 297 | void LLFolderViewItem::refresh() |
295 | searchable_label.append(mLabelSuffix); | 298 | { |
296 | LLStringUtil::toUpper(searchable_label); | 299 | refreshFromListener(); |
300 | |||
301 | std::string searchable_label(mLabel); | ||
302 | searchable_label.append(mLabelSuffix); | ||
303 | LLStringUtil::toUpper(searchable_label); | ||
297 | 304 | ||
298 | if (mSearchableLabel.compare(searchable_label)) | 305 | if (mSearchableLabel.compare(searchable_label)) |
306 | { | ||
307 | mSearchableLabel.assign(searchable_label); | ||
308 | dirtyFilter(); | ||
309 | // some part of label has changed, so overall width has potentially changed | ||
310 | if (mParentFolder) | ||
299 | { | 311 | { |
300 | mSearchableLabel.assign(searchable_label); | 312 | mParentFolder->requestArrange(); |
301 | dirtyFilter(); | ||
302 | // some part of label has changed, so overall width has potentially changed | ||
303 | if (mParentFolder) | ||
304 | { | ||
305 | mParentFolder->requestArrange(); | ||
306 | } | ||
307 | } | 313 | } |
314 | } | ||
308 | 315 | ||
309 | S32 label_width = sFont->getWidth(mLabel); | 316 | S32 label_width = sFont->getWidth(mLabel); |
310 | if( mLabelSuffix.size() ) | 317 | if( mLabelSuffix.size() ) |
311 | { | 318 | { |
312 | label_width += sFont->getWidth( mLabelSuffix ); | 319 | label_width += sFont->getWidth( mLabelSuffix ); |
313 | } | 320 | } |
314 | 321 | ||
315 | mLabelWidth = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + label_width; | 322 | mLabelWidth = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + label_width; |
316 | } | ||
317 | } | 323 | } |
318 | 324 | ||
319 | void LLFolderViewItem::applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor) | 325 | void LLFolderViewItem::applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor) |
@@ -798,10 +804,10 @@ void LLFolderViewItem::draw() | |||
798 | } | 804 | } |
799 | if(/*mControlLabel[0] != '\0' && */possibly_has_children) | 805 | if(/*mControlLabel[0] != '\0' && */possibly_has_children) |
800 | { | 806 | { |
801 | if (mArrowImage) | 807 | if (sArrowImage) |
802 | { | 808 | { |
803 | gl_draw_scaled_rotated_image(mIndentation, getRect().getHeight() - ARROW_SIZE - TEXT_PAD, | 809 | gl_draw_scaled_rotated_image(mIndentation, getRect().getHeight() - ARROW_SIZE - TEXT_PAD, |
804 | ARROW_SIZE, ARROW_SIZE, mControlLabelRotation, mArrowImage->getImage(), sFgColor); | 810 | ARROW_SIZE, ARROW_SIZE, mControlLabelRotation, sArrowImage->getImage(), sFgColor); |
805 | } | 811 | } |
806 | } | 812 | } |
807 | 813 | ||
@@ -937,7 +943,7 @@ void LLFolderViewItem::draw() | |||
937 | S32_MAX, S32_MAX, &right_x, FALSE ); | 943 | S32_MAX, S32_MAX, &right_x, FALSE ); |
938 | } | 944 | } |
939 | 945 | ||
940 | if (mBoxImage.notNull() && mStringMatchOffset != std::string::npos) | 946 | if (sBoxImage.notNull() && mStringMatchOffset != std::string::npos) |
941 | { | 947 | { |
942 | // don't draw backgrounds for zero-length strings | 948 | // don't draw backgrounds for zero-length strings |
943 | S32 filter_string_length = mRoot->getFilterSubString().size(); | 949 | S32 filter_string_length = mRoot->getFilterSubString().size(); |
@@ -950,7 +956,7 @@ void LLFolderViewItem::draw() | |||
950 | S32 top = getRect().getHeight(); | 956 | S32 top = getRect().getHeight(); |
951 | 957 | ||
952 | LLRect box_rect(left, top, right, bottom); | 958 | LLRect box_rect(left, top, right, bottom); |
953 | mBoxImage->draw(box_rect, sFilterBGColor); | 959 | sBoxImage->draw(box_rect, sFilterBGColor); |
954 | F32 match_string_left = text_left + sFont->getWidthF32(combined_string, 0, mStringMatchOffset); | 960 | F32 match_string_left = text_left + sFont->getWidthF32(combined_string, 0, mStringMatchOffset); |
955 | F32 y = (F32)getRect().getHeight() - sFont->getLineHeight() - (F32)TEXT_PAD; | 961 | F32 y = (F32)getRect().getHeight() - sFont->getLineHeight() - (F32)TEXT_PAD; |
956 | sFont->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y, | 962 | sFont->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y, |