viewer#1300 'Star' favorites in inventory

image is WIP
master
Andrey Kleshchev 2024-04-25 04:46:42 +03:00
parent 384d694aba
commit cea6eeeede
13 changed files with 114 additions and 22 deletions

View File

@ -99,6 +99,8 @@ void LLFolderViewItem::cleanupClass()
LLFolderViewItem::Params::Params()
: root(),
listener(),
favorite_image("favorite_image"),
favorite_content_image("favorite_content_image"),
folder_arrow_image("folder_arrow_image"),
folder_indentation("folder_indentation"),
selection_image("selection_image"),
@ -125,6 +127,8 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
: LLView(p),
mLabelWidth(0),
mLabelWidthDirty(false),
mIsFavorite(false),
mHasFavorites(false),
mSuffixNeedsRefresh(false),
mLabelPaddingRight(DEFAULT_LABEL_PADDING_RIGHT),
mParentFolder( NULL ),
@ -194,6 +198,8 @@ BOOL LLFolderViewItem::postBuild()
// getDisplayName() is expensive (due to internal getLabelSuffix() and name building)
// it also sets search strings so it requires a filter reset
mLabel = vmi->getDisplayName();
mIsFavorite = vmi->isFavorite();
mHasFavorites = vmi->hasFavorites();
setToolTip(vmi->getName());
// Dirty the filter flag of the model from the view (CHUI-849)
@ -307,6 +313,8 @@ void LLFolderViewItem::refresh()
LLFolderViewModelItem& vmi = *getViewModelItem();
mLabel = vmi.getDisplayName();
mIsFavorite = vmi.isFavorite();
mHasFavorites = vmi.hasFavorites();
setToolTip(vmi.getName());
// icons are slightly expensive to get, can be optimized
// see LLInventoryIcon::getIcon()
@ -339,6 +347,9 @@ void LLFolderViewItem::refreshSuffix()
mIconOpen = vmi->getIconOpen();
mIconOverlay = vmi->getIconOverlay();
mIsFavorite = vmi->isFavorite();
mHasFavorites = vmi->hasFavorites();
if (mRoot->useLabelSuffix())
{
// Very Expensive!
@ -754,6 +765,29 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L
}
}
void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color)
{
LLUIImage* favorite_image = NULL;
if (mIsFavorite)
{
favorite_image = default_params.favorite_image;
}
else if (mHasFavorites)
{
favorite_image = default_params.favorite_content_image;
}
if (favorite_image)
{
const S32 PAD = 2;
const S32 image_size = 30;
gl_draw_scaled_image(
getRect().getWidth() - image_size - PAD, getRect().getHeight() - mItemHeight + PAD,
image_size, image_size, favorite_image->getImage(), fg_color);
}
}
/*virtual*/ bool LLFolderViewItem::isHighlightAllowed()
{
return mIsSelected;
@ -913,6 +947,7 @@ void LLFolderViewItem::draw()
{
drawOpenFolderArrow(default_params, sFgColor);
}
drawFavoriteIcon(default_params, sFgColor);
drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);

View File

@ -49,7 +49,9 @@ class LLFolderViewItem : public LLView
public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
Optional<LLUIImage*> folder_arrow_image,
Optional<LLUIImage*> favorite_image,
favorite_content_image,
folder_arrow_image,
selection_image;
Mandatory<LLFolderView*> root;
Mandatory<LLFolderViewModelItem*> listener;
@ -92,6 +94,8 @@ protected:
std::string mLabel;
S32 mLabelWidth;
bool mLabelWidthDirty;
bool mIsFavorite;
bool mHasFavorites;
S32 mLabelPaddingRight;
LLFolderViewFolder* mParentFolder;
LLPointer<LLFolderViewModelItem> mViewModelItem;
@ -207,6 +211,8 @@ public:
// Returns true is this object and all of its children can be moved
virtual BOOL isMovable();
bool isFavorite() const { return mIsFavorite; }
// destroys this item recursively
virtual void destroyView();
@ -297,6 +303,7 @@ public:
// virtual void handleDropped();
virtual void draw();
void drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color);
void drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color);
void drawHighlight(const BOOL showContent, const BOOL hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, const LLUIColor &outlineColor, const LLUIColor &mouseOverColor);
void drawLabel(const LLFontGL * font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
@ -391,6 +398,10 @@ public:
// Returns true is this object and all of its children can be moved
virtual BOOL isMovable();
bool isFavorite() const { return mIsFavorite; }
bool hasFavorites() const { return mHasFavorites; }
void setHasFavorites(bool val) { mHasFavorites = val; }
// destroys this folder, and all children
virtual void destroyView();
void destroyRoot();

View File

@ -161,7 +161,10 @@ public:
virtual void selectItem(void) = 0;
virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0;
virtual bool isFavorite() const = 0;
virtual bool hasFavorites() const = 0;
virtual void setHasFavorites(bool val) = 0;
virtual BOOL isItemWearable() const { return FALSE; }
virtual BOOL isItemRenameable() const = 0;

View File

@ -2037,7 +2037,7 @@ bool LLAppearanceMgr::getCanReplaceCOF(const LLUUID& outfit_cat_id)
}
// Moved from LLWearableList::ContextMenu for wider utility.
bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids) const
bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids, bool warn_on_type_mismarch) const
{
// TODO: investigate wearables may not be loaded at this point EXT-8231
@ -2065,9 +2065,12 @@ bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids) const
{
return isAgentAvatarValid();
}
else
{
LL_WARNS() << "Unexpected wearable type" << LL_ENDL;
else
{
if (warn_on_type_mismarch)
{
LL_WARNS() << "Unexpected wearable type" << LL_ENDL;
}
return false;
}
}

