parent
53b3aed710
commit
d3d8513c3b
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ protected:
|
|||
* Called after inventory item was updated, update panel widgets to reflect inventory changes.
|
||||
*/
|
||||
virtual void updateItem(const std::string& name,
|
||||
bool favorite,
|
||||
EItemState item_state = IS_DEFAULT);
|
||||
|
||||
void setLeftWidgetsWidth(S32 width) { mLeftWidgetsWidth = width; }
|
||||
|
|
@ -222,8 +223,9 @@ private:
|
|||
LLUIImagePtr mSelectedImage;
|
||||
LLUIImagePtr mSeparatorImage;
|
||||
|
||||
bool mSelected;
|
||||
bool mSeparatorVisible;
|
||||
bool mSelected = false;
|
||||
bool mSeparatorVisible = false;
|
||||
bool mIsFavorite = false; // note that any setter needs to update tittle
|
||||
|
||||
std::string mHighlightedText;
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ LLPanelWearableOutfitItem::LLPanelWearableOutfitItem(LLViewerInventoryItem* item
|
|||
|
||||
// virtual
|
||||
void LLPanelWearableOutfitItem::updateItem(const std::string& name,
|
||||
bool favorite,
|
||||
EItemState item_state)
|
||||
{
|
||||
std::string search_label = name;
|
||||
|
|
@ -225,7 +226,7 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name,
|
|||
}
|
||||
}
|
||||
|
||||
LLPanelInventoryListItemBase::updateItem(search_label, item_state);
|
||||
LLPanelInventoryListItemBase::updateItem(search_label, favorite, item_state);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -452,6 +453,7 @@ LLPanelAttachmentListItem* LLPanelAttachmentListItem::create(LLViewerInventoryIt
|
|||
}
|
||||
|
||||
void LLPanelAttachmentListItem::updateItem(const std::string& name,
|
||||
bool favorite,
|
||||
EItemState item_state)
|
||||
{
|
||||
std::string title_joint = name;
|
||||
|
|
@ -469,7 +471,7 @@ void LLPanelAttachmentListItem::updateItem(const std::string& name,
|
|||
title_joint = title_joint + " (" + trans_name + ")";
|
||||
}
|
||||
|
||||
LLPanelInventoryListItemBase::updateItem(title_joint, item_state);
|
||||
LLPanelInventoryListItemBase::updateItem(title_joint, favorite, item_state);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -497,7 +499,7 @@ bool LLPanelDummyClothingListItem::postBuild()
|
|||
addWidgetToRightSide("btn_add_panel");
|
||||
|
||||
setIconImage(LLInventoryIcon::getIcon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, mWearableType, false));
|
||||
updateItem(wearableTypeToString(mWearableType));
|
||||
updateItem(wearableTypeToString(mWearableType), false);
|
||||
|
||||
// Make it look loke clothing item - reserve space for 'delete' button
|
||||
setLeftWidgetsWidth(getChildView("item_icon")->getRect().mLeft);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public:
|
|||
* Updates item name and (worn) suffix.
|
||||
*/
|
||||
/*virtual*/ void updateItem(const std::string& name,
|
||||
bool favorite,
|
||||
EItemState item_state = IS_DEFAULT);
|
||||
|
||||
void onAddWearable();
|
||||
|
|
@ -147,6 +148,7 @@ public:
|
|||
|
||||
/** Set item title. Joint name is added to the title in parenthesis */
|
||||
/*virtual*/ void updateItem(const std::string& name,
|
||||
bool favorite,
|
||||
EItemState item_state = IS_DEFAULT);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in New Issue