From cea6eeeede9f687ca195cc9b9e778fd6784afbe2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 25 Apr 2024 04:46:42 +0300 Subject: viewer#1300 'Star' favorites in inventory image is WIP --- indra/llui/llfolderviewitem.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 2bd14f6f6a..84146e5829 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -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); -- cgit v1.2.3 From a0c4d81080fbc4b5326e6b598e5df27e01631d48 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 27 Apr 2024 05:01:36 +0300 Subject: viewer#1300 'Star' favorites in inventory #2 --- indra/llui/llfolderviewitem.cpp | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 84146e5829..be703a1e9a 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -1783,6 +1783,64 @@ BOOL LLFolderViewFolder::isMovable() return TRUE; } +void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) +{ + if (mHasFavorites != new_childs_value) + { + if (new_childs_value) + { + mHasFavorites = new_childs_value; + // propagate up to root + LLFolderViewFolder* parent = getParentFolder(); + while (parent && !parent->hasFavorites()) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + } + else + { + LLFolderViewFolder* parent = this; + while (parent) + { + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) + { + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) + { + has_favorites = true; + break; + } + } + + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) + { + has_favorites = true; + break; + } + } + + if (!has_favorites) + { + parent->mHasFavorites = false; + parent->setHasFavorites(false); + } + else + { + break; + } + parent = parent->getParentFolder(); + } + } + } +} + BOOL LLFolderViewFolder::isRemovable() { -- cgit v1.2.3 From 2add3b49537fb041b880752dc5302ac6b317e601 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Apr 2024 22:07:12 +0300 Subject: viewer#1300 'Star' favorites in inventory #3 --- indra/llui/llfolderviewitem.cpp | 118 +++++++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 33 deletions(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index be703a1e9a..2accec7a68 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -199,7 +199,6 @@ BOOL LLFolderViewItem::postBuild() // 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) @@ -314,7 +313,6 @@ void LLFolderViewItem::refresh() mLabel = vmi.getDisplayName(); mIsFavorite = vmi.isFavorite(); - mHasFavorites = vmi.hasFavorites(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -348,7 +346,6 @@ void LLFolderViewItem::refreshSuffix() mIconOverlay = vmi->getIconOverlay(); mIsFavorite = vmi->isFavorite(); - mHasFavorites = vmi->hasFavorites(); if (mRoot->useLabelSuffix()) { @@ -1116,7 +1113,8 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mIsFolderComplete(false), // folder might have children that are not loaded yet. mAreChildrenInited(false), // folder might have children that are not built yet. mLastArrangeGeneration( -1 ), - mLastCalculatedWidth(0) + mLastCalculatedWidth(0), + mFavoritesDirtyFlags(0) { } @@ -1142,6 +1140,11 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) // The LLView base class takes care of object destruction. make sure that we // don't have mouse or keyboard focus gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() + + if (mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } } // addToFolder() returns TRUE if it succeeds. FALSE otherwise @@ -1785,60 +1788,109 @@ BOOL LLFolderViewFolder::isMovable() void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) { - if (mHasFavorites != new_childs_value) + if (mFavoritesDirtyFlags == 0) + { + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } + if (new_childs_value) + { + mFavoritesDirtyFlags |= FAVORITE_ADDED; + } + else + { + mFavoritesDirtyFlags |= FAVORITE_REMOVED; + } +} + +void LLFolderViewFolder::onIdleUpdateFavorites(void* data) +{ + LLFolderViewFolder* self = reinterpret_cast(data); + if (self->mFavoritesDirtyFlags == 0) { - if (new_childs_value) + LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + if (self->getViewModelItem()->isItemInTrash()) + { + // do not display favorite-stars in trash + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + LLFolderViewFolder* root_folder = self->getRoot(); + if (self->mFavoritesDirtyFlags == FAVORITE_ADDED) + { + if (!self->mHasFavorites) { - mHasFavorites = new_childs_value; - // propagate up to root - LLFolderViewFolder* parent = getParentFolder(); - while (parent && !parent->hasFavorites()) + // propagate up, exclude root + LLFolderViewFolder* parent = self; + while (parent && !parent->hasFavorites() && root_folder != parent) { parent->setHasFavorites(true); parent = parent->getParentFolder(); } } - else + } + else if (self->mFavoritesDirtyFlags > FAVORITE_ADDED) + { + // full check + LLFolderViewFolder* parent = self; + while (parent && root_folder != parent) { - LLFolderViewFolder* parent = this; - while (parent) + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) { - bool has_favorites = false; - for (items_t::iterator iter = parent->mItems.begin(); - iter != parent->mItems.end();) + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) { - items_t::iterator iit = iter++; - if ((*iit)->isFavorite()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - for (folders_t::iterator iter = parent->mFolders.begin(); - iter != parent->mFolders.end() && !has_favorites;) + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) { - folders_t::iterator fit = iter++; - if ((*fit)->isFavorite() || (*fit)->hasFavorites()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - if (!has_favorites) + if (!has_favorites) + { + if (parent->hasFavorites()) { - parent->mHasFavorites = false; parent->setHasFavorites(false); } else { + // Nothing changed break; } - parent = parent->getParentFolder(); } + else + { + // propagate up, exclude root + while (parent && !parent->hasFavorites() && root_folder != parent) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + break; + } + parent = parent->getParentFolder(); } } + + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); } -- cgit v1.2.3 From 1e7dc04644367dd7eb1469b36848aac265eb7050 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Apr 2024 22:07:12 +0300 Subject: viewer#1300 'Star' favorites in inventory #4 --- indra/llui/llfolderviewitem.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 2accec7a68..682da226bd 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -198,7 +198,7 @@ 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(); + mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash(); setToolTip(vmi->getName()); // Dirty the filter flag of the model from the view (CHUI-849) @@ -312,7 +312,7 @@ void LLFolderViewItem::refresh() LLFolderViewModelItem& vmi = *getViewModelItem(); mLabel = vmi.getDisplayName(); - mIsFavorite = vmi.isFavorite(); + mIsFavorite = vmi.isFavorite() && !vmi.isItemInTrash(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -345,7 +345,7 @@ void LLFolderViewItem::refreshSuffix() mIconOpen = vmi->getIconOpen(); mIconOverlay = vmi->getIconOverlay(); - mIsFavorite = vmi->isFavorite(); + mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash(); if (mRoot->useLabelSuffix()) { @@ -1808,7 +1808,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) if (self->mFavoritesDirtyFlags == 0) { LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); return; } @@ -1816,20 +1816,26 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) { // do not display favorite-stars in trash self->mFavoritesDirtyFlags = 0; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); return; } - LLFolderViewFolder* root_folder = self->getRoot(); if (self->mFavoritesDirtyFlags == FAVORITE_ADDED) { if (!self->mHasFavorites) { // propagate up, exclude root LLFolderViewFolder* parent = self; - while (parent && !parent->hasFavorites() && root_folder != parent) + while (parent + && (!parent->hasFavorites() || parent->mFavoritesDirtyFlags) + && !parent->getViewModelItem()->isAgentInventoryRoot()) { parent->setHasFavorites(true); + if (parent->mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + parent->mFavoritesDirtyFlags = 0; + } parent = parent->getParentFolder(); } } @@ -1838,7 +1844,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) { // full check LLFolderViewFolder* parent = self; - while (parent && root_folder != parent) + while (parent && !parent->getViewModelItem()->isAgentInventoryRoot()) { bool has_favorites = false; for (items_t::iterator iter = parent->mItems.begin(); @@ -1878,19 +1884,28 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data) else { // propagate up, exclude root - while (parent && !parent->hasFavorites() && root_folder != parent) + while (parent + && (!parent->hasFavorites() || parent->mFavoritesDirtyFlags) + && !parent->getViewModelItem()->isAgentInventoryRoot()) { parent->setHasFavorites(true); + if (parent->mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + parent->mFavoritesDirtyFlags = 0; + } parent = parent->getParentFolder(); } break; } + if (parent->mFavoritesDirtyFlags) + { + parent->mFavoritesDirtyFlags = 0; + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent); + } parent = parent->getParentFolder(); } } - - self->mFavoritesDirtyFlags = 0; - gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); } -- cgit v1.2.3 From 1c170381aea21cfd75d7b8789374f04f3a46d408 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 4 May 2024 01:50:50 +0300 Subject: viewer#1300 Update Inventory Settings --- indra/llui/llfolderviewitem.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 682da226bd..b473b3b395 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -58,6 +58,7 @@ LLUIColor LLFolderViewItem::sFilterBGColor; LLUIColor LLFolderViewItem::sFilterTextColor; LLUIColor LLFolderViewItem::sSuffixColor; LLUIColor LLFolderViewItem::sSearchStatusColor; +LLUIColor LLFolderViewItem::sFavoriteColor; // only integers can be initialized in header const F32 LLFolderViewItem::FOLDER_CLOSE_TIME_CONSTANT = 0.02f; @@ -173,6 +174,7 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); + sFavoriteColor = LLUIColorTable::instance().getColor("InventoryFavoriteColor", DEFAULT_WHITE); sColorSetInitialized = true; } @@ -764,6 +766,12 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color) { + static LLUICachedControl draw_star("InventoryFavoritesUseStar", true); + if (!draw_star) + { + return; + } + LLUIImage* favorite_image = NULL; if (mIsFavorite) { @@ -1019,7 +1027,20 @@ void LLFolderViewItem::draw() } } - LLColor4 color = (mIsSelected && filled) ? mFontHighlightColor : mFontColor; + static LLUICachedControl highlight_color("InventoryFavoritesColorText", true); + LLColor4 color; + if (mIsSelected && filled) + { + color = mFontHighlightColor; + } + else if (mIsFavorite && highlight_color) + { + color = sFavoriteColor; + } + else + { + color = mFontColor; + } if (isFadeItem()) { -- cgit v1.2.3 From 5c78396b64c985a7e58d045ff3f343bccc81c8d3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 9 May 2024 00:40:30 +0300 Subject: viewer#1424 Favorites in Appearance floater #1 --- indra/llui/llfolderviewitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index b473b3b395..59be1444d9 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -785,7 +785,7 @@ void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUI if (favorite_image) { const S32 PAD = 2; - const S32 image_size = 30; + const S32 image_size = 18; gl_draw_scaled_image( getRect().getWidth() - image_size - PAD, getRect().getHeight() - mItemHeight + PAD, -- cgit v1.2.3 From 7d1597fc98868c73d6de0b95f3c1af4c459a30c8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 May 2024 22:16:20 +0300 Subject: viewer#1424 Favorites in Appearance floater #4 --- indra/llui/llfolderviewitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 59be1444d9..7be8db4777 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -777,7 +777,7 @@ void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUI { favorite_image = default_params.favorite_image; } - else if (mHasFavorites) + else if (mHasFavorites && !hasVisibleChildren()) { favorite_image = default_params.favorite_content_image; } -- cgit v1.2.3 From 1eeecfa1a8bf43a8980217ce34e3b5f4458483e0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 14 May 2024 15:11:45 +0300 Subject: viewer#1425 Sorting in Appearance floater --- indra/llui/llfolderviewitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 7be8db4777..7a78540510 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -777,7 +777,7 @@ void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUI { favorite_image = default_params.favorite_image; } - else if (mHasFavorites && !hasVisibleChildren()) + else if (mHasFavorites && !isOpen()) { favorite_image = default_params.favorite_content_image; } -- cgit v1.2.3 From 50b93bd83af7cc4ddbd5b8b68f20099dac5f5ed2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 14 May 2024 17:28:00 +0300 Subject: viewer#1424 Favorite support in galleries --- indra/llui/llfolderviewitem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/llfolderviewitem.cpp') diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 7a78540510..0131ab1085 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -784,8 +784,8 @@ void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUI if (favorite_image) { - const S32 PAD = 2; - const S32 image_size = 18; + const S32 PAD = 3; + const S32 image_size = 14; gl_draw_scaled_image( getRect().getWidth() - image_size - PAD, getRect().getHeight() - mItemHeight + PAD, -- cgit v1.2.3