View File

@ -102,7 +102,7 @@ public:
bool getCanReplaceCOF(const LLUUID& outfit_cat_id);
// Can we add all referenced items to the avatar?
bool canAddWearables(const uuid_vec_t& item_ids) const;
bool canAddWearables(const uuid_vec_t& item_ids, bool warn_on_type_mismarch = true) const;
// Copy all items in a category.
void shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id,

View File

@ -79,6 +79,9 @@ public:
virtual LLPointer<LLUIImage> getOpenIcon() const { return getIcon(); }
virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; }
virtual std::string getLabelSuffix() const { return LLStringUtil::null; }
virtual bool isFavorite() const { return false; }
virtual bool hasFavorites() const { return false; }
virtual void setHasFavorites(bool val) {}
virtual BOOL isItemRenameable() const { return TRUE; }
virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; }
virtual BOOL isItemMovable( void ) const { return FALSE; }

View File

@ -68,9 +68,10 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
if (!folder->areChildrenInited() || !needsSort(folder->getViewModelItem())) return;
LLFolderViewModelItemInventory* modelp = static_cast<LLFolderViewModelItemInventory*>(folder->getViewModelItem());
if (modelp->getUUID().isNull()) return;
LLFolderViewModelItemInventory* sort_modelp = static_cast<LLFolderViewModelItemInventory*>(folder->getViewModelItem());
if (sort_modelp->getUUID().isNull()) return;
bool has_favorites = false;
for (std::list<LLFolderViewFolder*>::iterator it = folder->getFoldersBegin(), end_it = folder->getFoldersEnd();
it != end_it;
++it)
@ -79,11 +80,14 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
LLFolderViewFolder* child_folderp = *it;
sort(child_folderp);
LLFolderViewModelItemInventory* modelp = static_cast<LLFolderViewModelItemInventory*>(child_folderp->getViewModelItem());
has_favorites |= child_folderp->isFavorite() || child_folderp->hasFavorites();
if (child_folderp->getFoldersCount() > 0)
{
time_t most_recent_folder_time =
static_cast<LLFolderViewModelItemInventory*>((*child_folderp->getFoldersBegin())->getViewModelItem())->getCreationDate();
LLFolderViewModelItemInventory* modelp = static_cast<LLFolderViewModelItemInventory*>(child_folderp->getViewModelItem());
LLFolderViewModelItemInventory* folderp = static_cast<LLFolderViewModelItemInventory*>((*child_folderp->getFoldersBegin())->getViewModelItem());
time_t most_recent_folder_time = folderp->getCreationDate();
if (most_recent_folder_time > modelp->getCreationDate())
{
modelp->setCreationDate(most_recent_folder_time);
@ -91,16 +95,24 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
}
if (child_folderp->getItemsCount() > 0)
{
time_t most_recent_item_time =
static_cast<LLFolderViewModelItemInventory*>((*child_folderp->getItemsBegin())->getViewModelItem())->getCreationDate();
LLFolderViewModelItemInventory* itemp = static_cast<LLFolderViewModelItemInventory*>((*child_folderp->getItemsBegin())->getViewModelItem());
time_t most_recent_item_time = itemp->getCreationDate();
LLFolderViewModelItemInventory* modelp = static_cast<LLFolderViewModelItemInventory*>(child_folderp->getViewModelItem());
if (most_recent_item_time > modelp->getCreationDate())
{
modelp->setCreationDate(most_recent_item_time);
}
}
}
for (std::list<LLFolderViewItem*>::const_iterator it = folder->getItemsBegin(), end_it = folder->getItemsEnd();
it != end_it && !has_favorites;
++it)
{
LLFolderViewItem* child_itemp = *it;
has_favorites |= child_itemp->isFavorite();
}
folder->setHasFavorites(has_favorites);
sort_modelp->setHasFavorites(has_favorites);
base_t::sort(folder);
}

View File

