summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llaccordionctrltab.h2
-rw-r--r--indra/llui/llflatlistview.cpp13
-rw-r--r--indra/llui/llflatlistview.h6
-rw-r--r--indra/llui/llfolderviewitem.cpp182
-rw-r--r--indra/llui/llfolderviewitem.h23
-rw-r--r--indra/llui/llfolderviewmodel.h7
6 files changed, 225 insertions, 8 deletions
diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h
index f01fff2519..b1dd4e4c2e 100644
--- a/indra/llui/llaccordionctrltab.h
+++ b/indra/llui/llaccordionctrltab.h
@@ -140,7 +140,7 @@ public:
S32 notify(const LLSD& info);
bool notifyChildren(const LLSD& info);
- void draw();
+ virtual void draw();
void storeOpenCloseState();
void restoreOpenCloseState();
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index cd866f1625..10bbcfda9e 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -1356,9 +1356,17 @@ bool LLFlatListViewEx::getForceShowingUnmatchedItems()
return mForceShowingUnmatchedItems;
}
-void LLFlatListViewEx::setForceShowingUnmatchedItems(bool show)
+void LLFlatListViewEx::setForceShowingUnmatchedItems(bool show, bool notify_parent)
{
- mForceShowingUnmatchedItems = show;
+ if (mForceShowingUnmatchedItems != show)
+ {
+ mForceShowingUnmatchedItems = show;
+ if (!mFilterSubString.empty())
+ {
+ updateNoItemsMessage(mFilterSubString);
+ filterItems(false, true);
+ }
+ }
}
void LLFlatListViewEx::setFilterSubString(const std::string& filter_str, bool notify_parent)
@@ -1427,6 +1435,7 @@ void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent)
if (visibility_changed && notify_parent)
{
+ rearrangeItems();
notifyParentItemsRectChanged();
}
}
diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index ba269a7d78..48cd9dd709 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -480,7 +480,11 @@ public:
bool getForceShowingUnmatchedItems();
- void setForceShowingUnmatchedItems(bool show);
+ /**
+ * Sets filtered out items to stay visible. Can result in rect changes,
+ * so can notify_parent if rect changes
+ */
+ void setForceShowingUnmatchedItems(bool show, bool notify_parent);
/**
* Sets up new filter string and filters the list.
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index a9e1171444..71b3c3ddd1 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;
@@ -99,6 +100,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 +128,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 ),
@@ -169,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;
}
@@ -194,6 +200,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() && !vmi->isItemInTrash();
setToolTip(vmi->getName());
// Dirty the filter flag of the model from the view (CHUI-849)
@@ -307,6 +314,7 @@ void LLFolderViewItem::refresh()
LLFolderViewModelItem& vmi = *getViewModelItem();
mLabel = vmi.getDisplayName();
+ mIsFavorite = vmi.isFavorite() && !vmi.isItemInTrash();
setToolTip(vmi.getName());
// icons are slightly expensive to get, can be optimized
// see LLInventoryIcon::getIcon()
@@ -339,6 +347,8 @@ void LLFolderViewItem::refreshSuffix()
mIconOpen = vmi->getIconOpen();
mIconOverlay = vmi->getIconOverlay();
+ mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash();
+
if (mRoot->useLabelSuffix())
{
// Very Expensive!
@@ -752,6 +762,32 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L
}
}
+void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color)
+{
+ static LLUICachedControl<bool> draw_star("InventoryFavoritesUseStar", true);
+ static LLUICachedControl<bool> draw_hollow_star("InventoryFavoritesUseHollowStar", true);
+
+ LLUIImage* favorite_image = NULL;
+ if (draw_star && mIsFavorite)
+ {
+ favorite_image = default_params.favorite_image;
+ }
+ else if (draw_hollow_star && mHasFavorites && !isOpen())
+ {
+ favorite_image = default_params.favorite_content_image;
+ }
+
+ if (favorite_image)
+ {
+ const S32 PAD = 3;
+ const S32 image_size = 14;
+
+ 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;
@@ -911,6 +947,7 @@ void LLFolderViewItem::draw()
{
drawOpenFolderArrow(default_params, sFgColor);
}
+ drawFavoriteIcon(default_params, sFgColor);
drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
@@ -985,7 +1022,20 @@ void LLFolderViewItem::draw()
}
}
- LLColor4 color = (mIsSelected && filled) ? mFontHighlightColor : mFontColor;
+ static LLUICachedControl<bool> highlight_color("InventoryFavoritesColorText", true);
+ LLColor4 color;
+ if (mIsSelected && filled)
+ {
+ color = mFontHighlightColor;
+ }
+ else if (mIsFavorite && highlight_color)
+ {
+ color = sFavoriteColor;
+ }
+ else
+ {
+ color = mFontColor;
+ }
if (isFadeItem())
{
@@ -1079,7 +1129,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)
{
}
@@ -1105,6 +1156,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
@@ -1746,6 +1802,128 @@ BOOL LLFolderViewFolder::isMovable()
return TRUE;
}
+void LLFolderViewFolder::updateHasFavorites(bool 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<LLFolderViewFolder*>(data);
+ if (self->mFavoritesDirtyFlags == 0)
+ {
+ LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL;
+ gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
+ return;
+ }
+
+ if (self->getViewModelItem()->isItemInTrash())
+ {
+ // do not display favorite-stars in trash
+ self->mFavoritesDirtyFlags = 0;
+ gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
+ return;
+ }
+
+ if (self->mFavoritesDirtyFlags == FAVORITE_ADDED)
+ {
+ if (!self->mHasFavorites)
+ {
+ // propagate up, exclude root
+ LLFolderViewFolder* parent = self;
+ 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();
+ }
+ }
+ }
+ else if (self->mFavoritesDirtyFlags > FAVORITE_ADDED)
+ {
+ // full check
+ LLFolderViewFolder* parent = self;
+ while (parent && !parent->getViewModelItem()->isAgentInventoryRoot())
+ {
+ 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)
+ {
+ if (parent->hasFavorites())
+ {
+ parent->setHasFavorites(false);
+ }
+ else
+ {
+ // Nothing changed
+ break;
+ }
+ }
+ else
+ {
+ // propagate up, exclude root
+ 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();
+ }
+ }
+}
+
BOOL LLFolderViewFolder::isRemovable()
{
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index 351613e387..0afe86e151 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -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;
@@ -145,6 +149,8 @@ protected:
static LLUIColor sFilterTextColor;
static LLUIColor sSuffixColor;
static LLUIColor sSearchStatusColor;
+ static LLUIColor sFavoriteColor;
+
// this is an internal method used for adding items to folders. A
// no-op at this level, but reimplemented in derived classes.
@@ -207,6 +213,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 +305,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 +400,18 @@ 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; }
+ void updateHasFavorites(bool new_childs_value);
+private:
+ static void onIdleUpdateFavorites(void* data);
+
+ constexpr static S32 FAVORITE_ADDED = 1;
+ constexpr static S32 FAVORITE_REMOVED = 2;
+ S32 mFavoritesDirtyFlags { 0 };
+public:
+
// destroys this folder, and all children
virtual void destroyView();
void destroyRoot();
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index f02c1e3883..5ba35c2fde 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -162,6 +162,7 @@ public:
virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0;
+ virtual bool isFavorite() const = 0;
virtual BOOL isItemWearable() const { return FALSE; }
virtual BOOL isItemRenameable() const = 0;
@@ -170,7 +171,8 @@ public:
virtual BOOL isItemMovable( void ) const = 0; // Can be moved to another folder
virtual void move( LLFolderViewModelItem* parent_listener ) = 0;
- virtual BOOL isItemRemovable( bool check_worn = true ) const = 0; // Can be destroyed
+ virtual BOOL isItemRemovable( bool check_worn = true) const = 0; // Can be destroyed
+ virtual BOOL isItemInTrash(void) const = 0;
virtual BOOL removeItem() = 0;
virtual void removeBatch(std::vector<LLFolderViewModelItem*>& batch) = 0;
@@ -183,6 +185,9 @@ public:
virtual void pasteFromClipboard() = 0;
virtual void pasteLinkFromClipboard() = 0;
+ virtual bool isAgentInventory() const = 0;
+ virtual bool isAgentInventoryRoot() const = 0;
+
virtual void buildContextMenu(LLMenuGL& menu, U32 flags) = 0;
virtual bool potentiallyVisible() = 0; // is the item definitely visible or we haven't made up our minds yet?