diff options
Diffstat (limited to 'indra/newview/llinventorylistitem.cpp')
-rw-r--r-- | indra/newview/llinventorylistitem.cpp | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp index e210975a5a..5fb5b0f23f 100644 --- a/indra/newview/llinventorylistitem.cpp +++ b/indra/newview/llinventorylistitem.cpp @@ -43,7 +43,19 @@ static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelInventoryListItemBaseParams(&typeid(LLPanelInventoryListItemBase::Params), "inventory_list_item"); -static const S32 WIDGET_SPACING = 3; +constexpr S32 WIDGET_SPACING = 3; +constexpr S32 FAVORITE_IMAGE_SIZE = 14; +constexpr S32 FAVORITE_IMAGE_PAD = 3; + +bool get_is_item_favorite(const LLViewerInventoryItem* inv) +{ + if (inv->getIsLinkType()) + { + LLInventoryObject* obj = gInventory.getObject(inv->getLinkedUUID()); + return obj && obj->getIsFavorite(); + } + return inv->getIsFavorite(); +} LLPanelInventoryListItemBase::Params::Params() : default_style("default_style"), @@ -75,19 +87,30 @@ void LLPanelInventoryListItemBase::draw() LLViewerInventoryItem* inv_item = getItem(); if (inv_item) { - updateItem(inv_item->getName()); + updateItem(inv_item->getName(), get_is_item_favorite(inv_item)); } setNeedsRefresh(false); } + static LLUICachedControl<bool> draw_star("InventoryFavoritesUseStar", true); + + LLRect local_rect = getLocalRect(); if (mHovered && mHoverImage) { - mHoverImage->draw(getLocalRect()); + mHoverImage->draw(local_rect); + } + else if (mIsFavorite && draw_star()) + { + + static LLPointer<LLUIImage> fav_img = LLRender2D::getInstance()->getUIImage("Inv_Favorite_Star_Full"); + gl_draw_scaled_image( + local_rect.getWidth() - FAVORITE_IMAGE_SIZE - FAVORITE_IMAGE_PAD, FAVORITE_IMAGE_PAD, + FAVORITE_IMAGE_SIZE, FAVORITE_IMAGE_SIZE, fav_img->getImage()); } if (mSelected && mSelectedImage) { - mSelectedImage->draw(getLocalRect()); + mSelectedImage->draw(local_rect); } if (mSeparatorVisible && mSeparatorImage) @@ -95,7 +118,7 @@ void LLPanelInventoryListItemBase::draw() // place under bottom of listitem, using image height // item_pad in list using the item should be >= image height // to avoid cropping of top of the next item. - LLRect separator_rect = getLocalRect(); + LLRect separator_rect = local_rect; separator_rect.mTop = separator_rect.mBottom; separator_rect.mBottom -= mSeparatorImage->getHeight(); F32 alpha = getCurrentTransparency(); @@ -107,9 +130,15 @@ void LLPanelInventoryListItemBase::draw() // virtual void LLPanelInventoryListItemBase::updateItem(const std::string& name, + bool favorite, EItemState item_state) { setIconImage(mIconImage); + if (mIsFavorite != favorite) + { + mIsFavorite = favorite; + reshapeMiddleWidgets(); + } setTitle(name, mHighlightedText, item_state); } @@ -164,7 +193,7 @@ bool LLPanelInventoryListItemBase::postBuild() if (inv_item) { mIconImage = LLInventoryIcon::getIcon(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), false); - updateItem(inv_item->getName()); + updateItem(inv_item->getName(), get_is_item_favorite(inv_item)); } setNeedsRefresh(true); @@ -290,6 +319,7 @@ LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem mHovered(false), mSelected(false), mSeparatorVisible(false), + mIsFavorite(false), mHoverImage(params.hover_image), mSelectedImage(params.selected_image), mSeparatorImage(params.separator_image) @@ -392,6 +422,16 @@ void LLPanelInventoryListItemBase::setTitle(const std::string& title, default:; } + if (mIsFavorite) + { + static LLUICachedControl<bool> use_color("InventoryFavoritesColorText", true); + if (use_color) + { + static const LLUIColor favorite_color = LLUIColorTable::instance().getColor("InventoryFavoriteColor", LLColor4::white); + style_params.color = favorite_color; + } + } + LLTextUtil::textboxSetHighlightedVal( mTitleCtrl, style_params, @@ -466,6 +506,10 @@ void LLPanelInventoryListItemBase::reshapeMiddleWidgets() S32 name_left = icon_rect.mRight + getWidgetSpacing(); S32 name_right = getLocalRect().getWidth() - mRightWidgetsWidth - getWidgetSpacing(); + if (mIsFavorite) + { + name_right -= FAVORITE_IMAGE_SIZE + FAVORITE_IMAGE_PAD; + } LLRect name_rect(mTitleCtrl->getRect()); name_rect.set(name_left, name_rect.mTop, name_right, name_rect.mBottom); mTitleCtrl->setShape(name_rect); |