@ -866,7 +866,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
}
}
if (getIsFavorite())
if (isFavorite())
{
items.push_back(std::string("Remove from Favorites"));
}
@ -2264,7 +2264,7 @@ const LLUUID& LLItemBridge::getThumbnailUUID() const
return LLUUID::null;
}
bool LLItemBridge::getIsFavorite() const
bool LLItemBridge::isFavorite() const
{
LLViewerInventoryItem* item = NULL;
LLInventoryModel* model = getInventoryModel();
@ -2424,7 +2424,7 @@ const LLUUID& LLFolderBridge::getThumbnailUUID() const
return LLUUID::null;
}
bool LLFolderBridge::getIsFavorite() const
bool LLFolderBridge::isFavorite() const
{
LLViewerInventoryCategory* cat = getCategory();
if (cat)
@ -2434,6 +2434,16 @@ bool LLFolderBridge::getIsFavorite() const
return false;
}
bool LLFolderBridge::hasFavorites() const
{
return mHasFavorites;
}
void LLFolderBridge::setHasFavorites(bool val)
{
mHasFavorites = val;
}
void LLFolderBridge::update()
{
// we know we have children but haven't fetched them (doesn't obey filter)
@ -8066,7 +8076,7 @@ void LLFolderViewGroupedItemBridge::groupFilterContextMenu(folder_view_item_dequ
menuentry_vec_t disabled_items;
if (get_selection_item_uuids(selected_items, ids))
{
if (!LLAppearanceMgr::instance().canAddWearables(ids) && canWearSelected(ids))
if (!LLAppearanceMgr::instance().canAddWearables(ids, false) && canWearSelected(ids))
{
disabled_items.push_back(std::string("Wearable And Object Wear"));
disabled_items.push_back(std::string("Wearable Add"));

View File

@ -86,7 +86,7 @@ public:
//--------------------------------------------------------------------
virtual const LLUUID& getUUID() const { return mUUID; }
virtual const LLUUID& getThumbnailUUID() const { return LLUUID::null; }
virtual bool getIsFavorite() const { return false; }
virtual bool isFavorite() const { return false; }
virtual void clearDisplayName() { mDisplayName.clear(); }
virtual void restoreItem() {}
virtual void restoreToWorld() {}
@ -257,7 +257,9 @@ public:
LLViewerInventoryItem* getItem() const;
virtual const LLUUID& getThumbnailUUID() const;
virtual bool getIsFavorite() const;
virtual bool isFavorite() const;
virtual bool hasFavorites() const { return false; }
virtual void setHasFavorites(bool val) {}
protected:
BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response);
@ -279,6 +281,7 @@ public:
mCallingCards(FALSE),
mWearables(FALSE),
mIsLoading(false),
mHasFavorites(false),
mShowDescendantsCount(false)
{}
@ -304,7 +307,9 @@ public:
virtual std::string getLabelSuffix() const;
virtual LLFontGL::StyleFlags getLabelStyle() const;
virtual const LLUUID& getThumbnailUUID() const;
virtual bool getIsFavorite() const;
virtual bool isFavorite() const;
virtual bool hasFavorites() const;
virtual void setHasFavorites(bool val);
void setShowDescendantsCount(bool show_count) {mShowDescendantsCount = show_count;}
@ -392,6 +397,7 @@ protected:
bool mWearables;
bool mIsLoading;
bool mShowDescendantsCount;
bool mHasFavorites;
LLTimer mTimeSinceRequestStart;
std::string mMessage;
LLRootHandle<LLFolderBridge> mHandle;

View File

@ -129,6 +129,9 @@ public:
virtual void navigateToFolder(bool new_window = false, bool change_mode = false) {}
virtual BOOL isItemRenameable() const;
virtual BOOL renameItem(const std::string& new_name);
virtual bool isFavorite() const { return false; }
virtual bool hasFavorites() const { return false; }
virtual void setHasFavorites(bool val) {};
virtual BOOL isItemMovable() const;
virtual BOOL isItemRemovable() const;
virtual BOOL removeItem();

View File

@ -29,6 +29,8 @@
bevel_style="none"
scroll.reserve_scroll_corner="false">
<folder folder_arrow_image="Folder_Arrow"
favorite_image="Favorite_Star_Active"
favorite_content_image="Favorite_Star_Off"
folder_indentation="8"
item_height="20"
item_top_pad="4"

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<folder_view_item
folder_arrow_image="Folder_Arrow"
favorite_image="Favorite_Star_Active"
favorite_content_image="Favorite_Star_Off"
folder_indentation="8"
item_height="20"
item_top_pad="4"

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<inbox_folder_view_folder
folder_arrow_image="Folder_Arrow"
favorite_image="Favorite_Star_Active"
favorite_content_image="Favorite_Star_Off"
folder_indentation="8"
item_height="20"
item_top_pad="4"